]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
favor setuptools imports over distutils
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 15 Nov 2021 20:06:06 +0000 (15:06 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 17 Nov 2021 22:52:47 +0000 (17:52 -0500)
Python 3.10 has deprecated "distutils" in favor of explicit use of
"setuptools" in :pep:`632`; SQLAlchemy's setup.py has replaced imports
accordingly. However, since setuptools itself only recently added the
replacement symbols mentioned in pep-632 as of November of 2022 in version
59.0.1, ``setup.py`` still has fallback imports to distutils, as SQLAlchemy
1.4 does not have a hard setuptools versioning requirement at this time.
SQLAlchemy 2.0 is expected to use a full :pep:`517` installation layout
which will indicate appropriate setuptools versioning up front.

Fixes: #7311
Change-Id: I215ef3c3b226a38266f59d181214aea462c4664d

doc/build/changelog/unreleased_14/7311.rst [new file with mode: 0644]
setup.py

diff --git a/doc/build/changelog/unreleased_14/7311.rst b/doc/build/changelog/unreleased_14/7311.rst
new file mode 100644 (file)
index 0000000..69a522d
--- /dev/null
@@ -0,0 +1,12 @@
+.. change::
+    :tags: bug, setup
+    :tickets: 7311
+
+    Python 3.10 has deprecated "distutils" in favor of explicit use of
+    "setuptools" in :pep:`632`; SQLAlchemy's setup.py has replaced imports
+    accordingly. However, since setuptools itself only recently added the
+    replacement symbols mentioned in pep-632 as of November of 2022 in version
+    59.0.1, ``setup.py`` still has fallback imports to distutils, as SQLAlchemy
+    1.4 does not have a hard setuptools versioning requirement at this time.
+    SQLAlchemy 2.0 is expected to use a full :pep:`517` installation layout
+    which will indicate appropriate setuptools versioning up front.
index 55a3cee6f984b065d7c4dfc44f10d5b9fa6f0571..f1a1cacba366f699d5aca2f0aafa83fd77383b9c 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,3 @@
-from distutils.command.build_ext import build_ext
-from distutils.errors import CCompilerError
-from distutils.errors import DistutilsExecError
-from distutils.errors import DistutilsPlatformError
 import os
 import platform
 import re
@@ -10,8 +6,20 @@ import sys
 from setuptools import Distribution as _Distribution
 from setuptools import Extension
 from setuptools import setup
+from setuptools.command.build_ext import build_ext
 from setuptools.command.test import test as TestCommand
 
+# attempt to use pep-632 imports for setuptools symbols; however,
+# since these symbols were only added to setuptools as of 59.0.1,
+# fall back to the distutils symbols otherwise
+try:
+    from setuptools.errors import CCompilerError
+    from setuptools.errors import DistutilsExecError
+    from setuptools.errors import DistutilsPlatformError
+except ImportError:
+    from distutils.errors import CCompilerError
+    from distutils.errors import DistutilsExecError
+    from distutils.errors import DistutilsPlatformError
 
 cmdclass = {}