Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 334 lines (293 sloc) 12.573 kb
911b8034 »
2008-06-08 compile Cython.Plex.Scanners module on install to speed up compilation
1 from distutils.core import setup, Extension
c4fa206b »
2007-07-28 Initial version
2 from distutils.sysconfig import get_python_lib
911b8034 »
2008-06-08 compile Cython.Plex.Scanners module on install to speed up compilation
3 import os, os.path
7d717f7d »
2007-09-07 buildfile changes
4 import sys
c4fa206b »
2007-07-28 Initial version
5
1727c4ba »
2012-02-24 do not compile Cython itself outside of CPython
6 try:
7 import platform
8 is_cpython = not hasattr(platform, 'python_implementation') or platform.python_implementation() == 'CPython'
9 except (ImportError, NameError):
10 is_cpython = True # CPython < 2.6
11
594ba31d »
2009-11-20 Remove extra files in distribution tar.
12 if sys.platform == "darwin":
13 # Don't create resource files on OS X tar.
14 os.environ['COPY_EXTENDED_ATTRIBUTES_DISABLE'] = 'true'
15 os.environ['COPYFILE_DISABLE'] = 'true'
16
655041eb »
2007-07-30 fix target directory for Lexicon.pickle (do it right this time)
17 setup_args = {}
18
43239dc1 »
2010-02-17 somewhat ugly hack for Py3.1+ to get Cython modules compiled on insta…
19 def add_command_class(name, cls):
20 cmdclasses = setup_args.get('cmdclass', {})
21 cmdclasses[name] = cls
22 setup_args['cmdclass'] = cmdclasses
23
5691e177 »
2011-02-25 better sdist, use command for generating gitrev
24 from distutils.command.sdist import sdist as sdist_orig
25 class sdist(sdist_orig):
26 def run(self):
f63b9469 »
2011-04-05 fix MANIFEST.in and force MANIFEST generation in sdist command
27 self.force_manifest = 1
5691e177 »
2011-02-25 better sdist, use command for generating gitrev
28 if (sys.platform != "win32" and
29 os.path.isdir('.git')):
30 assert os.system("git show-ref -s HEAD > .gitrev") == 0
31 sdist_orig.run(self)
32 add_command_class('sdist', sdist)
33
f89d8fe5 »
2009-04-24 use lib2to3 to port to Py3 on installation
34 if sys.version_info[0] >= 3:
35 import lib2to3.refactor
36 from distutils.command.build_py \
37 import build_py_2to3 as build_py
38 # need to convert sources to Py3 on installation
39 fixers = [ fix for fix in lib2to3.refactor.get_fixers_from_package("lib2to3.fixes")
40 if fix.split('fix_')[-1] not in ('next',)
41 ]
42 build_py.fixer_names = fixers
43239dc1 »
2010-02-17 somewhat ugly hack for Py3.1+ to get Cython modules compiled on insta…
43 add_command_class("build_py", build_py)
f89d8fe5 »
2009-04-24 use lib2to3 to port to Py3 on installation
44
5409958b »
2010-03-13 find .pxd include directories automatically during installation
45 pxd_include_dirs = [
46 directory for directory, dirs, files in os.walk('Cython/Includes')
47 if '__init__.pyx' in files or '__init__.pxd' in files
5b086260 »
2010-07-06 Copy over Cython/Includes/Deprecated directory on install...
48 or directory == 'Cython/Includes' or directory == 'Cython/Includes/Deprecated']
5409958b »
2010-03-13 find .pxd include directories automatically during installation
49
50 pxd_include_patterns = [
51 p+'/*.pxd' for p in pxd_include_dirs ] + [
52 p+'/*.pyx' for p in pxd_include_dirs ]
f89d8fe5 »
2009-04-24 use lib2to3 to port to Py3 on installation
53
f2977151 »
2012-07-09 fix inclusion of .cpp utility files in setup.py
54 setup_args['package_data'] = {
55 'Cython.Plex' : ['*.pxd'],
56 'Cython.Compiler' : ['*.pxd'],
57 'Cython.Runtime' : ['*.pyx', '*.pxd'],
58 'Cython.Utility' : ['*.pyx', '*.pxd', '*.c', '*.h', '*.cpp'],
59 'Cython' : [ p[7:] for p in pxd_include_patterns ],
60 }
c4fa206b »
2007-07-28 Initial version
61
5f531449 »
2011-01-14 Undo EOL whitespace additions.
62 # This dict is used for passing extra arguments that are setuptools
0855d80e »
2009-11-10 Optional setuptools-based cython build
63 # specific to setup
64 setuptools_extra_args = {}
65
c12526e9 »
2010-12-01 Excluded cygdb from python 2.3 and 2.4 installations and made it 2.5 …
66 # tells whether to include cygdb (the script and the Cython.Debugger package
51714ebf »
2010-12-09 Drop Python 2.5 support + unicode UCS4 builds support + add more tests
67 include_debugger = sys.version_info[:2] > (2, 5)
c12526e9 »
2010-12-01 Excluded cygdb from python 2.3 and 2.4 installations and made it 2.5 …
68
0855d80e »
2009-11-10 Optional setuptools-based cython build
69 if 'setuptools' in sys.modules:
70 setuptools_extra_args['zip_safe'] = False
71 setuptools_extra_args['entry_points'] = {
72 'console_scripts': [
73 'cython = Cython.Compiler.Main:setuptools_main',
74 ]
75 }
76 scripts = []
c4fa206b »
2007-07-28 Initial version
77 else:
0855d80e »
2009-11-10 Optional setuptools-based cython build
78 if os.name == "posix":
c12526e9 »
2010-12-01 Excluded cygdb from python 2.3 and 2.4 installations and made it 2.5 …
79 scripts = ["bin/cython"]
0855d80e »
2009-11-10 Optional setuptools-based cython build
80 else:
c12526e9 »
2010-12-01 Excluded cygdb from python 2.3 and 2.4 installations and made it 2.5 …
81 scripts = ["cython.py"]
a8d81e52 »
2011-12-08 Include cygdb in setuptools distribution
82
83 if include_debugger:
84 if os.name == "posix":
85 scripts.append('bin/cygdb')
86 else:
87 scripts.append('cygdb.py')
88
0855d80e »
2009-11-10 Optional setuptools-based cython build
89
046270e7 »
2010-11-28 support building Cython itself with the refnanny enabled
90 def compile_cython_modules(profile=False, compile_more=False, cython_with_refnanny=False):
43239dc1 »
2010-02-17 somewhat ugly hack for Py3.1+ to get Cython modules compiled on insta…
91 source_root = os.path.abspath(os.path.dirname(__file__))
92 compiled_modules = ["Cython.Plex.Scanners",
d037a456 »
2010-11-16 more cythonisation in the scanner/parser
93 "Cython.Plex.Actions",
90cfb960 »
2010-12-08 reduce code size of parser and speed it up a little by statically swi…
94 "Cython.Compiler.Lexicon",
43239dc1 »
2010-02-17 somewhat ugly hack for Py3.1+ to get Cython modules compiled on insta…
95 "Cython.Compiler.Scanning",
96 "Cython.Compiler.Parsing",
97 "Cython.Compiler.Visitor",
8e821645 »
2011-05-28 enable compilation of FlowControl.py in Py<=2.4
98 "Cython.Compiler.FlowControl",
c6ecb09c »
2010-12-09 compile Code.py
99 "Cython.Compiler.Code",
8e821645 »
2011-05-28 enable compilation of FlowControl.py in Py<=2.4
100 "Cython.Runtime.refnanny",
f7fb5c63 »
2012-05-03 Remove Importer.py and with statements in FusedNode
101 # "Cython.Compiler.FusedNode",
8e821645 »
2011-05-28 enable compilation of FlowControl.py in Py<=2.4
102 ]
8dca292a »
2010-11-27 setup.py option '--cython-compile-all' to compile more Cython modules…
103 if compile_more:
104 compiled_modules.extend([
b69b4a5b »
2012-05-11 cythonize performance improvements for large codebases
105 "Cython.Build.Dependencies",
8dca292a »
2010-11-27 setup.py option '--cython-compile-all' to compile more Cython modules…
106 "Cython.Compiler.ParseTreeTransforms",
107 "Cython.Compiler.Nodes",
108 "Cython.Compiler.ExprNodes",
109 "Cython.Compiler.ModuleNode",
110 "Cython.Compiler.Optimize",
111 ])
c4fa206b »
2007-07-28 Initial version
112
046270e7 »
2010-11-28 support building Cython itself with the refnanny enabled
113 defines = []
114 if cython_with_refnanny:
115 defines.append(('CYTHON_REFNANNY', '1'))
c4fa206b »
2007-07-28 Initial version
116
8dca292a »
2010-11-27 setup.py option '--cython-compile-all' to compile more Cython modules…
117 extensions = []
c12815a8 »
2009-04-24 make sure we do not compile (for now) in Py3
118 if sys.version_info[0] >= 3:
43239dc1 »
2010-02-17 somewhat ugly hack for Py3.1+ to get Cython modules compiled on insta…
119 from Cython.Distutils import build_ext as build_ext_orig
911b8034 »
2008-06-08 compile Cython.Plex.Scanners module on install to speed up compilation
120 for module in compiled_modules:
121 source_file = os.path.join(source_root, *module.split('.'))
2dc08fb1 »
2009-02-03 build and install "Cython.Runtime.refnanny", use it as a fallback if …
122 if os.path.exists(source_file + ".py"):
b0900657 »
2009-07-03 only regenerate Cython's own C sources when the .py files were updated
123 pyx_source_file = source_file + ".py"
2dc08fb1 »
2009-02-03 build and install "Cython.Runtime.refnanny", use it as a fallback if …
124 else:
b0900657 »
2009-07-03 only regenerate Cython's own C sources when the .py files were updated
125 pyx_source_file = source_file + ".pyx"
cbcec79e »
2010-11-11 recompile Cython source files when .pxd override files change
126 dep_files = []
127 if os.path.exists(source_file + '.pxd'):
128 dep_files.append(source_file + '.pxd')
046270e7 »
2010-11-28 support building Cython itself with the refnanny enabled
129 if '.refnanny' in module:
130 defines_for_module = []
131 else:
132 defines_for_module = defines
43239dc1 »
2010-02-17 somewhat ugly hack for Py3.1+ to get Cython modules compiled on insta…
133 extensions.append(
cbcec79e »
2010-11-11 recompile Cython source files when .pxd override files change
134 Extension(module, sources = [pyx_source_file],
046270e7 »
2010-11-28 support building Cython itself with the refnanny enabled
135 define_macros = defines_for_module,
cbcec79e »
2010-11-11 recompile Cython source files when .pxd override files change
136 depends = dep_files)
43239dc1 »
2010-02-17 somewhat ugly hack for Py3.1+ to get Cython modules compiled on insta…
137 )
138
139 class build_ext(build_ext_orig):
e74ad055 »
2010-10-22 Py3 install fix: keep original Py2 source modules of Cython alive dur…
140 # we must keep the original modules alive to make sure
141 # their code keeps working when we remove them from
142 # sys.modules
143 dead_modules = []
144
43239dc1 »
2010-02-17 somewhat ugly hack for Py3.1+ to get Cython modules compiled on insta…
145 def build_extensions(self):
146 # add path where 2to3 installed the transformed sources
147 # and make sure Python (re-)imports them from there
148 already_imported = [ module for module in sys.modules
149 if module == 'Cython' or module.startswith('Cython.') ]
e74ad055 »
2010-10-22 Py3 install fix: keep original Py2 source modules of Cython alive dur…
150 keep_alive = self.dead_modules.append
43239dc1 »
2010-02-17 somewhat ugly hack for Py3.1+ to get Cython modules compiled on insta…
151 for module in already_imported:
e74ad055 »
2010-10-22 Py3 install fix: keep original Py2 source modules of Cython alive dur…
152 keep_alive(sys.modules[module])
43239dc1 »
2010-02-17 somewhat ugly hack for Py3.1+ to get Cython modules compiled on insta…
153 del sys.modules[module]
154 sys.path.insert(0, os.path.join(source_root, self.build_lib))
155
73368ff5 »
2010-04-09 support profiling of Cython binary modules when passing --cython-prof…
156 if profile:
157 from Cython.Compiler.Options import directive_defaults
158 directive_defaults['profile'] = True
159 print("Enabled profiling for the Cython binary modules")
43239dc1 »
2010-02-17 somewhat ugly hack for Py3.1+ to get Cython modules compiled on insta…
160 build_ext_orig.build_extensions(self)
161
162 setup_args['ext_modules'] = extensions
163 add_command_class("build_ext", build_ext)
164
165 else: # Python 2.x
166 from distutils.command.build_ext import build_ext as build_ext_orig
167 try:
168 class build_ext(build_ext_orig):
169 def build_extension(self, ext, *args, **kargs):
170 try:
171 build_ext_orig.build_extension(self, ext, *args, **kargs)
172 except StandardError:
173 print("Compilation of '%s' failed" % ext.sources[0])
174 from Cython.Compiler.Main import compile
175 from Cython import Utils
73368ff5 »
2010-04-09 support profiling of Cython binary modules when passing --cython-prof…
176 if profile:
177 from Cython.Compiler.Options import directive_defaults
178 directive_defaults['profile'] = True
179 print("Enabled profiling for the Cython binary modules")
43239dc1 »
2010-02-17 somewhat ugly hack for Py3.1+ to get Cython modules compiled on insta…
180 source_root = os.path.dirname(__file__)
181 for module in compiled_modules:
182 source_file = os.path.join(source_root, *module.split('.'))
183 if os.path.exists(source_file + ".py"):
184 pyx_source_file = source_file + ".py"
185 else:
186 pyx_source_file = source_file + ".pyx"
187 c_source_file = source_file + ".c"
cbcec79e »
2010-11-11 recompile Cython source files when .pxd override files change
188 source_is_newer = False
189 if not os.path.exists(c_source_file):
190 source_is_newer = True
191 else:
192 c_last_modified = Utils.modification_time(c_source_file)
193 if Utils.file_newer_than(pyx_source_file, c_last_modified):
194 source_is_newer = True
195 else:
196 pxd_source_file = source_file + ".pxd"
197 if os.path.exists(pxd_source_file) and Utils.file_newer_than(pxd_source_file, c_last_modified):
198 source_is_newer = True
199 if source_is_newer:
43239dc1 »
2010-02-17 somewhat ugly hack for Py3.1+ to get Cython modules compiled on insta…
200 print("Compiling module %s ..." % module)
201 result = compile(pyx_source_file)
202 c_source_file = result.c_file
203 if c_source_file:
846d1859 »
2010-07-02 fix Cython installation, make compilation obligatory (unless explicit…
204 # Py2 distutils can't handle unicode file paths
205 if isinstance(c_source_file, unicode):
206 filename_encoding = sys.getfilesystemencoding()
207 if filename_encoding is None:
208 filename_encoding = sys.getdefaultencoding()
209 c_source_file = c_source_file.encode(filename_encoding)
046270e7 »
2010-11-28 support building Cython itself with the refnanny enabled
210 if '.refnanny' in module:
211 defines_for_module = []
212 else:
213 defines_for_module = defines
43239dc1 »
2010-02-17 somewhat ugly hack for Py3.1+ to get Cython modules compiled on insta…
214 extensions.append(
046270e7 »
2010-11-28 support building Cython itself with the refnanny enabled
215 Extension(module, sources = [c_source_file],
216 define_macros = defines_for_module)
43239dc1 »
2010-02-17 somewhat ugly hack for Py3.1+ to get Cython modules compiled on insta…
217 )
218 else:
219 print("Compilation failed")
220 if extensions:
221 setup_args['ext_modules'] = extensions
222 add_command_class("build_ext", build_ext)
223 except Exception:
846d1859 »
2010-07-02 fix Cython installation, make compilation obligatory (unless explicit…
224 print('''
225 ERROR: %s
226
227 Extension module compilation failed, looks like Cython cannot run
228 properly on this system. To work around this, pass the option
229 "--no-cython-compile". This will install a pure Python version of
230 Cython without compiling its own sources.
231 ''' % sys.exc_info()[1])
232 raise
43239dc1 »
2010-02-17 somewhat ugly hack for Py3.1+ to get Cython modules compiled on insta…
233
e0c8a312 »
2010-04-09 tiny cleanup in setup.py
234 cython_profile = '--cython-profile' in sys.argv
235 if cython_profile:
236 sys.argv.remove('--cython-profile')
237
43239dc1 »
2010-02-17 somewhat ugly hack for Py3.1+ to get Cython modules compiled on insta…
238 try:
8dca292a »
2010-11-27 setup.py option '--cython-compile-all' to compile more Cython modules…
239 sys.argv.remove("--cython-compile-all")
240 cython_compile_more = True
241 except ValueError:
242 cython_compile_more = False
243
244 try:
046270e7 »
2010-11-28 support building Cython itself with the refnanny enabled
245 sys.argv.remove("--cython-with-refnanny")
246 cython_with_refnanny = True
247 except ValueError:
248 cython_with_refnanny = False
249
250 try:
43239dc1 »
2010-02-17 somewhat ugly hack for Py3.1+ to get Cython modules compiled on insta…
251 sys.argv.remove("--no-cython-compile")
e79c7017 »
2011-04-28 avoid redundant exception output in Python 3 build
252 compile_cython_itself = False
43239dc1 »
2010-02-17 somewhat ugly hack for Py3.1+ to get Cython modules compiled on insta…
253 except ValueError:
e79c7017 »
2011-04-28 avoid redundant exception output in Python 3 build
254 compile_cython_itself = True
255
1727c4ba »
2012-02-24 do not compile Cython itself outside of CPython
256 if compile_cython_itself and (is_cpython or cython_compile_more):
046270e7 »
2010-11-28 support building Cython itself with the refnanny enabled
257 compile_cython_modules(cython_profile, cython_compile_more, cython_with_refnanny)
911b8034 »
2008-06-08 compile Cython.Plex.Scanners module on install to speed up compilation
258
0855d80e »
2009-11-10 Optional setuptools-based cython build
259 setup_args.update(setuptools_extra_args)
911b8034 »
2008-06-08 compile Cython.Plex.Scanners module on install to speed up compilation
260
6c734f76 »
2010-11-03 move 'official' version number to Cython/__init__.py to avoid importi…
261 from Cython import __version__ as version
0fba6e92 »
2009-08-21 import Cython as late as possible
262
c12526e9 »
2010-12-01 Excluded cygdb from python 2.3 and 2.4 installations and made it 2.5 …
263 packages = [
264 'Cython',
265 'Cython.Build',
266 'Cython.Compiler',
267 'Cython.Runtime',
268 'Cython.Distutils',
269 'Cython.Plex',
270 'Cython.Tests',
efe9d6a9 »
2010-12-10 Some unit tests for the build system.
271 'Cython.Build.Tests',
c12526e9 »
2010-12-01 Excluded cygdb from python 2.3 and 2.4 installations and made it 2.5 …
272 'Cython.Compiler.Tests',
556722cb »
2011-07-21 Utility Code loader + memview python3 compat
273 'Cython.Utility',
3f8fefb0 »
2011-07-22 Tempita support
274 'Cython.Tempita',
c12526e9 »
2010-12-01 Excluded cygdb from python 2.3 and 2.4 installations and made it 2.5 …
275 ]
276
277 if include_debugger:
278 packages.append('Cython.Debugger')
b9c4e647 »
2010-12-09 Debugging test package in setup.py.
279 packages.append('Cython.Debugger.Tests')
38a051cb »
2011-01-16 missing package data files for gdb support tests
280 # it's enough to do this for Py2.5+:
281 setup_args['package_data']['Cython.Debugger.Tests'] = ['codefile', 'cfuncs.c']
282
c4fa206b »
2007-07-28 Initial version
283 setup(
2dc08fb1 »
2009-02-03 build and install "Cython.Runtime.refnanny", use it as a fallback if …
284 name = 'Cython',
c4fa206b »
2007-07-28 Initial version
285 version = version,
286 url = 'http://www.cython.org',
9f2c79e1 »
2011-02-13 meta data update in setup.py
287 author = 'Robert Bradshaw, Stefan Behnel, Dag Seljebotn, Greg Ewing, et al.',
288 author_email = 'cython-devel@python.org',
79c376ec »
2007-07-29 added metadata for Cheeseshop
289 description = "The Cython compiler for writing C extensions for the Python language.",
290 long_description = """\
291 The Cython language makes writing C extensions for the Python language as
292 easy as Python itself. Cython is a source code translator based on the
293 well-known Pyrex_, but supports more cutting edge functionality and
294 optimizations.
295
296 The Cython language is very close to the Python language (and most Python
297 code is also valid Cython code), but Cython additionally supports calling C
298 functions and declaring C types on variables and class attributes. This
299 allows the compiler to generate very efficient C code from Cython code.
300
301 This makes Cython the ideal language for writing glue code for external C
302 libraries, and for fast C modules that speed up the execution of Python
303 code.
304
305 .. _Pyrex: http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/
306 """,
307 classifiers = [
308 "Development Status :: 5 - Production/Stable",
309 "Intended Audience :: Developers",
e10b4dae »
2009-01-16 fixed license reference in setup.py
310 "License :: OSI Approved :: Apache Software License",
79c376ec »
2007-07-29 added metadata for Cheeseshop
311 "Operating System :: OS Independent",
312 "Programming Language :: Python",
8ba61dc5 »
2009-08-21 Cython is basically Py3 clean
313 "Programming Language :: Python :: 2",
314 "Programming Language :: Python :: 3",
9cc67e6d »
2007-12-29 misc updates
315 "Programming Language :: C",
bf0af312 »
2009-03-28 Add trove classifier "Programming Language :: Cython"
316 "Programming Language :: Cython",
79c376ec »
2007-07-29 added metadata for Cheeseshop
317 "Topic :: Software Development :: Code Generators",
318 "Topic :: Software Development :: Compilers",
319 "Topic :: Software Development :: Libraries :: Python Modules"
320 ],
321
c4fa206b »
2007-07-28 Initial version
322 scripts = scripts,
c12526e9 »
2010-12-01 Excluded cygdb from python 2.3 and 2.4 installations and made it 2.5 …
323 packages=packages,
2dc08fb1 »
2009-02-03 build and install "Cython.Runtime.refnanny", use it as a fallback if …
324
a91171e1 »
2008-08-16 Better setup.py pyximport installation
325 # pyximport
a7b92caa »
2008-10-03 [Cython] PATCH: fix pyximport installation as a package
326 py_modules = ["pyximport/__init__",
327 "pyximport/pyximport",
2dc08fb1 »
2009-02-03 build and install "Cython.Runtime.refnanny", use it as a fallback if …
328 "pyximport/pyxbuild",
329
7c283459 »
2009-01-14 install cython.py for pure python mode use
330 "cython"],
2dc08fb1 »
2009-02-03 build and install "Cython.Runtime.refnanny", use it as a fallback if …
331
655041eb »
2007-07-30 fix target directory for Lexicon.pickle (do it right this time)
332 **setup_args
c4fa206b »
2007-07-28 Initial version
333 )
Something went wrong with that request. Please try again.