gfxmonk
gfxmonk

Reputation: 8736

Build a namespace package for use via $PYTHONPATH

It's a slightly awkwardly worded question, but basically:

I've got a wrapper script to build a python package, it mostly just does setup.py --single-version-externally-managed. I can add whatever I want to this build process - but it must be general, as it's used to build a large number of packages.

Normally, I can just add the build result onto $PYTHONPATH, and all is well.

But with namespaced packages (e.g ndg-httpsclient), it looks a lot like they'll only work when in a designated site-packages directory, because they use .pth files.

Confusingly there is a ndg/__init__.py in the source, which contains the namespace package boilerplate code:

__import__('pkg_resources').declare_namespace(__name__)

So that looks like it ought to be importable directly on $PYTHONPATH, but then the installation taunts me with:

Skipping installation of /<some-build-dir>/site-packages/ndg/__init__.py (namespace package)

Presumably it has a good reason for doing that, but its reliance on .pth files means the result can't be used via $PYTHONPATH, only by copying it to a well-known location, which I am unable to do for technical reasons. I am also unable to inject arbitrary python into the app initialization (so site.addsitedir() is out too).

So, is there some way I don't know about to have a namespace module importable without putting it in a well-known location? Alternatively, is there a way to convince setuptools to not skip the __init__.py -- and would that actually work?

Upvotes: 1

Views: 297

Answers (0)

Related Questions