[Cubicweb] Cubicweb packaging problem
sylvain.thenault at logilab.fr
Wed Jul 30 08:03:40 CEST 2014
On 29 juillet 17:23, Yann Cointepas wrote:
> I am trying to create a "package" (i.e. a virtualenv based directory that
> can be used after setting PATH, PYTHONPATH, etc.) containing Cubicweb to
> use it on various Linux systems. My problem is that I cannot use "import
> logilab" on systems that have already this module installed because, after
> importation, I always have logilab.__file__ pointing to
> /usr/lib/python2.7/dist-packages/logilab/__init__.pyc (I do testing on
> Ubuntu) even if my PYTHONPATH is correct.
> I checked (with a print) that logilab/__init__.py is executed from my
> package. The problem comes from the content of that file. If I remove
> "__import__('pkg_resources').declare_namespace(__name__)", I have no more
> path problems (and I can finally "import cubicweb" from my package).
> Do you think it is a bug in logilab module or in pkg_resources ?
> Could someone suggest a better solution than modifying logilab/__init__.py
> each time I create a new package ?
This is weird and I've to admit I don't know why you get this behaviour. I fail
to see why, if your package's logilab directory is first in your PYTHONPATH, it
ends up importing the system wide's one first.
Anyway you should look up at __path__ instead of __file__. You may ends up
having both logilab's directory there.
If investigation shows that logilab's __init__ should be shaped differently, we
may do that.
Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (05.62.17.16.42)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure: http://www.logilab.fr/services
CubicWeb, the semantic web framework: http://www.cubicweb.org
More information about the Cubicweb