Skip to content

Commit 0b1c47b

Browse files
authored
do not install cython as build dependency (#610)
User can not cythonize during `pip install msgpack`. So remove cython from build dependency. If user need to use another Cython, user should download sdist, unzip, manually cythonize, and `pip install .`.
1 parent 9cea8b6 commit 0b1c47b

File tree

2 files changed

+1
-50
lines changed

2 files changed

+1
-50
lines changed

pyproject.toml

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
[build-system]
2-
requires = [
3-
# Also declared in requirements.txt, if updating here please also update there
4-
"Cython~=3.0.10",
5-
"setuptools >= 69.5.1",
6-
]
2+
requires = ["setuptools >= 69.5.1"]
73
build-backend = "setuptools.build_meta"
84

95
[project]

setup.py

-45
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,9 @@
33
import sys
44

55
from setuptools import Extension, setup
6-
from setuptools.command.build_ext import build_ext
7-
from setuptools.command.sdist import sdist
86

97
PYPY = hasattr(sys, "pypy_version_info")
108

11-
12-
class NoCython(Exception):
13-
pass
14-
15-
16-
try:
17-
import Cython.Compiler.Main as cython_compiler
18-
19-
have_cython = True
20-
except ImportError:
21-
have_cython = False
22-
23-
24-
def cythonize(src):
25-
if not have_cython:
26-
raise Exception("Cython is required for building from checkout")
27-
sys.stderr.write(f"cythonize: {src!r}\n")
28-
cython_compiler.compile([src])
29-
30-
31-
def ensure_source(src):
32-
pyx = os.path.splitext(src)[0] + ".pyx"
33-
34-
if not os.path.exists(src) or have_cython and os.stat(src).st_mtime < os.stat(pyx).st_mtime:
35-
cythonize(pyx)
36-
37-
38-
class BuildExt(build_ext):
39-
def build_extension(self, ext):
40-
for src in ext.sources:
41-
ensure_source(src)
42-
return build_ext.build_extension(self, ext)
43-
44-
45-
# Cython is required for sdist
46-
class Sdist(sdist):
47-
def __init__(self, *args, **kwargs):
48-
cythonize("msgpack/_cmsgpack.pyx")
49-
sdist.__init__(self, *args, **kwargs)
50-
51-
529
libraries = []
5310
macros = []
5411
ext_modules = []
@@ -69,9 +26,7 @@ def __init__(self, *args, **kwargs):
6926
)
7027
del libraries, macros
7128

72-
7329
setup(
74-
cmdclass={"build_ext": BuildExt, "sdist": Sdist},
7530
ext_modules=ext_modules,
7631
packages=["msgpack"],
7732
)

0 commit comments

Comments
 (0)