-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--target doesn't work for namespace packages #1924
Comments
The Python docs say only the site-packages folders relative to |
@mmerickel I am having difficulty locating the relevant section of the docs. Link, please? |
Darn, not a lot of ambiguity there. Any ideas on how I can work around this limitation? App Engine inserts the lib subdirectory into sys.path (eg. https://github.com/GoogleCloudPlatform/appengine-python-flask-skeleton/blob/master/appengine_config.py#L6), but that obviously doesn't enable the .pth file. |
You could manually move the namespace'd package that you want to the actual folder where it would be located if it was simply part of the overall package, in a build / deploy step. Alternately, call addsitedir explicitly in your own |
@Ivoz |
Unfortunately, I have a workaround which I am trying to simplify:
But that seems rather ugly to me. What would help a lot would be if a But in the absence of such a method, can the above code be improved or is there another, simpler workaround? |
Sadly, this not only affects
pip really should do something about it. |
This issue is implicated in jaraco/pip-run#5. |
Here's another thought - since Python 3.3+ supports namespace packages natively, why not on those Pythons drop the use of .pth files altogether and let Python handle the importing? |
I was going to explore the possibility of implementing my suggestion, but searching the pip codebase, I see no reference to In seaching the web, I stumble across this distutils sig thread. |
Other interesting details in this thread. |
I've found that the |
In that latest thread, PJE says:
So checking if it's the case:
So it seems that at least nominally pkg_resources is able to provide resources for the trivial package. Although,
I suspect that if the package had some metadata (dist-info or egg_info), it would also work. So I want to say PJE's supposition is tenatively confirmed and focus on
|
Hello I had this issue when using Google Cloud APIs with the command
My workaround is to add the following lines in my setup file...
etc... Do you have anything better? I work with Python 2.7 |
What with all the issues that reference this one (all closed), I'm a bit confused as to whether this issue remains relevant. @jaraco, can you comment? |
I don't believe there's much else to do here in pip. It's a limitation in python that the namespace package support required the -nspkg.pth hook to function. As long as the hook is needed, namespace packages won't load unless installed to a site dir. With PEP 420, these packages do run and with the latest updates to the hook, can coexist with hook-facilitated packages. The pip-run (formerly rwt) package makes use of --target and works with namespace packages by installing a sitecustomize module. Perhaps that technique could be employed in other environments that rely on --target to get better namespace support in older Pythons. |
That's how I solved the problem at my last employer. Would be awesome if it worked out of the box... |
I'm going to close this as there isn't much pip can do here, this is just how Python's |
So if I get this correct pip will not try to have a working namespace package when installed with --target? Could in this case some info (warning?) with some useful information be printed out to the user? e.g. pip doesn't support this, you might want to run |
@JensTimmerman That's an interesting idea. I agree, it's a bit hostile to install packages into a I'm not sure a warning is quite appropriate - as it may be the case that a tool invoking pip will be correcting for the condition as rwt does. More importantly, though, this issue largely goes away with Python 3.3, so perhaps the best solution is just to work around it until you can port everything to Python 3. |
For reference the missing |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
When doing a local install of a namespace package, the .pth file doesn't get picked up for some reason:
However, all necessary files are in fact installed in lib/:
And of course the whole procedure works just fine for non-namespace packages.
Thanks to @mmerickel for setting me straight on the source of the issue.
The text was updated successfully, but these errors were encountered: