Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
209 views
in Technique[技术] by (71.8m points)

python - Virtualenv specific pip config files

I need to use different pip config files depending on which project I'm currently working on. Each project pulls from a separate pypi repo and needs its own block in my .pip/pip.conf file

[global]
    timeout = 60
    index-url = <my_custom_pypi_repo>

Is there a way to provide a pip.conf file on a virtualenv specific basis?

Ideally when I run

 workon env1
 pip install env1_package

It would only try and download from the env1 config file

And similar for env2 Ideally when I run

 workon env2
 pip install env2_package

I would like it to not request this package from the env1 pypi server.

question from:https://stackoverflow.com/questions/35638576/virtualenv-specific-pip-config-files

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Found this after I had posted the question:

https://pip.pypa.io/en/stable/user_guide/#config-file

 ~/.pip/pip.conf

You will need to set:

 ~/.virtualenvs/env1/pip.conf
 ~/.virtualenvs/env2/pip.conf

It will still inherit from:

 ~/.pip/pip.conf

But will allow it to be overwritten for each environment.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...