2007-03-01 00:35:54 +00:00
|
|
|
#!/usr/bin/env python
|
2009-03-30 21:35:00 +00:00
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
|
# or more contributor license agreements. See the NOTICE file
|
|
|
|
|
# distributed with this work for additional information
|
|
|
|
|
# regarding copyright ownership. The ASF licenses this file
|
|
|
|
|
# to you under the Apache License, Version 2.0 (the
|
|
|
|
|
# "License"); you may not use this file except in compliance
|
|
|
|
|
# with the License. You may obtain a copy of the License at
|
|
|
|
|
#
|
2016-02-03 01:57:03 +09:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2007-03-01 00:35:54 +00:00
|
|
|
#
|
2009-03-30 21:35:00 +00:00
|
|
|
# Unless required by applicable law or agreed to in writing,
|
|
|
|
|
# software distributed under the License is distributed on an
|
|
|
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
|
# KIND, either express or implied. See the License for the
|
|
|
|
|
# specific language governing permissions and limitations
|
|
|
|
|
# under the License.
|
2007-03-01 00:35:54 +00:00
|
|
|
#
|
|
|
|
|
|
2011-11-26 05:23:09 +00:00
|
|
|
import sys
|
|
|
|
|
|
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+.
2026-01-29 16:51:37 -05:00
|
|
|
from setuptools import Extension, setup
|
|
|
|
|
from setuptools.command.build_ext import build_ext
|
|
|
|
|
from setuptools.errors import CompileError, ExecError, PlatformError
|
2007-08-25 18:01:30 +00:00
|
|
|
|
2014-07-10 09:18:42 -04:00
|
|
|
# Fix to build sdist under vagrant
|
|
|
|
|
import os
|
|
|
|
|
if 'vagrant' in str(os.environ):
|
2018-03-01 15:42:33 +01:00
|
|
|
try:
|
|
|
|
|
del os.link
|
|
|
|
|
except AttributeError:
|
|
|
|
|
pass
|
2014-07-10 09:18:42 -04:00
|
|
|
|
2016-02-11 13:58:39 +09:00
|
|
|
include_dirs = ['src']
|
2011-09-13 13:54:05 +00:00
|
|
|
if sys.platform == 'win32':
|
|
|
|
|
include_dirs.append('compat/win32')
|
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+.
2026-01-29 16:51:37 -05:00
|
|
|
ext_errors = (CompileError, ExecError, PlatformError, IOError)
|
2011-11-26 05:23:09 +00:00
|
|
|
else:
|
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+.
2026-01-29 16:51:37 -05:00
|
|
|
ext_errors = (CompileError, ExecError, PlatformError)
|
2011-11-26 05:23:09 +00:00
|
|
|
|
2016-02-03 01:57:03 +09:00
|
|
|
|
2011-11-26 05:23:09 +00:00
|
|
|
class BuildFailed(Exception):
|
|
|
|
|
pass
|
|
|
|
|
|
2016-02-03 01:57:03 +09:00
|
|
|
|
2011-11-26 05:23:09 +00:00
|
|
|
class ve_build_ext(build_ext):
|
|
|
|
|
def run(self):
|
|
|
|
|
try:
|
|
|
|
|
build_ext.run(self)
|
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+.
2026-01-29 16:51:37 -05:00
|
|
|
except PlatformError:
|
2011-11-26 05:23:09 +00:00
|
|
|
raise BuildFailed()
|
|
|
|
|
|
|
|
|
|
def build_extension(self, ext):
|
|
|
|
|
try:
|
|
|
|
|
build_ext.build_extension(self, ext)
|
2016-02-03 01:57:03 +09:00
|
|
|
except ext_errors:
|
2011-11-26 05:23:09 +00:00
|
|
|
raise BuildFailed()
|
|
|
|
|
|
2016-02-03 01:57:03 +09:00
|
|
|
|
2021-09-25 16:47:05 -04:00
|
|
|
def read_file(path):
|
|
|
|
|
"""
|
|
|
|
|
Return the contents of a file
|
|
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
- path: path to the file
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
- contents of the file
|
|
|
|
|
"""
|
|
|
|
|
with open(path, "r") as desc_file:
|
|
|
|
|
return desc_file.read().rstrip()
|
|
|
|
|
|
|
|
|
|
|
2011-11-26 05:23:09 +00:00
|
|
|
def run_setup(with_binary):
|
|
|
|
|
if with_binary:
|
|
|
|
|
extensions = dict(
|
2016-02-03 01:57:03 +09:00
|
|
|
ext_modules=[
|
|
|
|
|
Extension('thrift.protocol.fastbinary',
|
2020-08-25 09:53:39 +08:00
|
|
|
extra_compile_args=['-std=c++11'],
|
2016-02-11 13:58:39 +09:00
|
|
|
sources=[
|
|
|
|
|
'src/ext/module.cpp',
|
|
|
|
|
'src/ext/types.cpp',
|
|
|
|
|
'src/ext/binary.cpp',
|
|
|
|
|
'src/ext/compact.cpp',
|
|
|
|
|
],
|
2025-10-30 07:44:21 +01:00
|
|
|
depends=[
|
|
|
|
|
'src/ext/binary.h',
|
|
|
|
|
'src/ext/compact.h',
|
|
|
|
|
'src/ext/endian.h',
|
|
|
|
|
'src/ext/protocol.h',
|
|
|
|
|
'src/ext/protocol.tcc',
|
|
|
|
|
'src/ext/types.h',
|
|
|
|
|
],
|
2016-02-03 01:57:03 +09:00
|
|
|
include_dirs=include_dirs,
|
|
|
|
|
)
|
2011-11-26 05:23:09 +00:00
|
|
|
],
|
|
|
|
|
cmdclass=dict(build_ext=ve_build_ext)
|
|
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
extensions = dict()
|
2015-11-06 21:24:16 +09:00
|
|
|
|
2016-09-04 18:49:21 +09:00
|
|
|
ssl_deps = []
|
|
|
|
|
if sys.hexversion < 0x03050000:
|
|
|
|
|
ssl_deps.append('backports.ssl_match_hostname>=3.5')
|
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+.
2026-01-29 16:51:37 -05:00
|
|
|
tornado_deps = ['tornado>=6.3.0']
|
|
|
|
|
twisted_deps = ['twisted>=24.3.0', 'zope.interface>=6.1']
|
2016-09-04 18:49:21 +09:00
|
|
|
|
2016-02-03 01:57:03 +09:00
|
|
|
setup(name='thrift',
|
2026-04-08 00:05:45 +02:00
|
|
|
version='0.24.0',
|
2016-02-03 01:57:03 +09:00
|
|
|
description='Python bindings for the Apache Thrift RPC system',
|
2021-09-25 16:47:05 -04:00
|
|
|
long_description=read_file("README.md"),
|
|
|
|
|
long_description_content_type="text/markdown",
|
2018-12-30 11:06:00 -05:00
|
|
|
author='Apache Thrift Developers',
|
2016-02-03 01:57:03 +09:00
|
|
|
author_email='dev@thrift.apache.org',
|
|
|
|
|
url='http://thrift.apache.org',
|
|
|
|
|
license='Apache License 2.0',
|
2016-09-04 18:49:21 +09:00
|
|
|
extras_require={
|
|
|
|
|
'ssl': ssl_deps,
|
|
|
|
|
'tornado': tornado_deps,
|
|
|
|
|
'twisted': twisted_deps,
|
|
|
|
|
'all': ssl_deps + tornado_deps + twisted_deps,
|
|
|
|
|
},
|
2016-02-03 01:57:03 +09:00
|
|
|
packages=[
|
|
|
|
|
'thrift',
|
|
|
|
|
'thrift.protocol',
|
|
|
|
|
'thrift.transport',
|
|
|
|
|
'thrift.server',
|
|
|
|
|
],
|
|
|
|
|
package_dir={'thrift': 'src'},
|
|
|
|
|
classifiers=[
|
|
|
|
|
'Development Status :: 5 - Production/Stable',
|
|
|
|
|
'Environment :: Console',
|
|
|
|
|
'Intended Audience :: Developers',
|
|
|
|
|
'Programming Language :: Python',
|
|
|
|
|
'Programming Language :: Python :: 3',
|
|
|
|
|
'Topic :: Software Development :: Libraries',
|
|
|
|
|
'Topic :: System :: Networking'
|
|
|
|
|
],
|
2017-01-27 16:21:40 -05:00
|
|
|
zip_safe=False,
|
2016-02-03 01:57:03 +09:00
|
|
|
**extensions
|
|
|
|
|
)
|
2006-09-03 21:13:07 +00:00
|
|
|
|
2017-09-30 15:44:16 -07:00
|
|
|
|
2011-11-26 05:23:09 +00:00
|
|
|
try:
|
2016-02-11 16:21:01 +09:00
|
|
|
with_binary = True
|
2015-11-06 21:24:16 +09:00
|
|
|
run_setup(with_binary)
|
2025-10-30 07:44:21 +01:00
|
|
|
sys.exit(0)
|
|
|
|
|
|
2011-11-26 05:23:09 +00:00
|
|
|
except BuildFailed:
|
2014-03-27 13:56:04 -04:00
|
|
|
print()
|
|
|
|
|
print('*' * 80)
|
2014-11-24 10:55:31 +01:00
|
|
|
print("An error occurred while trying to compile with the C extension enabled")
|
2014-03-27 13:56:04 -04:00
|
|
|
print("Attempting to build without the extension now")
|
|
|
|
|
print('*' * 80)
|
|
|
|
|
print()
|
2006-09-03 21:13:07 +00:00
|
|
|
|
2025-10-30 07:44:21 +01:00
|
|
|
# Retry but without the binary
|
|
|
|
|
try:
|
2011-11-26 05:23:09 +00:00
|
|
|
run_setup(False)
|
2025-10-30 07:44:21 +01:00
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
|
|
except BuildFailed:
|
|
|
|
|
print()
|
|
|
|
|
print('*' * 80)
|
|
|
|
|
print("An error occurred while trying to compile without the C extension enabled")
|
|
|
|
|
print("Build failed")
|
|
|
|
|
print('*' * 80)
|
|
|
|
|
print()
|
|
|
|
|
sys.exit(1)
|