Update the current env with the requirements describe in meta.yaml

Viewed 483

I would like to update the current env, juste after the git pull, with a rule in the Makefile, compatible for all OS.

> git pull
> conda env update --meta meta.yaml # Something like that

How it's possible to update the current env with the requirements present in meta.yaml ?

The export approach duplicate the dependencies and versions and it's specific to a platform (Windows, Linux, etc).

> conda env export > export.yaml # Bad solution. Duplicate info from meta.yaml

It's not sure to have the same requirements in export.yaml and all describe in the meta.yaml.

I would like something like

> conda env update --meta meta.yaml

to import all requirement describe in build:, run: and test:

1 Answers

One solution is to create a script to take care of "combining" the requirements in build, test, and run; and produce the desired env.yaml for conda.

meta_update.py

#!/usr/bin/python3
import yaml

with open('meta.yaml', 'r') as meta_file:
    meta = yaml.load(meta_file)

env = {}
for req_type in ['build', 'run', 'test']:   # or more generally: for req_type in meta.keys():
    env.update(meta[req_type])

yaml.dump(env, 'my_env.yaml')

Then in your Makefile, you can call meta_update.py, followed by conda env update my_env.yaml.

Related