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

强颜欢笑 提交于 2019-12-04 03:22:43

问题


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.


回答1:


The "dummy packages" are actually called "metapackages". See http://conda.pydata.org/docs/building/meta-pkg.html. That seems a good option.

Alternatively, could you build a conda package of your project? In the conda recipe's meta.yml you can use selectors for different platforms. http://conda.pydata.org/docs/building/meta-yaml.html#preprocessing-selectors




回答2:


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



来源:https://stackoverflow.com/questions/32869042/is-there-a-way-to-have-platform-specific-dependencies-in-environment-yml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!