SethMMorton / natsort

Simple yet flexible natural sorting in Python.
https://pypi.org/project/natsort/
MIT License
907 stars 52 forks source link

DeprecationWarning on Python 3.10 #130

Closed domdfcoding closed 3 years ago

domdfcoding commented 3 years ago

Describe the bug In Python 3.10 (due to release in October 2021) the distutils module is deprecated and is scheduled for removal in Python 3.12

natsort uses distutils.version.StrictVersion to determine whether the version of fastnumbers is appropriate:

https://github.com/SethMMorton/natsort/blob/4e47f82856822ac776b4874747852b99edb79d9e/natsort/compat/fastnumbers.py#L7

https://github.com/SethMMorton/natsort/blob/4e47f82856822ac776b4874747852b99edb79d9e/natsort/compat/fastnumbers.py#L16

See PEP 632 for more information on the deprecation.

Expected behavior Importing natsort does not trigger a DeprecationWarning.

Environment (please complete the following information):

To Reproduce python3.10 -Werror -c "import natsort"

Traceback ```python traceback Traceback (most recent call last): File "", line 1, in File "venv/lib/python3.10/site-packages/natsort/__init__.py", line 3, in from natsort.natsort import ( File "venv/lib/python3.10/site-packages/natsort/natsort.py", line 14, in from natsort import utils File "venv/lib/python3.10/site-packages/natsort/utils.py", line 49, in from natsort.compat.fastnumbers import fast_float, fast_int File "venv/lib/python3.10/site-packages/natsort/compat/fastnumbers.py", line 7, in from distutils.version import StrictVersion File "/usr/lib/python3.10/distutils/__init__.py", line 16, in warnings.warn("The distutils package is deprecated and slated for " DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives ```