Skip to content

Commit

Permalink
Revert build_ext changes
Browse files Browse the repository at this point in the history
  • Loading branch information
EKC (Erik Cederstrand) committed Sep 27, 2023
1 parent 13f0a3e commit d0bc43a
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand All @@ -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=[
Expand Down

0 comments on commit d0bc43a

Please sign in to comment.