-
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
Use packaging.version to check version equality #9085
Use packaging.version to check version equality #9085
Conversation
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 looks good, just that it needs tests while we still have this fresh in our minds. :)
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.
Agreed this should have a test, but otherwise looks fine. I don't have time to write a test just now, but is it as simple as trying to install a package with version 1.0+local-1
?
So... Looks like I'll be writing the test. :) |
... or I could get to it this evening... 🙂 |
ACK. I'm happy to defer to you. :) |
I tried this test: def test_new_resolver_can_install_silly_version(script):
create_basic_wheel_for_package(
script,
"simple",
"0.1.0+local-1",
)
script.pip(
"install",
"--no-cache-dir", "--no-index",
"--find-links", script.scratch_path,
"simple"
)
assert_installed(script, simple="0.1.0+local-1") but it failed with "ERROR: Requested simple from file:///C:/Users/.../test_new_resolver_can_install_0/workspace/scratch/simple-0.1.0%2Blocal-1-py2.py3-none-any.whl has different version in metadata: '0.1.0+local.1'" which seems to be getting raised from |
(To be clear, I don't intend to look at the |
Gotta love when assertions break because people are doing weird things. :) |
Have I mentioned I hate normalisation? 😉 |
Yes, but vague spots in version normalisation means we probably want to test
|
LOL it turns out import importlib.metadata
import subprocess
import sys
import pkg_resources
from tests.lib.wheel import make_wheel
# Metadata uses dash, filename uses dot.
whl = 'simple-0.1.0+local.1-py3-none-any.whl'
make_wheel('simple', '0.1.0+local-1').save_to(whl)
# Install it.
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', f'./{whl}'])
# Prints '0.1.0+local-1' correctly.
print(importlib.metadata.version('simple'))
# Prints '0.1.0+local'... Huh?
print(pkg_resources.working_set.by_key['simple'].version) When can we switch to |
00f9234
to
d08b4d9
Compare
Test added. I adapted Paul’s implementation to use |
ASAP. Let's get 20.3 out the door and yank out entire bits of pip's codebase. :) |
Fix #9083. I’m 99.999% sure the fix is correct, but didn’t include a test since it’s late here and I have to get up early tomorrow. I’ll leave this to someone with more time 🙂