The conda plugin

The conda plugin is useful, primarily, for Python parts using the Conda open source package management system.

This plugin uses the common plugin keywords as well as those for “sources”. For more information, see Snapcraft parts metadata.

Additional features and syntax are dependent on which base is being used, as outlined below:

For examples, search GitHub for projects already using the plugin.

ⓘ This is a snapcraft plugin. See Snapcraft plugins and Supported plugins for further details on how plugins are used.

base: core22

This plugin uses the following plugin-specific keywords:

  • conda-packages (list of strings) List of conda packages to install.
  • conda-python-version (string) The Python version to use for the conda packages. Python version major and minor version (e.g. 3.9).
  • conda-miniconda-version (string, default: latest) The version of Miniconda to bootstrap. Defaults to the latest release.

Requires Snapcraft version 7.0+ .

base: core20

This plugin uses the following plugin-specific keywords:

  • conda-packages (list of strings) List of conda packages to install.
  • conda-python-version (string) The Python version to use for the conda packages. Python version major and minor version (e.g. 3.9).
  • conda-miniconda-version (string, default: latest) The version of Miniconda to bootstrap. Defaults to the latest release.

Requires Snapcraft version 4.6+ .

base: core18 | core

This plugin uses the following plugin-specific keywords:

  • conda-packages (list of strings) List of conda packages to install.
  • conda-python-version (string) The Python version to use for the conda packages. Defaults to the latest supported by Miniconda.
  • conda-miniconda-version (string) The version of Miniconda to bootstrap. Defaults to the latest release.

It is an awesome plugin, thanks.
But how do you install a package using conda that is on a custom channel?
For example, you want to add a package that is available on conda-forge ( conda install -c conda-forge hypothesis)?

1 Like

@hovakim_grabski, when you set “foo” and “bar” for your conda-packages directive, the Python Command that will run is ['conda', 'create', '--prefix', 'something', '--yes', 'foo', 'bar'], which is parsed to the shell command conda create --prefix something --yes foo bar. To allow conda-forge, you just have to add -c conda-forge to that command, so your conda-packages would be:

conda-packages:
    - -c
    - conda-forge
    - foo
    - bar

It’s clearly a workaround, but it works. It would be nice, however, to have an explicit option to allow this.

Is it possible to activate an environment before running the snap? I have a working environment.yml that installs some conda dependencies, then some pip dependencies, and, finally, my package that exposes a command through an entry_point. As it seems to be impossible to use an environment in the conda-snap plugin, I can’t install the pip packages and, therefore, can’t expose the command. Then, snapcraft says:

Failed to generate snap metadata: 
The specified command 'myscript' defined in the app 'myscript' does not exist.
Ensure that 'myscript' is installed with the correct path.

Is there any way to workaround this?

A minor documentation issue here: https://snapcraft.io/docs/conda-plugin, there is a link in the first sentence that leads to 404. What is the best place to report docs issues?

Hello! This is exactly the right place to report such issues. I’ll remove the link for now, but with the conda snap likely missing or deprecated, I’ll make a note to look into this a little more. We may need to revise this page more substantially. Thanks for reporting this.