8000 setup: automatically fallback to pure Python module · overcastcloud/msgpack-python@2627b6a · GitHub
[go: up one dir, main page]

8000 Skip to content

Commit 2627b6a

Browse files
committed
setup: automatically fallback to pure Python module
Signed-off-by: Bas Westerbaan <bas@westerbaan.name>
1 parent 6a28b28 commit 2627b6a

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

setup.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
from distutils.command.build_ext import build_ext
1010

11+
class NoCython(Exception):
12+
pass
13+
1114
try:
1215
import Cython.Compiler.Main as cython_compiler
1316
have_cython = True
@@ -24,10 +27,7 @@ def ensure_source(src):
2427

2528
if not os.path.exists(src):
2629
if not have_cython:
27-
raise Exception("""\
28-
Cython is required for building extension from checkout.
29-
Install Cython >= 0.16 or install msgpack from PyPI.
30-
""")
30+
raise NoCython
3131
cythonize(pyx)
3232
elif (os.path.exists(pyx) and
3333
os.stat(src).st_mtime < os.stat(pyx).st_mtime and
@@ -38,7 +38,14 @@ def ensure_source(src):
3838

3939
class BuildExt(build_ext):
4040
def build_extension(self, ext):
41-
ext.sources = list(map(ensure_source, ext.sources))
41+
try:
42+
ext.sources = list(map(ensure_source, ext.sources))
43+
except NoCython:
44+
print "WARNING"
45+
print "Cython is required for building extension from checkout."
46+
print "Install Cython >= 0.16 or install msgpack from PyPI."
47+
print "Falling back to pure Python implementation."
48+
return
4249
return build_ext.build_extension(self, ext)
4350

4451

0 commit comments

Comments
 (0)
0