Permalink
Browse files

update setup.py to work well with pyx file

  • Loading branch information...
1 parent 860b1e2 commit ff785c85464d4ef912931037beca8c47c7674e53 @leejjoon committed Nov 19, 2011
Showing with 20 additions and 1 deletion.
  1. +20 −1 setup.py
View
@@ -3,7 +3,23 @@
from setuptools import setup, Extension
-PYREX_SOURCE = "src/_region_filter.pyx"
+# check if cython or pyrex is available.
+pyrex_impls = 'Cython.Distutils.build_ext', 'Pyrex.Distutils.build_ext'
+for pyrex_impl in pyrex_impls:
+ try:
+ # from (pyrex_impl) import build_ext
+ build_ext = __import__(pyrex_impl, fromlist=['build_ext']).build_ext
+ break
+ except:
+ pass
+have_pyrex = 'build_ext' in globals()
+
+if have_pyrex:
+ cmdclass = {'build_ext': build_ext}
+ PYREX_SOURCE = "src/_region_filter.pyx"
+else:
+ cmdclass = {}
+ PYREX_SOURCE = "src/_region_filter.c"
import sys
import warnings
@@ -49,6 +65,9 @@ def main():
except AttributeError:
numpy_include = numpy.get_numpy_include()
+ if cmdclass:
+ ka["cmdclass"] = cmdclass
+
ka["ext_modules"] = [ Extension("pyregion._region_filter",
[PYREX_SOURCE],
include_dirs=['./src',

0 comments on commit ff785c8

Please sign in to comment.