Perhaps an “Allow plugins/extensions to install required Python packages?” checkbox that determines whether the contents of a plugin’s requirements.txt get installed when the plugin itself is? It could be off by default.
I think from feedback here, if conda is found but only the base environment exists, the configuration dialog should query about creating a new environment for Avogadro, right @matterhorn103
Only the “base” conda environment exists.
Would you like to create a new environment for Avogadro?
[ “avogadro” ]
“Cancel” | “Okay”
I’m trying to decide if that should pop up at first launch … or
the configure dialog (i.e., it finds conda but only one environment)
the downloader (i.e., it needs to install requirements, but the conda environment hasn’t been set)
I suppose the third option makes most sense to me, as then you avoid asking the user until it actually becomes relevant. Asking on first launch would be confusing I think.
Right now, I’d like to merge in what I have, and rigorously test it, which includes:
checking for python on startup and suggesting miniforge
using conda or pip to install requirements.txt for downloads
picking a python from PATH or conda environment
That still means that the code that runs python needs fixes to activate the conda environment. I’m sure there are probably some corner cases and bugs in what I have as PR.
Once that’s working, I’m willing to look at venv and other environments. My main hesitation is that venv can be anywhere.
If you (or others) want to help with research / feedback on how venv support should work… I’m open to it. (For example should every plugin have its own venv then?)
No don’t worry, didn’t come across badly. I agree taking it step-by-step is good. Just thinking for the future
Go ahead and finish the conda stuff for now. When it comes to testing I am very happy to lend a hand.
I’ll have a think and a read on how we can manage venv.
Not sure we need one for each plugin. What advantage would that have? It could lead to excessive duplication of things like numpy, which would suck.
It’s a good point about the possibility of them being anywhere, I’d forgotten that.
I guess Avogadro doesn’t really need to do automatic detection of venv environments. If the user wants to use a specific one they can manually configure the location. I would instead suggest that the possible location of a venv only becomes relevant when a plugin needs dependencies:
If conda was found or specified by the user, and a conda environment is specified, dependencies are installed to that (if the user wishes)
If conda was found but no environment is specified, Avo suggests the creation of a conda environment called avogadro
If the Python binary path is not a conda installation, but a venv environment was already specified manually in the Python config, use that
If no venv has been found, suggest the creation of a venv called avogadro. Probably best to put it in the plugins directory or some other user data directory.
If the location is kept consistent, then if a user agrees to make an avogadro environment (with conda or venv) then Avo can first look if there’s already one and use it. In this way the environment could be persistent between reinstallations or updates.