fixed license reference in setup.py
[cython.git] / setup.py
1 from distutils.core import setup, Extension
2 from distutils.sysconfig import get_python_lib
3 import os, os.path
4 import sys
5 from Cython.Compiler.Version import version
6
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:]
10
11 setup_args = {}
12
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'])]
19 else:
20     setup_args['package_data'] = {'Cython.Compiler' : ['Lexicon.pickle'],
21                                   'Cython' : ['Includes/*.pxd']}
22
23 if os.name == "posix":
24     scripts = ["bin/cython"]
25 else:
26     scripts = ["cython.py"]
27
28 try:
29     sys.argv.remove("--no-cython-compile")
30 except ValueError:
31     try:
32         from distutils.command.build_ext import build_ext as build_ext_orig
33         class build_ext(build_ext_orig):
34             def build_extension(self, ext, *args, **kargs):
35                 try:
36                     build_ext_orig.build_extension(self, ext, *args, **kargs)
37                 except StandardError:
38                     print("Compilation of '%s' failed" % ext.sources[0])
39         from Cython.Compiler.Main import compile
40         source_root = os.path.dirname(__file__)
41         compiled_modules = ["Cython.Plex.Scanners",
42                             "Cython.Compiler.Scanning",
43                             "Cython.Compiler.Parsing",
44                             "Cython.Compiler.Visitor"]
45         extensions = []
46         for module in compiled_modules:
47             source_file = os.path.join(source_root, *module.split('.'))
48             print("Compiling module %s ..." % module)
49             result = compile(source_file + ".py")
50             if result.c_file:
51                 extensions.append(
52                     Extension(module, sources = [result.c_file])
53                     )
54             else:
55                 print("Compilation failed")
56         if extensions:
57             setup_args['ext_modules'] = extensions
58             setup_args['cmdclass'] = {"build_ext" : build_ext}
59     except Exception:
60         print("ERROR: %s" % sys.exc_info()[1])
61         print("Extension module compilation failed, using plain Python implementation")
62
63
64 setup(
65   name = 'Cython', 
66   version = version,
67   url = 'http://www.cython.org',
68   author = 'Greg Ewing, Robert Bradshaw, Stefan Behnel, Dag Seljebotn, et al.',
69   author_email = 'cython-dev@codespeak.net',
70   description = "The Cython compiler for writing C extensions for the Python language.",
71   long_description = """\
72   The Cython language makes writing C extensions for the Python language as
73   easy as Python itself.  Cython is a source code translator based on the
74   well-known Pyrex_, but supports more cutting edge functionality and
75   optimizations.
76
77   The Cython language is very close to the Python language (and most Python
78   code is also valid Cython code), but Cython additionally supports calling C
79   functions and declaring C types on variables and class attributes. This
80   allows the compiler to generate very efficient C code from Cython code.
81
82   This makes Cython the ideal language for writing glue code for external C
83   libraries, and for fast C modules that speed up the execution of Python
84   code.
85
86   .. _Pyrex: http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/
87   """,
88   classifiers = [
89     "Development Status :: 5 - Production/Stable",
90     "Intended Audience :: Developers",
91     "License :: OSI Approved :: Apache Software License",
92     "Operating System :: OS Independent",
93     "Programming Language :: Python",
94     "Programming Language :: C",
95     "Topic :: Software Development :: Code Generators",
96     "Topic :: Software Development :: Compilers",
97     "Topic :: Software Development :: Libraries :: Python Modules"
98   ],
99
100   scripts = scripts,
101   packages=[
102     'Cython',
103     'Cython.Compiler',
104     'Cython.Distutils',
105     'Cython.Mac',
106     'Cython.Unix',
107     'Cython.Plex',
108
109     'Cython.Tests',
110     'Cython.Compiler.Tests',
111     ],
112   
113   # pyximport
114   py_modules = ["pyximport/__init__",
115                 "pyximport/pyximport",
116                 "pyximport/pyxbuild", 
117                 
118                 "cython"],
119   
120   **setup_args
121   )