1 from distutils.core import setup, Extension
2 from distutils.sysconfig import get_python_lib
5 from Cython.Compiler.Version import version
7 compiler_dir = os.path.join(get_python_lib(prefix=''), 'Cython/Compiler')
8 if sys.platform == "win32":
9 compiler_dir = compiler_dir[len(sys.prefix)+1:]
13 if sys.version_info < (2,4):
14 cython_dir = os.path.join(get_python_lib(prefix=''), 'Cython')
15 compiler_dir = os.path.join(cython_dir, 'Compiler')
16 setup_args['data_files'] = [
17 (compiler_dir, ['Cython/Compiler/Lexicon.pickle']),
18 (cython_dir, ['Cython/Includes/*.pxd'])]
20 setup_args['package_data'] = {'Cython.Compiler' : ['Lexicon.pickle'],
21 'Cython' : ['Includes/*.pxd']}
23 if os.name == "posix":
24 scripts = ["bin/cython"]
26 scripts = ["cython.py"]
29 sys.argv.remove("--no-cython-compile")
32 from Cython.Compiler.Main import compile
33 source_root = os.path.dirname(__file__)
34 compiled_modules = ["Cython.Plex.Scanners"]
36 for module in compiled_modules:
37 source_file = os.path.join(source_root, *module.split('.'))
38 print("Compiling module %s ..." % module)
39 result = compile(source_file + ".py")
42 Extension(module, sources = [result.c_file])
45 print("Compilation failed")
47 setup_args['ext_modules'] = extensions
49 print("ERROR: %s" % sys.exc_info()[1])
50 print("Extension module compilation failed, using plain Python implementation")
56 url = 'http://www.cython.org',
57 author = 'Greg Ewing, William Stein, Robert Bradshaw, Stefan Behnel, et al.',
58 author_email = 'wstein@gmail.com',
59 description = "The Cython compiler for writing C extensions for the Python language.",
60 long_description = """\
61 The Cython language makes writing C extensions for the Python language as
62 easy as Python itself. Cython is a source code translator based on the
63 well-known Pyrex_, but supports more cutting edge functionality and
66 The Cython language is very close to the Python language (and most Python
67 code is also valid Cython code), but Cython additionally supports calling C
68 functions and declaring C types on variables and class attributes. This
69 allows the compiler to generate very efficient C code from Cython code.
71 This makes Cython the ideal language for writing glue code for external C
72 libraries, and for fast C modules that speed up the execution of Python
75 .. _Pyrex: http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/
78 "Development Status :: 5 - Production/Stable",
79 "Intended Audience :: Developers",
80 "License :: OSI Approved :: Python Software Foundation License",
81 "Operating System :: OS Independent",
82 "Programming Language :: Python",
83 "Programming Language :: C",
84 "Topic :: Software Development :: Code Generators",
85 "Topic :: Software Development :: Compilers",
86 "Topic :: Software Development :: Libraries :: Python Modules"
99 'Cython.Compiler.Tests',
105 # Now install pyximport
106 os.chdir('pyximport')
107 os.spawnlp(os.P_WAIT, 'python', 'python', 'Setup.py', *sys.argv[1:])