-
Notifications
You must be signed in to change notification settings - Fork 8
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
Added support for wheel files with local version (pep-0440) #38
Conversation
@@ -104,6 +104,14 @@ def test_package_info_all_info(): | |||
} | |||
|
|||
|
|||
def test_package_info_wheel_with_local_version(): |
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.
Instead of a new test, I think you can just add a case to test_guess_name_version_from_filename
above
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.
@asottile - I considered that, but that test function doesn't cover the change - guess_name_version_from_filename() is called from inside create(), but only after the regex gets checked.
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.
ahh ok, let's go for a more directed test then, how about something like this?
pkg = main.Package.create(filename='f-1.0+local-py3-none-any.whl')
assert pkg.version == '1.0+local'
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.
@asottile - done
dumb_pypi/main.py
Outdated
@@ -150,7 +150,7 @@ def create( | |||
upload_timestamp: Optional[int] = None, | |||
uploaded_by: Optional[str] = None, | |||
) -> 'Package': | |||
if not re.match('[a-zA-Z0-9_\-\.]+$', filename) or '..' in filename: | |||
if not re.match('[a-zA-Z0-9_\-\.\+]+$', filename) or '..' in filename: |
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.
while you're at it (not your fault, existing code -- sorry!) can you add a r
prefix to this regex -- (it'll become a syntax error in python3.8 -- heh)
forgot to say, thanks for this PR -- definitely was an oversight on our part and we're happy to get this feature working 🎉 |
@asottile - no trouble, thanks to you guys for creating & maintaining this package, saved us a bunch of time. |
This has been released as part of v1.3.1 -- thanks again for your contribution 🎉 ! |
Fixed an issue where wheel files with local version identifiers (eg. f-1.0+local-py3-none-any.whl) were being rejected as having unsafe package names, since '+' was being rejected based on the filename regex in Package.create. '+' is a permitted character in wheel filenames as per PEP-0440 (https://www.python.org/dev/peps/pep-0440/#local-version-identifiers).