Commit 8fd32a78 authored by Denis Bilenko's avatar Denis Bilenko

setup.py: run cython if core.c does not exist

parent 75c24b62
...@@ -40,19 +40,23 @@ class my_build_ext(build_ext.build_ext): ...@@ -40,19 +40,23 @@ class my_build_ext(build_ext.build_ext):
def compile_cython(self): def compile_cython(self):
sources = glob.glob('gevent/*.pyx') + sorted(glob.glob('gevent/*.pxi')) sources = glob.glob('gevent/*.pyx') + sorted(glob.glob('gevent/*.pxi'))
if not sources: if not sources:
print >> sys.stderr, 'Could not find gevent.core sources' if not os.path.exists('gevent/core.c'):
return print >> sys.stderr, 'Could not find gevent/core.c'
core_c_mtime = os.stat('gevent/core.c').st_mtime if os.path.exists('gevent/core.c'):
changed = [filename for filename in sources if (os.stat(filename).st_mtime - core_c_mtime) > 1] core_c_mtime = os.stat('gevent/core.c').st_mtime
if changed: changed = [filename for filename in sources if (os.stat(filename).st_mtime - core_c_mtime) > 1]
if not changed:
return
print >> sys.stderr, 'Running cython (changed: %s)' % ', '.join(changed) print >> sys.stderr, 'Running cython (changed: %s)' % ', '.join(changed)
cython_result = os.system('cython gevent/core.pyx') else:
if cython_result: print >> sys.stderr, 'Running cython'
if os.system('cython -V 2> %s' % os.devnull): cython_result = os.system('cython gevent/core.pyx')
# there's no cython in the system if cython_result:
print >> sys.stderr, 'No cython found, cannot rebuild core.c' if os.system('cython -V 2> %s' % os.devnull):
return # there's no cython in the system
sys.exit(1) print >> sys.stderr, 'No cython found, cannot rebuild core.c'
return
sys.exit(1)
def build_extension(self, ext): def build_extension(self, ext):
self.compile_cython() self.compile_cython()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment