Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to have platform-specific dependencies in environment.yml?

I'm trying to use Conda to set up build & testing environments for a project (LensKit), and need to have platform-specific dependencies. Specifically, on Linux builds I need libgfortran and openssl, but not on Windows.

Is there a way that I can state, in environment.yml, that I need libgfortran but only on the 32- and 64-bit Linux platforms? Or do I need to have separate environment definitions to cover this case?

The other potential solution I see is creating a dummy package and publishing it to http://anaconda.org that just depends on the required base packages for each platform, and require that package in environment.yml.

like image 470
Michael Ekstrand Avatar asked Sep 30 '15 14:09

Michael Ekstrand


People also ask

Can you share Anaconda environment?

You can use Anaconda to export a Python virtual environment to a YAML file you can then reuse in different projects. You can also share the YAML file with your team, so everyone's on the same track.

How do I change the base environment in Anaconda prompt?

Go to the start menu, right-click 'Anaconda Prompt' and go to file location. Open its properties & change the target to the location of your preferred environment.


1 Answers

I stumbled across the same problem and wrote a small parser for exactly this problem. In your case, you could create an environment.yml.meta file as follows:

name: demo_env
dependencies:
  - <your_other_dependencies>
  - libgfortran [platform startswith linux]
  - openssl     [platform startswith linux]

and then create the environment from it with

python create_env.py

It's of course not the same as if it was supported native, because you need to either add the parser as submodule to your repo or just copy it over, but maybe you find it useful. The project is on GitHub:

https://github.com/silvanmelchior/cme_parser

like image 137
silvan Avatar answered Oct 03 '22 21:10

silvan