-
-
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
Add namespace support for develop #789
Conversation
|
||
if self.dry_run: | ||
# always generate the lines, even in dry run | ||
list(lines) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since lines is already a list comprehension, what does this achieve?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing. This was just left over from where I copied this code from install_egg_info
. In that function it uses map
to generate the lines instead of a list comprehension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Fixed)
How does this feature play with |
It'll work as it does today, it'll just remove the |
Yes please. Feel free to create a new private module for this purpose.
That does seem less complex and thus preferable. My main reservation with this implementation is it adds additional dependence on -nspkg.pth files, where these files are presumably unnecessary on Python 3.3+ (pypa/pip#1924) and possibly could be obviated on older Pythons (#406). I'd be tempted to restrict this functionality to environments where PEP-420 namespace support isn't available (i.e. python 2.6-3.2 where importlib2.hook.installed is not True). I know that complicates the implementation (and deployment) but it has the added benefit of not masking the problem where a better solution (presumably) exists. What do you think? |
Will do.
What better solution for editable install exists in those versions? As far as I can tell, you can omit |
Well, in Python, when you start an interpreter, it adds '.' to sys.path (either via
Neither project_a nor project_b need to be installed (and if they are, the editable versions in /dev will be imported first). That's of course the simplest use case, but I imagine you have a more complicated use case in mind. Can you expand on how the above wouldn't work? |
Hmm, the Thoughts? |
With PEP 420, any directory in PYTHONPATH can have a namespace package:
As for 'src', why not simply Actually, now that I think about it, I'm not opposed to the use of
For Python < 3.3, it might still be necessary to fold in the extra behavior. |
Cool, so I think we might have a way forward here. Please let me know if any of this is incorrect: develop will always create a For Python 2 and < 3.3 (or more correctly when
For > 3.3 (or more correctly when |
What @jonparrott suggests above is roughly what I had in mind when I suggested using |
@jonparrott: Interestingly, I have an example where I expected to run into this issue but I'm not. In this build on Travis, under What's interesting is that the tests pass - the package under develop seems to be able to import the installed packages from the same namespace... and the tests pass on many Python versions including 2.7. Right now, I can't explain why it is that I'm not hitting this issue, but perhaps this finding reveals a technique that's already viable. Perhaps I'll find to look into this more later, but I'd welcome your review of this as well to see if you can determine what I'm not seeing. |
@jaraco that is... interesting. Hmm. |
And although I use the same technique in another project, I find its tests are failing apparently due to namespace package issues, and here only under Python 3. I wonder if there's some sensitivity to the order in which the package under |
A point potentially worth noting: The other common source of conflicts is that the current directory is added to the front of |
I think there's a more insidious problem here - with pip-installed packages (or any other installer that omits For example, consider something like Perhaps the project could be reconfigured not to include that file at all, but that would eliminate the ability to use |
I should also mention that this PR is designed to address pypa/pip#3 and #250. |
Man, this is complex. :| I haven't had time to really dig into this as I've been busy re-writing an auth library, but I do want to come back to this eventually. However, If someone wants to take the reigns in the meantime, please feel free to work from what I've done and cc me on the new PR. |
@jaraco While I agree that situation isn't ideal, I believe it should still work as long as the Folks using something like tox to do full install-and-test in a venv would be able to test the post-install configuration that way, even if |
I noticed there was a lot of code in common with |
In my testing, I was unable to get the system to work because the I'm going to continue this discussion in #250. |
@jaraco sg, thanks for staying on top of this. |
See pypa/packaging-problems#12 for detailed context, but essentially:
This adds support for namespace packages by adding functionality to the develop command to create
{distribution}-develop-nspkg.pth
files insite-packages
instead of.egg-link
s.This work is mostly based on
install_egg_info
and this gist.There are some outstanding questions I have about this, and of course I need to write tests before merging. I just want to sanity check before I go further.
Questions:
install_egg_info
anddevelop
share a lot of common code around generating thenspkg.pth
files. Should I refactor that into a common module? If so, what should the module be? (There doesn't seem to be any 'private' modules in setuptools).pth
files that work the same as the.egg-info
files today for non-namespace packages. Is that desired?/cc @ncoghlan