Fix Python 3.12 build issues in thrift Python (#3276)
- Add pyproject.toml with setuptools build requirement for PEP 517 compliance
- Replace distutils imports with setuptools equivalents
- Use setuptools error names directly (CompileError, ExecError, PlatformError)
- Fix macOS header collision with ntohll/htonll macros in endian.h
- Add a matrix of MacOS versions (macos-15-intel, macos-14, macos-15,
macos-26)
- Add a matrix of non-EOL Python versions for testing
- Remove MSVC2015 from the test matrix (very old).
- Support MSVC2022, the latest in AppVeyor.
- Upgrade tornado, twisted, and zope.interface versions to the first
that support Python 3.12.
- Try to make the test_socket, RunClientServer, and TestServer tests less flaky.
This fixes the ModuleNotFoundError: No module named 'distutils' error
when building thrift with Python 3.12+.
diff --git a/lib/py/setup.py b/lib/py/setup.py
index a02cc4f..2dd2a77 100644
--- a/lib/py/setup.py
+++ b/lib/py/setup.py
@@ -20,13 +20,10 @@
#
import sys
-try:
- from setuptools import setup, Extension
-except Exception:
- from distutils.core import setup, Extension
-from distutils.command.build_ext import build_ext
-from distutils.errors import CCompilerError, DistutilsExecError, DistutilsPlatformError
+from setuptools import Extension, setup
+from setuptools.command.build_ext import build_ext
+from setuptools.errors import CompileError, ExecError, PlatformError
# Fix to build sdist under vagrant
import os
@@ -39,9 +36,9 @@
include_dirs = ['src']
if sys.platform == 'win32':
include_dirs.append('compat/win32')
- ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError, IOError)
+ ext_errors = (CompileError, ExecError, PlatformError, IOError)
else:
- ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
+ ext_errors = (CompileError, ExecError, PlatformError)
class BuildFailed(Exception):
@@ -52,7 +49,7 @@
def run(self):
try:
build_ext.run(self)
- except DistutilsPlatformError:
+ except PlatformError:
raise BuildFailed()
def build_extension(self, ext):
@@ -99,8 +96,8 @@
ssl_deps = []
if sys.hexversion < 0x03050000:
ssl_deps.append('backports.ssl_match_hostname>=3.5')
- tornado_deps = ['tornado>=4.0']
- twisted_deps = ['twisted']
+ tornado_deps = ['tornado>=6.3.0']
+ twisted_deps = ['twisted>=24.3.0', 'zope.interface>=6.1']
setup(name='thrift',
version='0.23.0',