crate / crate-python

Python DB API client library for CrateDB, using HTTP.
https://cratedb.com/docs/python/
Apache License 2.0
78 stars 31 forks source link

Maintenance (PEP 632): Remove dependency on `distutils` #513

Closed amotl closed 1 year ago

amotl commented 1 year ago

About

The distutils package will become deprecated, see PEP 632 – Deprecate distutils module.

DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives

Solution

The accepted solution is to vendor packaging.version, like how NumPy, pandas and SciPy are doing it equally.

References

mfussenegger commented 1 year ago

Wouldn't a tuple(map(int, version.split('.'))) be good enough for our purposes? CrateDB versions follow x.y.z and don't have any other components. A tuple with 3 integers has the correct comparison semantics

amotl commented 1 year ago

CrateDB versions follow x.y.z and don't have any other components.

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 distutils parser did not manage to do all the x.x.xa / x.x.xb / x.x.xrc pre-release variants correctly, while I needed it to work with corresponding pre-release packages of SQLAlchemy.

https://github.com/crate/crate-python/blob/744d4a51f38d4f3d15a69dd0a371ba95d268412a/src/crate/client/_pep440.py#L1-L4