Oh and I forgot to mention that it would also allow plugins to depend on each other, if we permit it.
Ok then, this is fair enough, but I think we should keep simple scripts simple – which to me means that they should retain their self-contained nature and not need to be supported by metadata files.
Happily around a year ago the Python community standardized on a way to specify dependencies within a script using inline script metadata, so I suggest we take advantage of that existing standardized mechanism.
Unfortunately, pixi
doesn’t support this, as it’s only really geared towards a project-based or environment-based workflow. This is one thing I like about uv
– it makes a great effort to be suitable for all the various workflows people have. Conda ecosystem support is low on their agenda though.
I don’t see that as a huge problem though – parsing the metadata block is fairly straightforward with the regex-based reference implementation and Avogadro can make sure the environment has the packages the script needs.
I suggest that we use a [tool.avogadro]
table, both in script metadata for scripts and in pyproject.toml
for packages, to store any metadata we need to have access to without executing any code.
In scripts, we can also support putting pixi
’s table in our table and then pass it wholesale to pixi
.
Adapting the example from the above links, the top of an energy script for Avogadro could then look like this for PyPI dependencies:
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "numpy>=2.2.0",
# ]
#
# [tool.avogadro]
# script-type = "energy"
# ///
import numpy as np
...
or like this for conda ones:
# /// script
# requires-python = ">=3.11"
#
# [tool.avogadro]
# script-type = "energy"
#
# [tool.avogadro.pixi]
# channels = ["conda-forge"]
#
# [tool.avogadro.pixi.dependencies]
# numpy = ">=2.2.0"
# ///
import numpy as np
...
In this way we could in theory have all the scripts in a single directory, just like now, and the scripts can be run with pixi exec --spec <dependencies> <script>
in isolated – but cached – environments.
If you like the sort of direction I’m thinking about, I’d be very happy to.