\n
[1]: Technically, if there are create_default_packages
set in the Conda configuration, Conda will first create the environment with just these packages, then subsequently install the dependencies specified in the YAML file.
Reputation: 1463
I am trying to create a conda environment.yml file for users of a project. One dependency is not distributed by conda, but available with pip+github. I assume based on this example that I can do this:
dependencies
- pip
- regular_conda_dep
- depend_of_blah
# Install in editable mode.
- -e git+https://github.com/ourgroup/blah.git
But what happens to the dependencies of blah (depend_of_blah)? Will the pip install after the conda so that as long as I am careful to include it gets installed before blah? Later on will blah update cleanly, getting as much as possible from conda?
Or do I need to add --no-deps to the pip line? Is it implied that this is done magically? I don't see a lot of advanced examples that deal with this, but in my experience is that it is a real danger in pip/conda mixes not to use --no-deps, with pip essentially hijacking anything that hasn't been explicitly handled first.
Upvotes: 4
Views: 2700
Reputation: 1350
You can tell pip to ignore dependencies via environment variables
PIP_NO_DEPS=1 conda env create -f myenv.yaml
From the documentation:
pip’s command line options can also be set with environment variables using the format
PIP_<UPPER_LONG_NAME>
. Dashes (-
) have to be replaced with underscores (_
).
Upvotes: 4
Reputation: 77098
Conda parses the YAML, and partitions the dependency specifications into a Conda set and a Pip set (code). Only the Conda set is used to solve and create the initial environment.1 Once the environment has been successfully created, Conda writes all the Pip specifications to a temporary requirements.txt
(code), and then using the python
in the environment runs the command:
python -m pip install -U -r <requirements.txt>
So, to explicitly answer the question: If all the dependencies of blah
are installed via Conda and they have sufficient versions installed, then Pip should only install blah
and leave the Conda versions untouched. This is because the default value for --upgrade-strategy
is only-if-needed
.
Otherwise, if the Conda dependencies section does not include all the dependencies of blah
, then Pip will install the necessary dependencies.
[1]: Technically, if there are create_default_packages
set in the Conda configuration, Conda will first create the environment with just these packages, then subsequently install the dependencies specified in the YAML file.
Upvotes: 2