Python: two packages with the same name; how do you indicate which one is loaded?

I have two packages that install different packages with the same name. They are both “packages” in that they have top-level files setup.pythat are indicated package=['foo']on the command setup.

If I install with distutils.core, the last one to be installed will overwrite the previous one (but I think I would not overwrite if all the .py files had the same name?). If I install using setuptools, these two packages are installed in different eggs.

One option would be to explicitly set sys.paththe package name before importing; it seems "non-pythic" and pretty dirty.

Assuming I have these two identically named packages installed in different eggsof setuptools, how can I specify an importable one?

+5
source share
2 answers

The Setuptools manual mentions --multi-version (-m), which completely removes the package from sys.path. You should use pkg_resources.require ('package == version') in your code as early as possible to fix sys.path. This tip is that easy_install always prints when you use -m.

But you cannot import immediately (unless they are intended for this using namespace packages ).

+1
source

, - , .

, setup.py - . - .

sys.path, , .pth. , , "head" python.

, , ?

0

All Articles