-
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
Get rid full file path #7898
Get rid full file path #7898
Changes from all commits
bc7124e
3450e5b
0c7c877
764fca3
a611a84
f79c530
e33c22a
b5e1a88
3449d5f
7eb1af5
a8006e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Display only the wheel filename instead of the entire filepath, when using a cached wheel. |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -264,9 +264,21 @@ def populate_link(self, finder, upgrade, require_hashes): | |||||||||||||||||
package_name=self.name, | ||||||||||||||||||
supported_tags=supported_tags, | ||||||||||||||||||
) | ||||||||||||||||||
|
||||||||||||||||||
if old_link != self.link: | ||||||||||||||||||
logger.debug('Using cached wheel link: %s', self.link) | ||||||||||||||||||
|
||||||||||||||||||
@property | ||||||||||||||||||
def from_wheel_cache(self): | ||||||||||||||||||
# type: () -> bool | ||||||||||||||||||
""" | ||||||||||||||||||
This function returns whether the file path is in the wheel cache. | ||||||||||||||||||
""" | ||||||||||||||||||
if self._wheel_cache is not None and self.link is not None: | ||||||||||||||||||
return bool(self._wheel_cache.cache_dir in self.link.file_path) | ||||||||||||||||||
else: | ||||||||||||||||||
return False | ||||||||||||||||||
Comment on lines
+277
to
+280
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO this is safer (duck-typing) and clearer:
Suggested change
Also please mind the docstring. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The AttributeError suggestion is unclear to me. There are too many attribute access and it’s confusing which one causes the exception. The original implementation is more explicit for me (but the |
||||||||||||||||||
|
||||||||||||||||||
# Things that are valid for all kinds of requirements? | ||||||||||||||||||
@property | ||||||||||||||||||
def name(self): | ||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,17 @@ | |
import pytest | ||
from pip._vendor.packaging.requirements import Requirement | ||
|
||
from pip._internal.cache import WheelCache | ||
from pip._internal.exceptions import InstallationError | ||
from pip._internal.models.format_control import FormatControl | ||
from pip._internal.models.link import Link | ||
from pip._internal.req.constructors import ( | ||
install_req_from_line, | ||
install_req_from_req_string, | ||
) | ||
from pip._internal.req.req_install import InstallRequirement | ||
from tests.lib import path_to_url | ||
from tests.lib.wheel import make_wheel | ||
|
||
|
||
class TestInstallRequirementBuildDirectory(object): | ||
|
@@ -108,3 +113,52 @@ def test_install_req_from_string_with_comes_from_without_link(self): | |
assert install_req.link.url == wheel_url | ||
assert install_req.req.url == wheel_url | ||
assert install_req.is_wheel | ||
|
||
|
||
class TestInstallRequirementWheelCache(object): | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
def test_able_to_register_when_get_from_wheel_cache(self, tmpdir): | ||
""" | ||
This test to make sure that file is able to tell when a link is | ||
from the wheel cache. | ||
""" | ||
|
||
Comment on lines
+121
to
+125
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's |
||
format_control = FormatControl() | ||
wheel_path = path_to_url(make_wheel( | ||
name='pip', | ||
version='6.9.0' | ||
).save_to_dir(tmpdir)) | ||
|
||
wheel_cache = WheelCache(tmpdir, format_control) | ||
|
||
install_req = install_req_from_req_string( | ||
req_string='pip', | ||
wheel_cache=wheel_cache | ||
) | ||
install_req.link = Link(wheel_path) | ||
|
||
assert install_req.from_wheel_cache | ||
|
||
def test_able_to_register_when_not_get_from_wheel_cache(self, tmpdir): | ||
""" | ||
This test to make sure that file is able to tell when a link is not | ||
from the wheel cache. | ||
""" | ||
|
||
Comment on lines
+143
to
+147
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So is this. |
||
wheel_path = path_to_url(make_wheel( | ||
name='pip', | ||
version='6.9.0' | ||
).save_to_dir(tmpdir)) | ||
|
||
format_control = FormatControl() | ||
|
||
wheel_cache = WheelCache(tmpdir + '/wheel_cache', format_control) | ||
|
||
install_req = install_req_from_req_string( | ||
req_string='pip', | ||
wheel_cache=wheel_cache | ||
) | ||
|
||
install_req.link = Link(wheel_path) | ||
|
||
assert not install_req.from_wheel_cache |
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.
I don't think this newline is needed.