Skip to content

Commit

Permalink
Conda: define explicit python requirement in environment.yml (#3758)
Browse files Browse the repository at this point in the history
It turns out that when creating a conda environment from an
`environment.yml` file, it is not possible to specify or override the
python version of the environment from the command line.

I.e. it turns out that:

   conda env create -f environment.yml -n test-environment python=3.7

actually sets up a python 3.6 environment. This was because the
dependency `plumpy` was not yet marked as being compatible with
python 3.7. This has since been fixed and we now explicitly set the
python version in the `environment.yml` file.
  • Loading branch information
ltalirz authored Feb 14, 2020
1 parent 0a45f40 commit 12f9641
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/conda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ export PATH="$HOME/miniconda/bin:$PATH"
hash -r
conda config --set always_yes yes --set changeps1 no

# Workaround for https://github.com/conda/conda/issues/9337
pip uninstall -y setuptools
conda install setuptools

conda update -q conda
conda info -a
conda env create -f environment.yml -n test-environment python=$PYTHON_VERSION
conda env create -f environment.yml -n test-environment
3 changes: 2 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Usage: conda env create -n myenvname -f environment.yml python=3.6
# Usage: conda env create -n myenvname -f environment.yml
---
name: aiida
channels:
- defaults
- conda-forge
- etetoolkit
dependencies:
- python~=3.7
- aldjemy~=0.9.1
- alembic~=1.2
- circus~=0.16.1
Expand Down
7 changes: 5 additions & 2 deletions utils/validate_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ def update_environment_yml():
replacements = {'psycopg2-binary': 'psycopg2', 'graphviz': 'python-graphviz'}
install_requires = get_setup_json()['install_requires']

conda_requires = []
# python version cannot be overriden from outside environment.yml
# (even if it is not specified at all in environment.yml)
# https://github.com/conda/conda/issues/9506
conda_requires = ['python~=3.7']
for req in install_requires:
# skip packages required for specific python versions
# (environment.yml aims at the latest python version)
Expand All @@ -309,7 +312,7 @@ def update_environment_yml():
environment_filename = 'environment.yml'
file_path = os.path.join(ROOT_DIR, environment_filename)
with open(file_path, 'w') as env_file:
env_file.write('# Usage: conda env create -n myenvname -f environment.yml python=3.6\n')
env_file.write('# Usage: conda env create -n myenvname -f environment.yml\n')
yaml.safe_dump(
environment, env_file, explicit_start=True, default_flow_style=False, encoding='utf-8', allow_unicode=True
)
Expand Down

0 comments on commit 12f9641

Please sign in to comment.