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

Is there a StrictVersion after we drop distutils? #520

Closed
cclauss opened this issue Mar 14, 2022 · 1 comment
Closed

Is there a StrictVersion after we drop distutils? #520

cclauss opened this issue Mar 14, 2022 · 1 comment

Comments

@cclauss
Copy link
Contributor

cclauss commented Mar 14, 2022

We currently use from distutils.version import StrictVersion but we want to drop distutils in preparation for Python 3.12. What is the recommended substitute for StrictVersion? https://github.com/python/cpython/blob/main/Lib/distutils/version.py#L93

https://github.com/pypa/packaging/blob/main/packaging/version.py

@brettcannon
Copy link
Member

Our normal Version class is strict when it comes to Python packaging version support, so that probably covers what you want. Otherwise you can also use packaging.utils.canonical_version() if you want even more strict string output.

znewman01 added a commit to znewman01/securesystemslib that referenced this issue Sep 30, 2022
distutils is deprecated as of Python 3.10. We were only using it for
`StrictVersion`, which parses a version string and lets you order the
result.

The [official recommendation] from the packaging team is to replace
`StrictVersion` with a dependency on the `packaging` package, but:

1. The Python version parser was a little different from GPG versioning
   anyway because it's made for Python versions (it had support for
   "prerelease tags").
2. I wanted to avoid adding dependencies if possible.

[official recommendation]: pypa/packaging#520

This PR adds a new `Version` class in `securesystemslib.gpg.util` and
uses that instead.

Signed-off-by: Zachary Newman <[email protected]>
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

No branches or pull requests

2 participants