问题
I am running a local pypi server. I can install packages from this server by either specifying it with the -i
option of the pip
command or by setting the PIP_INDEX_URL
environment variable. When I install a package that has prerequisites, setup.py
has historically honored the PIP_INDEX_URL
environment variable, pulling the additional packages from my local server.
However, on a couple of systems that have been recently installed, it is behaving differently. Running, for instance, python setup.py develop
fails because it tries to install prerequisites packages from pypi.python.org.
I have updated all of the related python packages (python
, distribute
, virtualenv
, pip
, etc...) on all the systems I'm testing on and continue to see this discrepancy. On my "original" system, setup.py
downloads prerequisites from the pypi server specified in my PIP_INDEX_URL
environment variable. On the newer systems, I can't seem to make it honor this variable.
What am I missing?
回答1:
Create setup.cfg
in the same folder as your setup.py
with following content:
[easy_install]
allow_hosts = *.myintranet.example.com
From: http://pythonhosted.org/setuptools/easy_install.html#restricting-downloads-with-allow-hosts
You can use the
--allow-hosts (-H)
option to restrict what domains EasyInstall will look for links and downloads on.
--allow-hosts=None
prevents downloading altogether.
回答2:
I ran into the same issue. Fundamentally, setup.py
is using setuptools
which leverages easy_install
, not pip
. Thus, it ignores any pip-related
environment variables you set.
Rather than use python setup.py develop
you can run pip (from the top of the package) pip install -e .
to produce the same effect.
来源:https://stackoverflow.com/questions/21687561/setup-py-not-honoring-pip-index-url