[Python-projects] namespace packages support?

F. Oliver Gathmann gathmann at cenix-bioscience.com
Thu Apr 9 14:57:04 CEST 2009


Hello!

I am trying to re-package a monolithic library I am maintaining into a 
number of small, easy-installable packages, using the "namespace 
packages" feature of setuptools. However, I am having trouble to have 
pylint cooperate with the layout of my project.

In looking for a solution to my problem I realized that the various 
logilab packages make themselves heavy use of namespace packages, so I 
investigated more closely how pylint copes with the layout of its own 
dependent packages.

If I put pylint and its required logilab sources in a tree layed out 
like this:

somedir/
     logilab/
         logilab/
             common/
             astng/
     pylint/
         pylint/

and run pylint on one of its own modules like so (in <somedir>):

$ env PYTHONPATH=pylint:logilab python pylint/pylint/lint.py 
--include-ids=y pylint/pylint/checkers/variables.py | grep E0611
No config file found, using default configuration

No errors found - everything is fine.

However, if I separate the two logilab packages in a layout like this:

somedir/
     logilab_common/
         logilab/
             common/
     logilab_astng/
         logilab/
             astng/
     pylint/
         pylint/

and run like so (again, in <somedir>):

$ env PYTHONPATH=pylint:logilab_common:logilab_astng python 
pylint/pylint/lint.py --include-ids=y 
pylint/pylint/checkers/variables.py | grep E0611
No config file found, using default configuration
E0611: 22: No name 'astng' in module 'logilab'
E0611: 23: No name 'astng' in module 'logilab'
E0611: 24: No name 'astng' in module 'logilab'
|E0611      |3          |

I get unfriendly import errors from pylint. However, actually accessing 
the logilab.astng package with the same package layout:

$ env PYTHONPATH=pylint:logilab_common:logilab_astng python -c "from 
logilab import astng; print astng.__name__"
logilab.astng

works fine (this is with a clean 2.5.1 interpreter with only setuptools 
in the site-packages, BTW).

Now, I would much rather have a layout with separated package 
directories for my own project (like in the second example above) - is 
there any way I could get pylint to work with this?

Thank you very much in advance,

Oliver

-- 
--------------------------------------------------------------------
F. Oliver Gathmann, Ph.D.
Director IT Unit
Cenix BioScience GmbH
Tatzberg 47                       phone: +49 (351) 4173-136
D-01307 Dresden, Germany          fax:   +49 (351) 4173-109

fingerprint: 8E0E 9A64 A07E 0D1A D302  34C2 421A AE9F 4E13 A009
public key: http://www.cenix-bioscience.com/public_keys/gathmann.gpg
--------------------------------------------------------------------

---------------------------------------------------------
Sitz der Gesellschaft (Place of Business): Dresden
Geschaeftsfuehrer (CEO): Dr. Christophe J. Echeverri
Amtsgericht (Local Court): Dresden, HRB 19964
Ust-ID (VAT-No.): DE205824437
---------------------------------------------------------



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.logilab.org/pipermail/python-projects/attachments/20090409/036cf24a/attachment-0185.html>


More information about the Python-Projects mailing list