-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Broken namespace packages corner-case? (py3.5) #900
Comments
Hi there. I have now managed to reproduce this without involving tox at all. I updated my repository reproducing the bug in IwanVosloo/setuptools-namespaces. |
Thanks for the repro repo and for eliminating tox. I've forked your repo as https://github.com/jaraco/setuptools-issue-900 and further distilled the issue in master. I'm setting In any case, I don't yet have a good understanding of the issue, but I'm getting closer and will give it another look another time. |
Thanks @jaraco We have wrestled with the issue a bit more and have learnt some more about it. Firstly, this is a strange (yet probably common) scenario: we are running code from the current directory of the source code of a package, but that package is installed (via pip) AS WELL. This seems to confuse setuptools somewhat, because it picks up ./nspace as well as the installed site-packages version of nspace. (./nspace only contains two, whereas the version in site-packages contains three as well.) Secondly, we realised that this is related to setuptools' handling of PEP420 implicit namespaces. According to PEP420, namespace packages should not have What causes the issue is: There are two versions of the nspace package: When importing nspace.three, somehow the ./nspace is found first, and inside it it finds an init.py. According to PEP420 then, if a package has an I am not sure how one would handle this scenario. Our code base runs on Python 2.7 as well and I'm not sure if one still needs On the other hand, the situation where you run, eg "python ./setup.py" in the source code tree of a package which also happens to be installed in site-packages is kindof weird. Yet, I think it often happens. For example, when people run tests against installed packages: python ./setup.py test. |
BTW, once one removes the |
Thank you for the analysis, we were running into the same problem. Workaround was to change current directory before executing the tests. This has one downside though: One can only test after installation, which is non ideal during development (on CI we test the installed package). Workaround for that: pip install -e the package during development and run the tests from another folder. |
@IwanVosloo @tlandschoff-scale May you please check if you have this problem with latest setuptools? Recently my pull request fixing similar issue was merged, I hope it should help with this issue too. |
I have hit a complicated corner case on py3.5 regarding namespace packages on code that used to work before. I suspect it is a bug in a recent setuptools, but I may be wrong... tox is also involved, but I doubt it is at fault.
I have reproduced the whole thing in IwanVosloo/setuptools-namespaces
The gist of it is: code in one module in a namespace package cannot import code from another module in a different setuptools distribution that shares the same namespace package.
I have the following directory structure:
nspace-two and nspace-three are different Distributions sharing a namespace package (nspace), and nspace-two depends on nspace-three.
The module nspace-two/nspace/two/stuff.py starts off with an "import pkg_resources" [1] before it imports something from nspace.three.
If you run tox, nspace-two/tox.ini runs, as a test:
python -c 'from nspace.three.morestuff import *'
(and this always works)and then:
python -c 'from nspace.two.stuff import *'
(which breaks on py3.5 but works on 2.7)If I comment out the import in [1] above - it also works.
If I instruct tox to changedir away from nspace-two directory before doing those imports - it also works.
python: 3.5.2
virtualenv: 15.1.0
pip: 9.0.1
setuptools: 32.3.0
The text was updated successfully, but these errors were encountered: