From d0bc43a7d787fffc8bce73013fbc34ae0cbaf8eb Mon Sep 17 00:00:00 2001 From: "EKC (Erik Cederstrand)" Date: Wed, 27 Sep 2023 10:36:25 +0200 Subject: [PATCH] Revert build_ext changes --- setup.py | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/setup.py b/setup.py index 33355de..ff89305 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,6 @@ from os.path import join, dirname from setuptools import setup, find_packages -from setuptools.command.build_ext import build_ext from setuptools.extension import Extension with open(join(dirname(__file__), 'thriftpy2', '__init__.py'), 'r') as f: @@ -40,32 +39,32 @@ ] + tornado_requires +cmdclass = {} +ext_modules = [] + # pypy detection PYPY = "__pypy__" in sys.modules UNIX = platform.system() in ("Linux", "Darwin") -ext_modules = [] +# only build ext in CPython with UNIX platform if UNIX and not PYPY: - ext_modules = [ - Extension("thriftpy2.transport.cybase", sources=["thriftpy2/transport/cybase.pyx"]), - Extension("thriftpy2.transport.buffered.cybuffered", sources=["thriftpy2/transport/buffered/cybuffered.pyx"]), - Extension("thriftpy2.transport.framed.cyframed", sources=["thriftpy2/transport/framed/cyframed.pyx"]), - Extension("thriftpy2.transport.memory.cymemory", sources=["thriftpy2/transport/memory/cymemory.pyx"]), - Extension("thriftpy2.transport.sasl.cysasl", sources=["thriftpy2/transport/sasl/cysasl.pyx"]), - Extension("thriftpy2.protocol.cybin", sources=["thriftpy2/protocol/cybin/cybin.pyx"]), - ] - - -class CustomBuildExtCommand(build_ext): - """build_ext command for use when Cythonizing.""" - - def finalize_options(self): - # only build ext in CPython with UNIX platform - if self.distribution.ext_modules: - from Cython.Build import cythonize - self.distribution.ext_modules[:] = cythonize(self.distribution.ext_modules, force=self.force) - super().finalize_options() - + from Cython.Build import cythonize + cythonize("thriftpy2/transport/cybase.pyx") + cythonize("thriftpy2/transport/**/*.pyx") + cythonize("thriftpy2/protocol/cybin/cybin.pyx") + + ext_modules.append(Extension("thriftpy2.transport.cybase", + ["thriftpy2/transport/cybase.c"])) + ext_modules.append(Extension("thriftpy2.transport.buffered.cybuffered", + ["thriftpy2/transport/buffered/cybuffered.c"])) + ext_modules.append(Extension("thriftpy2.transport.memory.cymemory", + ["thriftpy2/transport/memory/cymemory.c"])) + ext_modules.append(Extension("thriftpy2.transport.framed.cyframed", + ["thriftpy2/transport/framed/cyframed.c"])) + ext_modules.append(Extension("thriftpy2.transport.sasl.cysasl", + ["thriftpy2/transport/sasl/cysasl.c"])) + ext_modules.append(Extension("thriftpy2.protocol.cybin", + ["thriftpy2/protocol/cybin/cybin.c"])) setup(name="thriftpy2", version=version, @@ -89,8 +88,7 @@ def finalize_options(self): "dev": dev_requires, "tornado": tornado_requires }, - setup_requires=["Cython"], - cmdclass={'build_ext': CustomBuildExtCommand}, + cmdclass=cmdclass, ext_modules=ext_modules, include_package_data=True, classifiers=[