Skip to content

Commit 261fc02

Browse files
committed
build: use packaging.version.Version
This avoids a deprecation warning on the distutils class.
1 parent 32a31f8 commit 261fc02

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

setup.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,9 @@
1212
import sys
1313
import sysconfig
1414

15+
from packaging.version import Version
1516
from setuptools import setup
1617

17-
# Python 3.12 dropped distutils from the stdlib. Try to access it via
18-
# setuptools.
19-
try:
20-
from setuptools._distutils.version import LooseVersion
21-
except ImportError:
22-
from distutils.version import LooseVersion
23-
2418
if sys.version_info[0:2] < (3, 9):
2519
print("Python 3.9+ is required", file=sys.stderr)
2620
sys.exit(1)
@@ -61,8 +55,8 @@
6155

6256
# PyPy (and possibly other distros) have CFFI distributed as part of
6357
# them.
64-
cffi_version = LooseVersion(cffi.__version__)
65-
if cffi_version < LooseVersion(MINIMUM_CFFI_VERSION):
58+
cffi_version = Version(Version(cffi.__version__).base_version)
59+
if cffi_version < Version(MINIMUM_CFFI_VERSION):
6660
print(
6761
"CFFI %s or newer required (%s found); "
6862
"not building CFFI backend" % (MINIMUM_CFFI_VERSION, cffi_version),

0 commit comments

Comments
 (0)