[Distutils] How to detect a namespace packages?

Hartmut Goebel h.goebel at crazy-compilers.com
Mon Aug 26 12:36:49 CEST 2013


Hi,

I'm one of the developers of www.pyinstaller.org, a tool for creating
stand-alone executables.

We need to reliable detect if a package is a namespace package (nspkg).
For each namespace, we need to add an empty fake-module into our
executable to keep the import mechanism working. This has to work in all
versions of Python starting with 2.4.

nspkgs set up via a nspkg.pth-file are detected by being in sys.modules,
but imp.find_module() files.

For nspkgs using __init__.py-files (which use
pkg_resources.declare_namespace() or pkgutil.extend_path()) I have no
clue how to detect them.

I tried to query meta-information using pkgresources, but I did not find
a solution.

Any help?

-- 
Regards
Hartmut Goebel

| Hartmut Goebel          | h.goebel at crazy-compilers.com               |
| www.crazy-compilers.com | compilers which you thought are impossible |



More information about the Distutils-SIG mailing list