mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-10-28 08:04:12 +00:00
do not fallback on build error (#568)
This commit is contained in:
parent
ecf03748c7
commit
acd0684392
1 changed files with 6 additions and 20 deletions
26
setup.py
Executable file → Normal file
26
setup.py
Executable file → Normal file
|
|
@ -22,6 +22,8 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
def cythonize(src):
|
def cythonize(src):
|
||||||
|
if not have_cython:
|
||||||
|
raise Exception("Cython is required for building from checkout")
|
||||||
sys.stderr.write(f"cythonize: {src!r}\n")
|
sys.stderr.write(f"cythonize: {src!r}\n")
|
||||||
cython_compiler.compile([src], cplus=True)
|
cython_compiler.compile([src], cplus=True)
|
||||||
|
|
||||||
|
|
@ -29,31 +31,15 @@ def cythonize(src):
|
||||||
def ensure_source(src):
|
def ensure_source(src):
|
||||||
pyx = os.path.splitext(src)[0] + ".pyx"
|
pyx = os.path.splitext(src)[0] + ".pyx"
|
||||||
|
|
||||||
if not os.path.exists(src):
|
if not os.path.exists(src) or have_cython and os.stat(src).st_mtime < os.stat(pyx).st_mtime:
|
||||||
if not have_cython:
|
|
||||||
raise NoCython
|
|
||||||
cythonize(pyx)
|
cythonize(pyx)
|
||||||
elif os.path.exists(pyx) and os.stat(src).st_mtime < os.stat(pyx).st_mtime and have_cython:
|
|
||||||
cythonize(pyx)
|
|
||||||
return src
|
|
||||||
|
|
||||||
|
|
||||||
class BuildExt(build_ext):
|
class BuildExt(build_ext):
|
||||||
def build_extension(self, ext):
|
def build_extension(self, ext):
|
||||||
try:
|
for src in ext.sources:
|
||||||
ext.sources = list(map(ensure_source, ext.sources))
|
ensure_source(src)
|
||||||
except NoCython:
|
return build_ext.build_extension(self, ext)
|
||||||
print("WARNING")
|
|
||||||
print("Cython is required for building extension from checkout.")
|
|
||||||
print("Install Cython >= 0.16 or install msgpack from PyPI.")
|
|
||||||
print("Falling back to pure Python implementation.")
|
|
||||||
return
|
|
||||||
try:
|
|
||||||
return build_ext.build_extension(self, ext)
|
|
||||||
except Exception as e:
|
|
||||||
print("WARNING: Failed to compile extension modules.")
|
|
||||||
print("msgpack uses fallback pure python implementation.")
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
|
|
||||||
# Cython is required for sdist
|
# Cython is required for sdist
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue