Skip to content
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

MNT: compatibility with newer packaging #30

Closed
wants to merge 1 commit into from

Conversation

ZLLentz
Copy link

@ZLLentz ZLLentz commented Apr 18, 2023

I dug into this a bit because newer versions of black and conda require packaging>=22.0.

Following recommendations here: pypa/packaging#631 (comment)
The simplest way to support all versions of packaging is to use the Version class directly instead of the parse function.

parse used to return Version or LegacyVersion depending on if it received a valid version string, but now it raises InvalidVersion instead if the version string is invalid. If we add a try/except around parse then you'll be compatible with packaging>=22 but lose compatibility with packaging<22. Instead, switching to the Version class directly has the same exception raising behavior in all versions of packaging, including the latest.

This seemed like an appropriate fix here because this library only uses LegacyVersion as an indicator that something is a branch rather than a version, so its absence doesn't seem like much of a problem.

closes #27

@goerz
Copy link
Owner

goerz commented Apr 18, 2023

Looks like it should work in principle, and I'd be happy to merge if you can make the tests pass.

You'll also have to pin black < 23.

@goerz goerz force-pushed the mnt_packaging_compat branch from cd744dc to 71a3c23 Compare April 18, 2023 21:32
@goerz
Copy link
Owner

goerz commented Apr 18, 2023

It's not going to be that easy… There are several other places where parse_version is called, and I really depend on the old behavior. The easiest fix is probably to backport the entire old parse_version function and the LegacyVersion type (or something that behaves equivalently) into the package.

@ZLLentz
Copy link
Author

ZLLentz commented Apr 18, 2023

I didn't realize you were using parse_version elsewhere, that's my bad.

Maybe the easiest thing to do is to use https://pypi.org/project/packvers/ which I think is just a forked/vendored version of packaging at 21.3, or backport/vendor it yourself if you prefer.

@goerz
Copy link
Owner

goerz commented Apr 18, 2023

I'm going to look into this in #32

@goerz
Copy link
Owner

goerz commented Apr 18, 2023

Thanks for pointing out packvers! That certainly makes things easy!

@goerz
Copy link
Owner

goerz commented Apr 18, 2023

I'm going to close this in favor of #32, but I very much appreciate the contribution!

@goerz goerz closed this Apr 18, 2023
@ZLLentz
Copy link
Author

ZLLentz commented Apr 18, 2023

Thank you for moving ahead with this!

@ZLLentz ZLLentz deleted the mnt_packaging_compat branch April 18, 2023 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LegacyVersion has been removed from packaging.version
2 participants