-
-
Notifications
You must be signed in to change notification settings - Fork 177
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
Bad namespacing, imports breaks setuptools #345
Comments
for un-related reason, I renamed fs.gitpython to gitfs2. |
@zopyx do you think it's feasible to rename |
Here's my problem if fs.gitpython is used. nose complains about the following:
So, I chose to avoid the problem. |
I don't own the repo, so that's not an option for me. There's also the problem of it already being on PyPI. |
I know nothing about namespace packages, but has this always been a problem? I'm wondering why it wasn't noticed before? |
Could you please how this is solved/handled in fs.webdavfs? |
I recommend against publishing filesystems in the So the official recommendations don't use namespace packages. The only bit of magic required is the That said, there are several I'll do a deep dive in to namespace packages at some point, so I can properly evaluate @dargueta 's PR. In the meantime, our resident namespaces expert is @althonos If he's not too busy, he might be able to shed some light on this. |
Not my repo: 😬 Also,
|
The packages published under the
There are some techniques like manual module path extension to avoid installing a package in editable mode while having your tests use the development version of the package. |
The |
The same is true for |
If you try opening it using the |
@dargueta your assumption is wrong. There is no namespace definition in |
Okay well something's broken (see PyFilesystem/fs.dropboxfs#6). I now have no idea what. I'll close this for now. Thanks for your help! |
I see this here but this is obviously related to the entrypoint registration which is unrelated to namespace packages:
|
@dargueta Your webdev example works for me. Fresh venv. Do you have the lastest (v2.4.10) PyFilesystem? |
Yes. |
Tried a clean install and this happened...
I am so confused now. |
Ditto! I don't use Pyenv. I wonder if that's what's different about your environment? |
The entrypoint registration for
However the opener registered for
So the source distribution is just buggy. Perhaps it needs a MANIFEST or find_package() directive or something like that. Your own issue is likely something with pyenv. I would recommend using your standard Python 3 without pyenv and using a virtualenv created using |
Oh woooooow I just figured it out -- the Facepalmed so hard I might have a concussion... |
Really sorry about wasting everyone's time. |
Not at all! We all learned something. |
fs.dropboxfs is implemented using
fs
as a namespace package. This causes it to misbehave when importing fromfs
for several reasons:fs
declares itself as a namespace package. According to the setuptools documentation here,A) only namespace packages are supposed to contain the
__import__('pkg_resources')...
B) they must not contain executable code aside from that import.
We violate both of those rules, thus resulting in weird exceptions like this:
Changing that line to these two fixes the problem:
There's a similar issue in
fs.test
:It appears these are the only two places in the repo we do this. Fixing these imports gets us a separate weird error in code using
fs.dropboxfs
but that may be unrelated.The text was updated successfully, but these errors were encountered: