-
Notifications
You must be signed in to change notification settings - Fork 31
Maintenance (PEP 632): Remove dependency on distutils
#513
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
Conversation
0ba89a7
to
58378fc
Compare
58378fc
to
82138a0
Compare
6e06373
to
2c1d460
Compare
distutils
distutils
src/crate/client/pep440.py
Outdated
# Vendored from `packaging` on 2021-30-04, via pandas. | ||
# - https://github.com/pypa/packaging/blob/ae891fd74/packaging/_structures.py | ||
# - https://github.com/pypa/packaging/blob/ae891fd74/packaging/version.py | ||
# - https://github.com/pandas-dev/pandas/blob/cf2b88b5ea/pandas/util/version/__init__.py | ||
|
||
# This file is dual licensed under the terms of the Apache License, Version | ||
# 2.0, and the BSD License. See the LICENSE file in the root of this repository | ||
# for complete details. |
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.
If we use this license related header, we'd have to include the original license note to our LICENSE file afaik similar how pandas did it pandas-dev/pandas@f40e58c#diff-17d4b6290d4495e094bd6dc27902057dcb25ca7f73d595162899c22d1b95f43eR180.
Or we keep the license header of donald like numpy did https://github.com/numpy/numpy/pull/21000/files#diff-41a2b10dd4230acb81d1f9f7dedd8e8e6f6ef4f44d15f20105e9e82cf5a489ebR7.
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.
Response
Thank you for your attention.
Thoughts
I think it would be even better if someone would release and maintain a dedicated versions
, or pep440
package, that this code would not have to be vendored over and over again.
Discovery
Better late than never: It turns out, that happened already!
- https://pypi.org/project/versions/
https://github.com/nekitdev/versions - https://pypi.org/project/pep440/
https://github.com/Carreau/pep440
Thoughts
Maybe better spend another iteration to re-use one of those packages instead?
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.
Maybe better spend another iteration to re-use one of those packages instead?
Hm. While versions
feels a bit too heavy, I think pep440
is a bit too thin.
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.
Yes sounds good, lets use one of them.
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.
Maybe better spend another iteration to re-use one of those packages instead?
Hm. While
versions
feels a bit too heavy, I thinkpep440
is a bit too thin.
Another one: https://pypi.org/project/pep440-version-utils/
But also not sure if this is really worth of a dependency. Maybe we should just fix the license header instead?
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.
Another one: https://pypi.org/project/pep440-version-utils/.
Thanks, but this one actually pulls in packaging
, see pyproject.toml#L16.
But also not sure if this is really worth of a dependency.
Yeah, I think that was the same reasoning of the other maintainers.
Maybe we should just fix the license header instead?
Sure, let's do it like that for now.
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've reworked the patch to use the _pep440.py
file from current NumPy 1, as you suggested.
Footnotes
0df0951
to
82ce1e4
Compare
This effectively removes the direct dependency to `distutils`, which will become deprecated with Python 3.12. The patch uses the implementation from NumPy 1:1, originally authored by Donald Stufft and individual contributors.
82ce1e4
to
454e85b
Compare
…to it A little patch to re-add the `version()` method was needed for version comparison backwards-compatibility with code using it. Also, don't do code coverage reporting on the vendored code.
454e85b
to
744d4a5
Compare
return method(self._key, other._key) | ||
|
||
|
||
class LegacyVersion(_BaseVersion): |
Check warning
Code scanning / CodeQL
`__eq__` not overridden when adding attributes
""" | ||
|
||
|
||
class Version(_BaseVersion): |
Check warning
Code scanning / CodeQL
`__eq__` not overridden when adding attributes
Wouldn't a |
I think the version comparison is also used for comparing versions of Python packages, specifically SQLAlchemy. I recently already struggled very hard, because the older crate-python/src/crate/client/_pep440.py Lines 1 to 4 in 744d4a5
|
About
The
distutils
package will become deprecated, see PEP 632 – Deprecate distutils module.Solution
The accepted solution is to vendor
packaging.version
, like how NumPy, pandas and SciPy are doing it equally.References