Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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