Commit 232bc505 authored by Denis Bilenko's avatar Denis Bilenko

add 'cython' command to setup.py

parent 397e7b77
......@@ -40,15 +40,7 @@ sources = ['gevent/core.c']
libraries = []
class my_build_ext(build_ext.build_ext):
user_options = (build_ext.build_ext.user_options
+ [("cython=", None, "path to the cython executable")])
def initialize_options(self):
build_ext.build_ext.initialize_options(self)
self.cython = "cython"
def compile_cython(self):
def run_cython(cython_command='cython'):
sources = glob.glob('gevent/*.pyx') + glob.glob('gevent/*.pxi')
if not sources:
if not os.path.exists('gevent/core.c'):
......@@ -58,21 +50,30 @@ class my_build_ext(build_ext.build_ext):
changed = [filename for filename in sources if (os.stat(filename).st_mtime - core_c_mtime) > 1]
if not changed:
return
print >> sys.stderr, 'Running %s (changed: %s)' % (self.cython, ', '.join(changed))
print >> sys.stderr, 'Running %s (changed: %s)' % (cython_command, ', '.join(changed))
else:
print >> sys.stderr, 'Running %s' % self.cython
cython_result = os.system('%s gevent/core.pyx' % self.cython)
print >> sys.stderr, 'Running %s' % cython_command
cython_result = os.system('%s gevent/core.pyx' % cython_command)
if cython_result:
if os.system('%s -V 2> %s' % (self.cython, os.devnull)):
if os.system('%s -V 2> %s' % (cython_command, os.devnull)):
# there's no cython in the system
print >> sys.stderr, 'No cython found, cannot rebuild core.c'
return
sys.exit(1)
class my_build_ext(build_ext.build_ext):
user_options = (build_ext.build_ext.user_options
+ [("cython=", None, "path to the cython executable")])
def initialize_options(self):
build_ext.build_ext.initialize_options(self)
self.cython = "cython"
def build_extension(self, ext):
compile_libevent(self)
if self.cython:
self.compile_cython()
run_cython(self.cython)
result = build_ext.build_ext.build_extension(self, ext)
# hack: create a symlink from build/../core.so to gevent/core.so
# to prevent "ImportError: cannot import name core" failures
......@@ -295,6 +296,9 @@ def read(name):
if __name__ == '__main__':
if sys.argv[1:] == ['cython']:
run_cython()
else:
setup(
name='gevent',
version=__version__,
......
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