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",
35 "Cython.Compiler.Scanning",
36 "Cython.Compiler.Parsing",
37 "Cython.Compiler.Visitor"]
39 for module in compiled_modules:
40 source_file = os.path.join(source_root, *module.split('.'))
41 print("Compiling module %s ..." % module)
42 result = compile(source_file + ".py")
45 Extension(module, sources = [result.c_file])
48 print("Compilation failed")
50 setup_args['ext_modules'] = extensions
52 print("ERROR: %s" % sys.exc_info()[1])
53 print("Extension module compilation failed, using plain Python implementation")
59 url = 'http://www.cython.org',
60 author = 'Greg Ewing, Robert Bradshaw, Stefan Behnel, Dag Seljebotn, et al.',
61 author_email = 'cython-dev@codespeak.net',
62 description = "The Cython compiler for writing C extensions for the Python language.",
63 long_description = """\
64 The Cython language makes writing C extensions for the Python language as
65 easy as Python itself. Cython is a source code translator based on the
66 well-known Pyrex_, but supports more cutting edge functionality and
69 The Cython language is very close to the Python language (and most Python
70 code is also valid Cython code), but Cython additionally supports calling C
71 functions and declaring C types on variables and class attributes. This
72 allows the compiler to generate very efficient C code from Cython code.
74 This makes Cython the ideal language for writing glue code for external C
75 libraries, and for fast C modules that speed up the execution of Python
78 .. _Pyrex: http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/
81 "Development Status :: 5 - Production/Stable",
82 "Intended Audience :: Developers",
83 "License :: OSI Approved :: Python Software Foundation License",
84 "Operating System :: OS Independent",
85 "Programming Language :: Python",
86 "Programming Language :: C",
87 "Topic :: Software Development :: Code Generators",
88 "Topic :: Software Development :: Compilers",
89 "Topic :: Software Development :: Libraries :: Python Modules"
102 'Cython.Compiler.Tests',
106 py_modules = ["pyximport/__init__",
107 "pyximport/pyximport",
108 "pyximport/pyxbuild"],