Commit 487f797d authored by Denis Bilenko's avatar Denis Bilenko

add "cython" command to setup.py: python setup.py cython

parent df7f503e
...@@ -70,6 +70,16 @@ def system(command): ...@@ -70,6 +70,16 @@ def system(command):
return os.system(command) return os.system(command)
def run_cython(cython_command='cython'):
if has_changed('gevent/core.pyx', 'gevent/core_.pyx', 'gevent/libev.pxd'):
system('m4 gevent/core_.pyx > core.pyx && mv core.pyx gevent/')
if has_changed(cython_output, 'gevent/*.p*x*', 'gevent/*.h', 'gevent/*.c', 'libev/*.c', 'c-ares/*.c'):
if 0 == system('%s gevent/core.pyx -o core.c && mv core.* gevent/' % (cython_command, )):
data = open(cython_output).read()
data = data.replace('\n\n#endif /* Py_PYTHON_H */', '\n#include "callbacks.c"\n#endif /* Py_PYTHON_H */')
open(cython_output, 'w').write(data)
class my_build_ext(build_ext.build_ext): class my_build_ext(build_ext.build_ext):
user_options = (build_ext.build_ext.user_options user_options = (build_ext.build_ext.user_options
+ [("cython=", None, "path to the cython executable")]) + [("cython=", None, "path to the cython executable")])
...@@ -78,22 +88,13 @@ class my_build_ext(build_ext.build_ext): ...@@ -78,22 +88,13 @@ class my_build_ext(build_ext.build_ext):
build_ext.build_ext.initialize_options(self) build_ext.build_ext.initialize_options(self)
self.cython = "cython" self.cython = "cython"
def compile_cython(self):
if has_changed('gevent/core.pyx', 'gevent/core_.pyx', 'gevent/libev.pxd'):
system('m4 gevent/core_.pyx > core.pyx && mv core.pyx gevent/')
if has_changed(cython_output, 'gevent/*.p*x*', 'gevent/*.h', 'gevent/*.c', 'libev/*.c', 'c-ares/*.c'):
if 0 == system('%s gevent/core.pyx -o core.c && mv core.* gevent/' % (self.cython, )):
data = open(cython_output).read()
data = data.replace('\n\n#endif /* Py_PYTHON_H */', '\n#include "callbacks.c"\n#endif /* Py_PYTHON_H */')
open(cython_output, 'w').write(data)
def configure_cares(self): def configure_cares(self):
if sys.platform != 'win32' and not os.path.exists('c-ares/ares_config.h'): if sys.platform != 'win32' and not os.path.exists('c-ares/ares_config.h'):
os.system('cd c-ares && %s' % cares_configure_command) os.system('cd c-ares && %s' % cares_configure_command)
def build_extension(self, ext): def build_extension(self, ext):
if self.cython: if self.cython:
self.compile_cython() run_cython(self.cython)
if cares_embed: if cares_embed:
self.configure_cares() self.configure_cares()
try: try:
...@@ -142,28 +143,31 @@ def read(name): ...@@ -142,28 +143,31 @@ def read(name):
if __name__ == '__main__': if __name__ == '__main__':
setup( if sys.argv[1:] == ['cython']:
name='gevent', run_cython()
version=__version__, else:
description='Coroutine-based network library', setup(
long_description=read('README.rst'), name='gevent',
author='Denis Bilenko', version=__version__,
author_email='denis.bilenko@gmail.com', description='Coroutine-based network library',
url='http://www.gevent.org/', long_description=read('README.rst'),
packages=['gevent'], author='Denis Bilenko',
ext_modules=[gevent_core], author_email='denis.bilenko@gmail.com',
cmdclass={'build_ext': my_build_ext}, url='http://www.gevent.org/',
install_requires=['greenlet'], packages=['gevent'],
classifiers=[ ext_modules=[gevent_core],
"License :: OSI Approved :: MIT License", cmdclass={'build_ext': my_build_ext},
"Programming Language :: Python :: 2.4", install_requires=['greenlet'],
"Programming Language :: Python :: 2.5", classifiers=[
"Programming Language :: Python :: 2.6", "License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 2.7", "Programming Language :: Python :: 2.4",
"Operating System :: MacOS :: MacOS X", "Programming Language :: Python :: 2.5",
"Operating System :: POSIX", "Programming Language :: Python :: 2.6",
"Operating System :: Microsoft :: Windows", "Programming Language :: Python :: 2.7",
"Topic :: Internet", "Operating System :: MacOS :: MacOS X",
"Topic :: Software Development :: Libraries :: Python Modules", "Operating System :: POSIX",
"Intended Audience :: Developers", "Operating System :: Microsoft :: Windows",
"Development Status :: 4 - Beta"]) "Topic :: Internet",
"Topic :: Software Development :: Libraries :: Python Modules",
"Intended Audience :: Developers",
"Development Status :: 4 - Beta"])
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