I'm working on a Python library and using the anaconda distribution. I install packages into a conda
environment with both conda
and pip
. I'd like to install Python packages from both PyPi and an in-house repository server (Sonatype Nexus). To do this I need to set the --extra-index-url
flag.
I'd like to make this reproducible to enable anyone to recreate the environment from a script so setting --extra-index-url
from a command line invocation of pip
isn't an option.
I could set this globally in $HOME/.pip/pip.conf
, which works, but this isn't transferrable to other users, at least not in an automated way.
Is there a way to set a conda
environment specific pip.conf
file? Where would it be placed? This would enable anyone to check out the library code and recreate the environment with all dependencies intact and pulling code from an internal repository?
It might be worth mentioning that Conda YAML environment definitions support the full spectrum of the pip install
arguments, including --extra-index-url
. For example, one could have something like:
environment.yaml
name: foo
channels:
- defaults
dependencies:
- python=3.9
- numpy
- scipy
- pip
- pip:
- --extra-index-url https://127.0.100.55 # some custom URI
- custom-pkg1
- custom-pkg2
See Conda's Advanced Pip Example for a showcase of other capabilities.
You can set the environmental variable PIP_CONFIG_FILE
and point to the pip.conf
you like. Since you want
to recreate the environment from a script
you could set PIP_CONFIG_FILE
in this script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With