Skip to content
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

namespace packages cannot be found by various tools. #83

Open
ghost opened this issue Sep 17, 2013 · 8 comments
Open

namespace packages cannot be found by various tools. #83

ghost opened this issue Sep 17, 2013 · 8 comments

Comments

@ghost
Copy link

ghost commented Sep 17, 2013

Originally reported by: youngrok (Bitbucket: youngrok, GitHub: youngrok)


All of these, pkgutil.iter_modules, help(modules), pydoc modules, don't show namespace packages. IPython and eclipse pydev code completion doesn't work for namespace packages, either.

Of course importing namespace packages has no problem. It works. But supporting tools are also important. Current namespace package spec seems not so good.

It's because of absence of __init__.py. I know there are various reasons to skip __init__.py while installing namespace packages, but if it's not skipped, all problems will be fixed.

If we should respect PEP 420, *-nspkg.pth file should be fixed. Not just creating new module for namespace package, but registering all submodules of namespace packages is needed.

I'm sorry if I've posted this issue on wrong place. I'm confusing I have to post this here or on PEP mailing list.


@ghost
Copy link
Author

ghost commented Sep 19, 2013

Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco):


I recently encountered this situation as well, where pkg_resources.resource_filename will fail if the 'module` attribute is a namespace package. This situation only occurs if the package was installed using pip (which suppresses init.py for namespace packages). Note that using easy_install isn't subject to this issue (though I'm unsure if it does or even can disambiguate the different manifestations of a namespace package).

Can you confirm you were using pip when you encountered these issues? Can you try installing the packages with easy_install instead and see if it meets your expectations?

@ghost
Copy link
Author

ghost commented Sep 19, 2013

Original comment by youngrok (Bitbucket: youngrok, GitHub: youngrok):


Both pip and easy_install have problems, but the problems are different. As you say, when using pip, all of the ways mentioned above do not work. easy_install works better, but has another problem.

For example, I installed djangox-mako and djangox-route with easy_install. Then pkgutil, help and pydoc show the namespace package, but IPython and pydev do not work properly. IPython is supposed to show completion list like djangox, djangox.route, djangox.mako, but it only shows djangox and djangox.route. Even when I installed djangox-test additionally, it only shows one sub package of the djangox. Pydev do the same.

@ghost
Copy link
Author

ghost commented Sep 20, 2013

Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco):


@youngrok that's exactly what I would expect based on what I read from the code. The underlying challenge is that with a namespace package, there's no direct deterministic resolution for the namespace package. In the case of Djangox, that package may actually exist in multiple locations, so when you request a resource from that package, setuptools returns the first one.

When installed with PIP, everything happens to be installed into a single directory, but based on PEP 420 and other name spacing techniques, it's still not possible for setuptools to determine a location reliably.

I'd like to continue to explore this problem, but there's no obvious solution, so I will have to defer for now.

@ghost
Copy link
Author

ghost commented Jun 9, 2014

Original comment by jnrbsn (Bitbucket: jnrbsn, GitHub: jnrbsn):


I'm also experiencing this problem. When using IntelliJ IDEA, it underlines the import statement in red and can't find the declaration. I created an empty __init__.py file in the directory where the namespace package was installed and it worked. The package was installed via pip.

@silkentrance
Copy link
Contributor

@pganssle This might have been fixed by the fix for #97 in #1312.

@silkentrance
Copy link
Contributor

As for various tools not being able to resolve namespace packages, well, this is up to the tools, isn't it?

@pganssle
Copy link
Member

@silkentrance I don't think #1312 actually fixes any existing bugs, all it does is provide a new API for people to create namespace packages.

pkg_resources is also provided by this repo, so if pkg_resources.resource_filename still doesn't understand PEP420 namespace packages, that's an ongoing problem.

@silkentrance
Copy link
Contributor

@pganssle Ok, now I understand the issue, thanks for clearing this up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants