问题
I've got a custom pypi server running and am wondering how to point all references to https://pypi.python.org/ from there to my custom server?
I want to be able to cover cases of a user calling pip
/ easy_install
of a package (so they don't have to remember to do -i
or -f
) as well as someone doing python setup.py install
using setuptools with install_requires
in the setup.py
.
Is there some global config or setting I can do to get all these different methods to look at my local server? I imagine doing some network-proxy-type magic to route http://pypi.python.org/
to my custom server would be one way to go but unfortunately that's not an option.
Thanks!
回答1:
The following configuration will disable the pypi repository index and make your index the only index used by pip
and easy_install
. The setuptools install
command is basically a shortcut to run the easy_install
command on the current project. So, that would work too.
# Add the following to ~/.pydistutils.cfg for easy_install
[easy_install]
index_url = http://localhost:8000/
# Add the following to ~/.pip/pip.conf for pip
[global]
index-url = http://localhost:8000/
Look at easy_install's and pip's documentation for more information.
You could provide your users with a simple python script that creates these config files for them.
回答2:
You need to change 2 files:
For distutils
Configuration file: doc
~/.pydistutils.cfg
for linux,$HOME/pydistutils.cfg
for Windows
Content:
[easy_install] index_url = YOUR_URL
This concerns commands like python setup.py install
.
For pip
Configuration file: doc
~/.pip/pip.conf
for linux,$HOME/pip/pip.conf
for Windows
Content:
[global] index-url = YOUR_URL
This concerns pip install mypackage
commands.
来源:https://stackoverflow.com/questions/15014180/setuptools-easy-install-and-a-custom-pypi-server