[Distutils] A problem with setuptools, virtualenv and numpy
Christian Marquardt
christian at marquardt.sc
Sat Mar 28 00:17:51 CET 2009
Hello,
I've run into the following problem:
- I have numpy (v1.3.0b1) successfully installed in my system's
site-packages (for Python 2.5.2).
- I have setup a virtual environment (with virtualenv 1.3.3) which
uses the systems site-packages; in particular, I can load numpy
when working in that environment.
- I have a (namespaced) package which requires numpy (via
"install_requires = ['numpy']" in the setup() of setuptools
(v0.6c9, as coming with virtualenv), and try to build that in
the virtual environment using the usual python setup.py install.
- When processing the requirements for the packages, setuptools
downloads a fresh copy from numpy 1.3.0b1 from Pypi and tries
to install it - although numpy is already available in the system
wide site-packages directory.
To me, that's a bug, but I would like to know if it is a bug in numpy
(which might not support setuptools in the correct way) or setuptools
which tries to install an already existing package.
I have tried to debug this a bit and found that the problem seems to
happen in the easy_install.process_distribution() method in
easy_install.py, in the following part of the code:
log.info("Processing dependencies for %s", requirement)
try:
distros = WorkingSet([]).resolve(
[requirement], self.local_index, self.easy_install
)
except [...]
if self.always_copy or self.always_copy_from:
# Force all the relevant distros to be copied or activated
for dist in distros:
if dist.key not in self.installed_projects:
self.easy_install(dist.as_requirement())
log.info("Finished processing dependencies for %s", requirement)
*IF* I understand the code and comments in there correctly,
WorkingSet([]).resolve() returns a list of requirement objects
representing the requirements which are fulfilled in the existing
environment; in my case, that's the package itself as well as numpy:
>>> print distros
[yaros.gras 0.4.dev-r53 (/home/marq/.virtualenvs/yaros-devel/lib/python2.5/site-packages/yaros.gras-0.4.dev_r53-py2.5.egg), numpy 1.3.0b1 (/opt/apps/lib/python2.5/site-packages)]
The paths are also pointing to the correct directories.
Next, self.always_copy_from == '.', so the loop at the end of
the code above is also run through. The requirement object of
the package is filtered out, but the numpy requirement object is
passed to self.easy_install(), which then tries to fetch the
source code from Pypi.
Is that the intended behavior or a bug?
Many thanks,
Christian.
More information about the Distutils-SIG
mailing list