-
Notifications
You must be signed in to change notification settings - Fork 3k
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
req: improve extras/markers/link handling #5788
req: improve extras/markers/link handling #5788
Conversation
While working on this I noticed a few things that don't make sense (to me):
|
68f941f
to
5bcb430
Compare
Ref to this comment: https://github.com/pypa/pip/pull/5571/files#r223152710 I don't have time right now to generate a minimum example. Basically, ProjectB has a |
Yes, not being able to directly use a PEP 508 URL to a wheel is a known limitation... |
Wait, I meant as a direct argument on the command line, but there's another known issue with |
@wkschwartz : OK, so after patching pip to handle src/pip/_internal/download.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git i/src/pip/_internal/download.py w/src/pip/_internal/download.py
index 96f3b65c..8d8d1654 100644
--- i/src/pip/_internal/download.py
+++ w/src/pip/_internal/download.py
@@ -463,9 +463,12 @@ def url_to_path(url):
_, netloc, path, _, _ = urllib_parse.urlsplit(url)
- # if we have a UNC path, prepend UNC share notation
if netloc:
- netloc = '\\\\' + netloc
+ # if we have a UNC path, prepend UNC share notation
+ if sys.platform == 'win32':
+ netloc = '\\\\' + netloc
+ else:
+ netloc = ''
path = urllib_request.url2pathname(netloc + path)
return path I can reproduce the issue on master with this test: def test_pep508_url_already_installed(script):
pkgA_path = create_basic_wheel_for_package(
script,
name='pkgA', version='1.0',
depends=[], extras={},
)
pkgB_path = create_basic_wheel_for_package(
script,
name='pkgB', version='2.0',
depends=['pkgA @ %s' % ('file://localhost' + str(pkgA_path.abspath))],
extras={},
)
pkgC_path = create_basic_wheel_for_package(
script,
name='pkgC', version='3.0',
depends=['pkgB'],
extras={},
)
r = script.pip_install_local(
'-v', pkgB_path
)
assert "Successfully installed pkgA-1.0 pkgB-2.0" in r.stdout, str(r)
r = script.pip_install_local(
'-v', pkgC_path
)
assert "Successfully installed pkgC-3.0" in r.stdout, str(r) Will raise |
@marcromani and I were hit by this yesterday. Is it an issue that has already been reported? Also, I see some comments here and there about how problematic it is to properly support PEP 508 URL requirements opposed to dependency_links, but I assume the roadmap is to go on with them, is that correct? |
src/pip/_internal/req/req_install.py
Outdated
self.extras = { | ||
pkg_resources.safe_extra(extra) for extra in extras | ||
} | ||
self.extras = set(extras) |
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.
This doesn't seem right, or at least, it is redundant?
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.
Good catch.
s = str(self.req) | ||
s = self.req.name | ||
if self.extras: | ||
s += '[' + ','.join(sorted(self.extras)) + ']' |
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.
This would be better as s += '[%s]' % ','.join(sorted(self.extras))
, and it improves performance.
5bcb430
to
6fe66ea
Compare
Rebased on #5893. |
6fe66ea
to
6980ce3
Compare
* allow calling it with `comes_from=None` (easier for testing) * handle the case where `comes_from.link is None` (which can happen if a package using a PEP 508 URL requirement is already installed)
- ensure this information is not duplicated at both the `InstallRequirement` and `InstallRequirement.req` levels - make the output more consistent, and not dependent on whether an `InstallRequirement` was created with `install_req_from_line` or `install_req_from_req`
6980ce3
to
590bc3a
Compare
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
Does the closing of this PR mean that #5788 (comment) won't get fixed, or is there another PR taking care of this? |
It means someone else will have to do the work of pushing this and other related changes. |
Thanks @benoit-pierre for the effort and dedication, these are no easy tasks and at least the next person that takes care of them will have your work as a starting point. |
@wkschwartz See #5889 and associated PR's. |
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. |
InstallRequirement
andInstallRequirement.req
levelsInstallRequirement
was created withinstall_req_from_line
orinstall_req_from_req
Before:
package@url
->Collecting package@ url from url (from ...)
/Collecting ... (from package@ url->...)
package[extra]>=1.0; marker
->Collecting package[extra]
/Collecting .. (from package[extra])
(when used from the command line), butCollecting package[extra]; marker
/Collecting .. (from package[extra]; marker->...)
when coming from a package requirementspackage-0.8-py2.py3-none-any.whl[test]; marker
->Processing package-0.8-py2.py3-none-any.whl
/Collecting ... (from package==0.8)
Basically the format will now consistently looks like:
Collecting package==2.0 from URL (from ...)
/Collecting ... (from package[extra]==2.0)
.