From: Mike Bayer Date: Mon, 15 Nov 2021 20:06:06 +0000 (-0500) Subject: favor setuptools imports over distutils X-Git-Tag: rel_2_0_0b1~642^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6c02c33728a581e0df910caa8d96b6e114c114d;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git favor setuptools imports over distutils 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 --- diff --git a/doc/build/changelog/unreleased_14/7311.rst b/doc/build/changelog/unreleased_14/7311.rst new file mode 100644 index 0000000000..69a522d526 --- /dev/null +++ b/doc/build/changelog/unreleased_14/7311.rst @@ -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. diff --git a/setup.py b/setup.py index 55a3cee6f9..f1a1cacba3 100644 --- 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 = {}