[Cubicweb] Cubicweb is not compatible with virtualenv --system-site-package

Yann Cointepas yann at cointepas.net
Fri Oct 3 15:26:17 CEST 2014


Hi,

If the following assumption is true, there is an import bug in Logilab and
Cubicweb Python modules.

*The assumption:*

Using virtualenv with --system-site-package option make it possible to use
system packages that are not installed in virtualenv. If a module is
installed both on virtualenv and on system, the virtualenv version will be
used.

*The problem*

The assumption works for all modules I tried except the ones from logilab
or cubicweb. If these modules are installed in both virtualenv and system,
the system version is used. The following proof shows the difference
between lxml module and logilab module. It also show a tricky situation
where cubicweb was installed on a virtualenv and work perfectly until
someone install pylint on the system. The consequence (of the dependency on
logilab.common of pylint) is that cubicweb will be taken from virtualenv
but logilab.* will be in the system. The actual versions can be more or
less incompatible. For instance, today (i.e. with today pip version of
cubicweb) it is still possible on Ubuntu 14.04 to import cubicweb (but one
may have surprise at runtime) but it is not possible on Ubuntu 12.04
(logilab.common.registry does not exist on the system version but is
expected on recent cubicweb version).

*The proof*

Starting from a brain new installation of Ubuntu 14.04.
Installation of cubicweb and lxml in virtualenv:

$ sudo apt-get install libxml2-dev libxslt1-dev libpq-dev libgecode-dev
$ virtualenv --system-site-package ~/cubicweb
$ ~/cubicweb/bin/pip install cubicweb
$ ~/cubicweb/bin/pip install lxml

Check that, lxml, logilab and cubicweb modules are all imported from
virtualenv

$ ~/cubicweb/bin/python -c 'import lxml; print lxml.__file__'
/home/yann/cubicweb/local/lib/python2.7/site-packages/lxml/__init__.pyc
$ ~/cubicweb/bin/python -c 'import logilab; print logilab.__file__'
/home/yann/cubicweb/local/lib/python2.7/site-packages/logilab/__init__.pyc
$ ~/cubicweb/bin/python -c 'import cubicweb; print cubicweb.__file__'
/home/yann/cubicweb/local/lib/python2.7/site-packages/cubicweb/__init__.pyc

Install pylint that may seem to have nothing to do with cubicweb but
depends on logilab.common

$ sudo apt-get install pylint

Now, lxml and cubicweb are imported from virtualenv but logilab is imported
from system.

$ ~/cubicweb/bin/python -c 'import lxml; print lxml.__file__'
/home/yann/cubicweb/local/lib/python2.7/site-packages/lxml/__init__.pyc
$ ~/cubicweb/bin/python -c 'import logilab; print logilab.__file__'
/usr/lib/python2.7/dist-packages/logilab/__init__.pyc
$ ~/cubicweb/bin/python -c 'import cubicweb; print cubicweb.__file__'
/home/yann/cubicweb/local/lib/python2.7/site-packages/cubicweb/__init__.pyc

      Yann
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubicweb.org/pipermail/cubicweb/attachments/20141003/e368d989/attachment-0185.html>


More information about the Cubicweb mailing list