Conda plugin: activate an environment

I’m trying to use the conda plugin. 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.

Of course, I need the environment activated so that the command can be found. Is there any way to activate a full conda environment in the snap building process? Is there any way to workaround this?

Can you share the layout of the prime directory?

1 Like

@sergiusens, sure!

Here is my directory structure (yes, I’m using Julia and Python, and this is exactly why I need conda):

.
├── cstest
│   ├── __init__.py
│   ├── julia.jl
│   ├── main.py
│   └── something.py
├── environment.yml
├── README.md
├── requirements.txt
├── setup.py
└── snapcraft.yaml

And here is my setup.py (which defines the entrypoint myscript):

from setuptools import setup, find_packages

setup(
    name='cstest',
    version='0.1.0',
    packages=find_packages(),
    include_package_data=True,
    package_data={"cstest": ["*.jl"]},
    entry_points={
        'console_scripts': [
            'myscript = cstest.main:main',
        ],
    },
)

Just in case, I present also my environment.yml:

name: cstest
channels:
  - conda-forge
  - anaconda
  - defaults
dependencies:
  - python==3.10
  - julia==1.6.5
  - pip
  - pip:
    - julia
    - .
    - -r requirements.txt

Hi, thanks but this is the source directory, I would like to see the prime directory.

You can get the prime directory locally by running snapcraft prime --shell-after and then running find prime