How to declare build time dependencies without breaking other packages?

I had a problem installing a package dependent on python-daemon . I ended up tracing it to the latest version of the python-daemon package (2.0.3) released yesterday. Testing in a virtual environment on an Ubuntu 14.04 machine and issuing the following commands:

 (venv) $ pip list argparse (1.2.1) pip (1.5.6) setuptools (3.6) wsgiref (0.1.2) (venv) $ pip install redis ... works fine .... (venv) $ pip install python-daemon ... snip ... File "/home/pwj/.virtualenvs/venv/local/lib/python2.7/site-packages/pkg_resources.py", line 2147, in load ['__name__']) ImportError: No module named version (venv)02:15 PM tmp$ pip list argparse (1.2.1) lockfile (0.10.2) pip (1.5.6) python-daemon (2.0.3) setuptools (3.6) wsgiref (0.1.2) 

So the installation of python-daemon seemed to work, but something affected pip or setuptools because the other packages ( celery , flask ) I am trying to install with pip after that gives me the same trace:

  ... snip ... File "/home/pwj/.virtualenvs/venv/local/lib/python2.7/site-packages/pkg_resources.py", line 2147, in load ['__name__']) ImportError: No module named version 

If I remove python-daemon with pip elements again and packages that did not install now install normally. Has anyone else come across this or something similar to another project? My solution was to install the previous version

 (venv) $ pip install python-daemon==2.0.2 ... works ... 

but wondered what might cause such an error.

+8
python setuptools
source share
1 answer

(This behavior has been fixed in python-daemon version 2.0.4 and later.)

There are two sides:

  • Setuptools assumes that it is the center of everything.
  • Python-daemon version 2.0.3 does not take this into account.

A more detailed explanation: there is complex code using Docutils involved in the python-daemon build process, which is not needed after installation and is not part of the library code.

It is too difficult to leave in the irreplaceable (and therefore not testable) setup.py , so the assembly code is shunted into a separate module under test, version (in the version.py file), which itself uses Docutils.

But then setup.py has a cyclical dependency: how to import version when Docutils is not installed yet? How to use Setuptools to ensure the installation of Docutils, when running setup.py version will be required to complete? All possible solutions are ugly and confusing.

The approach adopted in 'python-daemon 2.0.3 is to declare the Docutils required for installation and declare the Setuptools entry point for which version is required. This way setup.py gets the installation of Docutils to any entry point that will use version .

But now we come to the first point that Setuptools takes over the center of everything. After announcing the entry point, setup.py changed every Setuptools action after that, and each package will fail if it cannot find the entry points. And, since most of them do not have version or the specified functions in this module, they call the Setuptools command.

What, in essence, is a mistake that needs to be fixed, shows a poorly understood case angle in Setuptools. Therefore, I vote for your question.

This doesn't seem to be a good solution: having modules for setup.py , but above all providing requirements. Setuptools suggests that this is the only build system needed to satisfy all the dependencies for everything, and when this assumption fails, it is very difficult to get around.

Thanks to the Python Packaging Authority and the distutils-sig forum for explaining this to me.

+4
source share

All Articles