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/test/py/TestServer.py b/test/py/TestServer.py
index 3a2f639..c2723e5 100755
--- a/test/py/TestServer.py
+++ b/test/py/TestServer.py
@@ -28,6 +28,7 @@
from util import local_libpath
sys.path.insert(0, local_libpath())
from thrift.protocol import TProtocol, TProtocolDecorator
+from thrift.Thrift import TException
SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
@@ -328,7 +329,9 @@
tfactory = TTransport.TBufferedTransportFactory()
# if --zlib, then wrap server transport, and use a different transport factory
if options.zlib:
- transport = TZlibTransport.TZlibTransport(transport) # wrap with zlib
+ if server_type != "TProcessPoolServer":
+ transport = TZlibTransport.TZlibTransport(transport) # wrap with zlib
+ # Avoid wrapping the server transport for process pools; TZlibTransport isn't picklable on spawn.
tfactory = TZlibTransport.TZlibTransportFactory()
# do server-specific setup here: