Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(15)

Delta Between Two Patch Sets: setup.py

Issue 3871: cross and native build of python for mingw32 with distutils
Left Patch Set: Created 9 years, 5 months ago
Right Patch Set: Created 7 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « setup_info.in ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # Autodetecting setup.py script for building the Python extensions 1 # Autodetecting setup.py script for building the Python extensions
2 # 2 #
3
4 __version__ = "$Revision$"
5 3
6 import sys, os, imp, re, optparse 4 import sys, os, imp, re, optparse
7 from glob import glob 5 from glob import glob
8 import sysconfig 6 import sysconfig
9 7
10 from distutils import log 8 from distutils import log
11 from distutils import text_file 9 from distutils import text_file
12 from distutils.errors import * 10 from distutils.errors import *
13 from distutils.core import Extension, setup 11 from distutils.core import Extension, setup
14 from distutils.command.build_ext import build_ext 12 from distutils.command.build_ext import build_ext
15 from distutils.command.install import install 13 from distutils.command.install import install
16 from distutils.command.install_lib import install_lib 14 from distutils.command.install_lib import install_lib
15 from distutils.command.build_scripts import build_scripts
17 from distutils.spawn import find_executable 16 from distutils.spawn import find_executable
18 from distutils.util import msysize 17
18 cross_compiling = "_PYTHON_HOST_PLATFORM" in os.environ
19
20 def get_platform():
21 # cross build
22 if "_PYTHON_HOST_PLATFORM" in os.environ:
23 return os.environ["_PYTHON_HOST_PLATFORM"]
24 # Get value of sys.platform
25 if sys.platform.startswith('osf1'):
26 return 'osf1'
27 return sys.platform
28 host_platform = get_platform()
19 29
20 # Were we compiled --with-pydebug or with #define Py_DEBUG? 30 # Were we compiled --with-pydebug or with #define Py_DEBUG?
21 COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount') 31 COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_AR GS"))
22 32
23 # This global variable is used to hold the list of modules to be disabled. 33 # This global variable is used to hold the list of modules to be disabled.
24 disabled_module_list = [] 34 disabled_module_list = []
25 35
26 def add_dir_to_list(dirlist, dir): 36 def add_dir_to_list(dirlist, dir):
27 """Add the directory 'dir' to the list 'dirlist' (at the front) if 37 """Add the directory 'dir' to the list 'dirlist' (after any relative
38 directories) if:
39
28 1) 'dir' is not already in 'dirlist' 40 1) 'dir' is not already in 'dirlist'
29 2) 'dir' actually exists, and is a directory.""" 41 2) 'dir' actually exists, and is a directory.
30 if dir is not None and os.path.isdir(dir) and dir not in dirlist: 42 """
31 dirlist.insert(0, dir) 43 if dir is None or not os.path.isdir(dir) or dir in dirlist:
44 return
45 for i, path in enumerate(dirlist):
46 if not os.path.isabs(path):
47 dirlist.insert(i + 1, dir)
48 return
49 dirlist.insert(0, dir)
32 50
33 def macosx_sdk_root(): 51 def macosx_sdk_root():
34 """ 52 """
35 Return the directory of the current OSX SDK, 53 Return the directory of the current OSX SDK,
36 or '/' if no SDK was specified. 54 or '/' if no SDK was specified.
37 """ 55 """
38 cflags = sysconfig.get_config_var('CFLAGS') 56 cflags = sysconfig.get_config_var('CFLAGS')
39 m = re.search(r'-isysroot\s+(\S+)', cflags) 57 m = re.search(r'-isysroot\s+(\S+)', cflags)
40 if m is None: 58 if m is None:
41 sysroot = '/' 59 sysroot = '/'
42 else: 60 else:
43 sysroot = m.group(1) 61 sysroot = m.group(1)
44 return sysroot 62 return sysroot
45 63
46 def is_macosx_sdk_path(path): 64 def is_macosx_sdk_path(path):
47 """ 65 """
48 Returns True if 'path' can be located in an OSX SDK 66 Returns True if 'path' can be located in an OSX SDK
49 """ 67 """
50 return (path.startswith('/usr/') and not path.startswith('/usr/local')) or p ath.startswith('/System/') 68 return ( (path.startswith('/usr/') and not path.startswith('/usr/local'))
69 or path.startswith('/System/')
70 or path.startswith('/Library/') )
51 71
52 def find_file(filename, std_dirs, paths): 72 def find_file(filename, std_dirs, paths):
53 """Searches for the directory where a given file is located, 73 """Searches for the directory where a given file is located,
54 and returns a possibly-empty list of additional directories, or None 74 and returns a possibly-empty list of additional directories, or None
55 if the file couldn't be found at all. 75 if the file couldn't be found at all.
56 76
57 'filename' is the name of a file, such as readline.h or libcrypto.a. 77 'filename' is the name of a file, such as readline.h or libcrypto.a.
58 'std_dirs' is the list of standard system directories; if the 78 'std_dirs' is the list of standard system directories; if the
59 file is found in one of them, no additional directives are needed. 79 file is found in one of them, no additional directives are needed.
60 'paths' is a list of additional locations to check; if the file is 80 'paths' is a list of additional locations to check; if the file is
61 found in one of them, the resulting list will contain the directory. 81 found in one of them, the resulting list will contain the directory.
62 """ 82 """
63 if sys.platform == 'darwin': 83 if host_platform == 'darwin':
64 # Honor the MacOSX SDK setting when one was specified. 84 # Honor the MacOSX SDK setting when one was specified.
65 # An SDK is a directory with the same structure as a real 85 # An SDK is a directory with the same structure as a real
66 # system, but with only header files and libraries. 86 # system, but with only header files and libraries.
67 sysroot = macosx_sdk_root() 87 sysroot = macosx_sdk_root()
68 88
69 # Check the standard locations 89 # Check the standard locations
70 for dir in std_dirs: 90 for dir in std_dirs:
71 f = os.path.join(dir, filename) 91 f = os.path.join(dir, filename)
72 92
73 if sys.platform == 'darwin' and is_macosx_sdk_path(dir): 93 if host_platform == 'darwin' and is_macosx_sdk_path(dir):
74 f = os.path.join(sysroot, dir[1:], filename) 94 f = os.path.join(sysroot, dir[1:], filename)
75 95
76 if os.path.exists(f): return [] 96 if os.path.exists(f): return []
77 97
78 # Check the additional directories 98 # Check the additional directories
79 for dir in paths: 99 for dir in paths:
80 f = os.path.join(dir, filename) 100 f = os.path.join(dir, filename)
81 101
82 if sys.platform == 'darwin' and is_macosx_sdk_path(dir): 102 if host_platform == 'darwin' and is_macosx_sdk_path(dir):
83 f = os.path.join(sysroot, dir[1:], filename) 103 f = os.path.join(sysroot, dir[1:], filename)
84 104
85 if os.path.exists(f): 105 if os.path.exists(f):
86 return [dir] 106 return [dir]
87 107
88 # Not found anywhere 108 # Not found anywhere
89 return None 109 return None
90 110
91 def find_library_file(compiler, libname, std_dirs, paths): 111 def find_library_file(compiler, libname, std_dirs, paths):
92 result = compiler.find_library_file(std_dirs + paths, libname) 112 result = compiler.find_library_file(std_dirs + paths, libname)
93 if result is None: 113 if result is None:
94 return None 114 return None
95 115
96 if sys.platform == 'darwin': 116 if host_platform == 'darwin':
97 sysroot = macosx_sdk_root() 117 sysroot = macosx_sdk_root()
98 118
99 # Check whether the found file is in one of the standard directories 119 # Check whether the found file is in one of the standard directories
100 dirname = os.path.dirname(result) 120 dirname = os.path.dirname(result)
101 for p in std_dirs: 121 for p in std_dirs:
102 # Ensure path doesn't end with path separator 122 # Ensure path doesn't end with path separator
103 p = p.rstrip(os.sep) 123 p = p.rstrip(os.sep)
104 124
105 if sys.platform == 'darwin' and is_macosx_sdk_path(p): 125 if host_platform == 'darwin' and is_macosx_sdk_path(p):
106 if os.path.join(sysroot, p[1:]) == dirname: 126 if os.path.join(sysroot, p[1:]) == dirname:
107 return [ ] 127 return [ ]
108 128
109 if p == dirname: 129 if p == dirname:
110 return [ ] 130 return [ ]
111 131
112 # Otherwise, it must have been in one of the additional directories, 132 # Otherwise, it must have been in one of the additional directories,
113 # so we have to figure out which one. 133 # so we have to figure out which one.
114 for p in paths: 134 for p in paths:
115 # Ensure path doesn't end with path separator 135 # Ensure path doesn't end with path separator
116 p = p.rstrip(os.sep) 136 p = p.rstrip(os.sep)
117 137
118 if sys.platform == 'darwin' and is_macosx_sdk_path(p): 138 if host_platform == 'darwin' and is_macosx_sdk_path(p):
119 if os.path.join(sysroot, p[1:]) == dirname: 139 if os.path.join(sysroot, p[1:]) == dirname:
120 return [ p ] 140 return [ p ]
121 141
122 if p == dirname: 142 if p == dirname:
123 return [p] 143 return [p]
124 else: 144 else:
125 assert False, "Internal error: Path not found in std_dirs or paths" 145 assert False, "Internal error: Path not found in std_dirs or paths"
126 146
127 def module_enabled(extlist, modname): 147 def module_enabled(extlist, modname):
128 """Returns whether the module 'modname' is present in the list 148 """Returns whether the module 'modname' is present in the list
(...skipping 13 matching lines...) Expand all
142 162
143 class PyBuildExt(build_ext): 163 class PyBuildExt(build_ext):
144 164
145 def __init__(self, dist): 165 def __init__(self, dist):
146 build_ext.__init__(self, dist) 166 build_ext.__init__(self, dist)
147 self.failed = [] 167 self.failed = []
148 168
149 def build_extensions(self): 169 def build_extensions(self):
150 170
151 # Detect which modules should be compiled 171 # Detect which modules should be compiled
152 missing = self.detect_modules() 172 old_so = self.compiler.shared_lib_extension
173 # Workaround PEP 3149 stuff
174 self.compiler.shared_lib_extension = os.environ.get("SO", ".so")
175 try:
176 missing = self.detect_modules()
177 finally:
178 self.compiler.shared_lib_extension = old_so
153 179
154 # Remove modules that are present on the disabled list 180 # Remove modules that are present on the disabled list
155 extensions = [ext for ext in self.extensions 181 extensions = [ext for ext in self.extensions
156 if ext.name not in disabled_module_list] 182 if ext.name not in disabled_module_list]
157 # move ctypes to the end, it depends on other modules 183 # move ctypes to the end, it depends on other modules
158 ext_map = dict((ext.name, i) for i, ext in enumerate(extensions)) 184 ext_map = dict((ext.name, i) for i, ext in enumerate(extensions))
159 if "_ctypes" in ext_map: 185 if "_ctypes" in ext_map:
160 ctypes = extensions.pop(ext_map["_ctypes"]) 186 ctypes = extensions.pop(ext_map["_ctypes"])
161 extensions.append(ctypes) 187 extensions.append(ctypes)
162 self.extensions = extensions 188 self.extensions = extensions
163 189
164 # Fix up the autodetected modules, prefixing all the source files 190 # Fix up the autodetected modules, prefixing all the source files
165 # with Modules/. 191 # with Modules/.
166 srcdir = sysconfig.get_config_var('srcdir') 192 srcdir = sysconfig.get_config_var('srcdir')
167 if not srcdir: 193 if not srcdir:
168 # Maybe running on Windows but not using CYGWIN? 194 # Maybe running on Windows but not using posix build?
169 raise ValueError("No source directory; cannot proceed.") 195 raise ValueError("No source directory; cannot proceed.")
170 srcdir = os.path.abspath(srcdir) 196 srcdir = os.path.abspath(srcdir)
171 moddirlist = [os.path.join(srcdir, 'Modules')] 197 moddirlist = [os.path.join(srcdir, 'Modules')]
172 198
173 # Platform-dependent module source and include directories
174 platform = self.get_platform()
175
176 # Fix up the paths for scripts, too 199 # Fix up the paths for scripts, too
177 self.distribution.scripts = [os.path.join(srcdir, filename) 200 self.distribution.scripts = [os.path.join(srcdir, filename)
178 for filename in self.distribution.scripts] 201 for filename in self.distribution.scripts]
179 202
180 # Python header files 203 # Python header files
181 headers = [sysconfig.get_config_h_filename()] 204 headers = [sysconfig.get_config_h_filename()]
182 headers += glob(os.path.join(sysconfig.get_path('platinclude'), "*.h")) 205 headers += glob(os.path.join(sysconfig.get_path('include'), "*.h"))
183 206
184 for ext in self.extensions[:]: 207 for ext in self.extensions[:]:
185 ext.sources = [ find_module_file(filename, moddirlist) 208 ext.sources = [ find_module_file(filename, moddirlist)
186 for filename in ext.sources ] 209 for filename in ext.sources ]
187 if ext.depends is not None: 210 if ext.depends is not None:
188 ext.depends = [find_module_file(filename, moddirlist) 211 ext.depends = [find_module_file(filename, moddirlist)
189 for filename in ext.depends] 212 for filename in ext.depends]
190 else: 213 else:
191 ext.depends = [] 214 ext.depends = []
192 # re-compile extensions if a header file has been changed 215 # re-compile extensions if a header file has been changed
(...skipping 22 matching lines...) Expand all
215 238
216 # When you run "make CC=altcc" or something similar, you really want 239 # When you run "make CC=altcc" or something similar, you really want
217 # those environment variables passed into the setup.py phase. Here's 240 # those environment variables passed into the setup.py phase. Here's
218 # a small set of useful ones. 241 # a small set of useful ones.
219 compiler = os.environ.get('CC') 242 compiler = os.environ.get('CC')
220 args = {} 243 args = {}
221 # unfortunately, distutils doesn't let us provide separate C and C++ 244 # unfortunately, distutils doesn't let us provide separate C and C++
222 # compilers 245 # compilers
223 if compiler is not None: 246 if compiler is not None:
224 (ccshared,cflags) = sysconfig.get_config_vars('CCSHARED','CFLAGS') 247 (ccshared,cflags) = sysconfig.get_config_vars('CCSHARED','CFLAGS')
225 args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags 248 # distutils set first cflags then ccshared
226 self.compiler.set_executables(**args) 249 args['compiler_so'] = compiler + ' ' + cflags + ' ' + ccshared
250
251 # FIXME: Is next correct ?
252 # To link modules we need LDSHARED passed to setup.py otherwise
253 # distutils will use linker from build system if cross-compiling.
254 linker_so = os.environ.get('LDSHARED')
255 if linker_so is not None:
256 args['linker_so'] = linker_so
257
258 #NO. lines above just override already customised compiler values
259 #self.compiler.set_executables(**args)
260
261 if host_platform in ['mingw', 'win32']:
262 data = open('pyconfig.h').read()
263 m = re.search(r"#s*define\s+Py_DEBUG\s+1\s*", data)
264 if m is not None:
265 self.compiler.libraries.append("python" + str(sysconfig.get_conf ig_var('VERSION')) + "_d")
266 else:
267 self.compiler.libraries.append("python" + str(sysconfig.get_conf ig_var('VERSION')))
268
269 if host_platform in ['mingw', 'win32']:
270 # NOTE: See comment for SHLIBS in configure.in .
271 # Although it look obsolete since setup.py add module
272 # required libraries we will pass list too.
273 # As example this will allow us to propage static
274 # libraries like mingwex to modules.
275 for lib in sysconfig.get_config_var('SHLIBS').split():
276 if lib.startswith('-l'):
277 self.compiler.libraries.append(lib[2:])
278 else:
279 self.compiler.libraries.append(lib)
227 280
228 build_ext.build_extensions(self) 281 build_ext.build_extensions(self)
229 282
230 longest = max([len(e.name) for e in self.extensions]) 283 longest = max([len(e.name) for e in self.extensions])
231 if self.failed: 284 if self.failed:
232 longest = max(longest, max([len(name) for name in self.failed])) 285 longest = max(longest, max([len(name) for name in self.failed]))
233 286
234 def print_three_column(lst): 287 def print_three_column(lst):
235 lst.sort(key=str.lower) 288 lst.sort(key=str.lower)
236 # guarantee zip() doesn't drop anything 289 # guarantee zip() doesn't drop anything
(...skipping 13 matching lines...) Expand all
250 print() 303 print()
251 304
252 if self.failed: 305 if self.failed:
253 failed = self.failed[:] 306 failed = self.failed[:]
254 print() 307 print()
255 print("Failed to build these modules:") 308 print("Failed to build these modules:")
256 print_three_column(failed) 309 print_three_column(failed)
257 print() 310 print()
258 311
259 def build_extension(self, ext): 312 def build_extension(self, ext):
313
260 if ext.name == '_ctypes': 314 if ext.name == '_ctypes':
261 if not self.configure_ctypes(ext): 315 if not self.configure_ctypes(ext):
262 return 316 return
263 317
264 try: 318 try:
265 build_ext.build_extension(self, ext) 319 build_ext.build_extension(self, ext)
266 except (CCompilerError, DistutilsError) as why: 320 except (CCompilerError, DistutilsError) as why:
267 self.announce('WARNING: building of extension "%s" failed: %s' % 321 self.announce('WARNING: building of extension "%s" failed: %s' %
268 (ext.name, sys.exc_info()[1])) 322 (ext.name, sys.exc_info()[1]))
269 self.failed.append(ext.name) 323 self.failed.append(ext.name)
270 return 324 return
271 # Workaround for Mac OS X: The Carbon-based modules cannot be 325 # Workaround for Mac OS X: The Carbon-based modules cannot be
272 # reliably imported into a command-line Python 326 # reliably imported into a command-line Python
273 if 'Carbon' in ext.extra_link_args: 327 if 'Carbon' in ext.extra_link_args:
274 self.announce( 328 self.announce(
275 'WARNING: skipping import check for Carbon-based "%s"' % 329 'WARNING: skipping import check for Carbon-based "%s"' %
276 ext.name) 330 ext.name)
277 return 331 return
278 332
279 if self.get_platform() == 'darwin' and ( 333 if host_platform == 'darwin' and (
280 sys.maxsize > 2**32 and '-arch' in ext.extra_link_args): 334 sys.maxsize > 2**32 and '-arch' in ext.extra_link_args):
281 # Don't bother doing an import check when an extension was 335 # Don't bother doing an import check when an extension was
282 # build with an explicit '-arch' flag on OSX. That's currently 336 # build with an explicit '-arch' flag on OSX. That's currently
283 # only used to build 32-bit only extensions in a 4-way 337 # only used to build 32-bit only extensions in a 4-way
284 # universal build and loading 32-bit code into a 64-bit 338 # universal build and loading 32-bit code into a 64-bit
285 # process will fail. 339 # process will fail.
286 self.announce( 340 self.announce(
287 'WARNING: skipping import check for "%s"' % 341 'WARNING: skipping import check for "%s"' %
288 ext.name) 342 ext.name)
289 return 343 return
290 344
291 # Workaround for Cygwin: Cygwin currently has fork issues when many 345 # Workaround for Cygwin: Cygwin currently has fork issues when many
292 # modules have been imported 346 # modules have been imported
293 if self.get_platform() == 'cygwin': 347 if host_platform == 'cygwin':
294 self.announce('WARNING: skipping import check for Cygwin-based "%s"' 348 self.announce('WARNING: skipping import check for Cygwin-based "%s"'
349 % ext.name)
350 return
351 if cross_compiling:
352 self.announce('WARNING: skipping import check for cross-compiled "%s "'
295 % ext.name) 353 % ext.name)
296 return 354 return
297 ext_filename = os.path.join( 355 ext_filename = os.path.join(
298 self.build_lib, 356 self.build_lib,
299 self.get_ext_filename(self.get_ext_fullname(ext.name))) 357 self.get_ext_filename(self.get_ext_fullname(ext.name)))
300 358
301 # If the build directory didn't exist when setup.py was 359 # If the build directory didn't exist when setup.py was
302 # started, sys.path_importer_cache has a negative result 360 # started, sys.path_importer_cache has a negative result
303 # cached. Clear that cache before trying to import. 361 # cached. Clear that cache before trying to import.
304 sys.path_importer_cache.clear() 362 sys.path_importer_cache.clear()
305 363
306 # Add the module's location to sys.path in case it tries to 364 # Don't try to load extensions for cross builds
307 # import itself recursively (multiprocessing does that) 365 if cross_compiling:
308 sys.path.append (os.path.dirname (ext_filename)) 366 return
309 367
310 try: 368 try:
311 imp.load_dynamic(ext.name, ext_filename) 369 imp.load_dynamic(ext.name, ext_filename)
312 except ImportError as why: 370 except ImportError as why:
313 self.failed.append(ext.name) 371 self.failed.append(ext.name)
314 self.announce('*** WARNING: renaming "%s" since importing it' 372 self.announce('*** WARNING: renaming "%s" since importing it'
315 ' failed: %s' % (ext.name, why), level=3) 373 ' failed: %s' % (ext.name, why), level=3)
316 assert not self.inplace 374 assert not self.inplace
317 basename, tail = os.path.splitext(ext_filename) 375 basename, tail = os.path.splitext(ext_filename)
318 newname = basename + "_failed" + tail 376 newname = basename + "_failed" + tail
(...skipping 12 matching lines...) Expand all
331 os.remove(filename) 389 os.remove(filename)
332 except AttributeError: 390 except AttributeError:
333 self.announce('unable to remove files (ignored)') 391 self.announce('unable to remove files (ignored)')
334 except: 392 except:
335 exc_type, why, tb = sys.exc_info() 393 exc_type, why, tb = sys.exc_info()
336 self.announce('*** WARNING: importing extension "%s" ' 394 self.announce('*** WARNING: importing extension "%s" '
337 'failed with %s: %s' % (ext.name, exc_type, why), 395 'failed with %s: %s' % (ext.name, exc_type, why),
338 level=3) 396 level=3)
339 self.failed.append(ext.name) 397 self.failed.append(ext.name)
340 398
341 def get_platform(self): 399 def add_multiarch_paths(self):
342 # Get value of sys.platform 400 # Debian/Ubuntu multiarch support.
343 for platform in ['cygwin', 'darwin', 'osf1']: 401 # https://wiki.ubuntu.com/MultiarchSpec
344 if sys.platform.startswith(platform): 402 cc = sysconfig.get_config_var('CC')
345 return platform 403 tmpfile = os.path.join(self.build_temp, 'multiarch')
346 return sys.platform 404 if not os.path.exists(self.build_temp):
405 os.makedirs(self.build_temp)
406 ret = os.system(
407 '%s -print-multiarch > %s 2> /dev/null' % (cc, tmpfile))
408 multiarch_path_component = ''
409 try:
410 if ret >> 8 == 0:
411 with open(tmpfile) as fp:
412 multiarch_path_component = fp.readline().strip()
413 finally:
414 os.unlink(tmpfile)
415
416 if multiarch_path_component != '':
417 add_dir_to_list(self.compiler.library_dirs,
418 '/usr/lib/' + multiarch_path_component)
419 add_dir_to_list(self.compiler.include_dirs,
420 '/usr/include/' + multiarch_path_component)
421 return
422
423 if not find_executable('dpkg-architecture'):
424 return
425 opt = ''
426 if cross_compiling:
427 opt = '-t' + sysconfig.get_config_var('HOST_GNU_TYPE')
428 tmpfile = os.path.join(self.build_temp, 'multiarch')
429 if not os.path.exists(self.build_temp):
430 os.makedirs(self.build_temp)
431 ret = os.system(
432 'dpkg-architecture %s -qDEB_HOST_MULTIARCH > %s 2> /dev/null' %
433 (opt, tmpfile))
434 try:
435 if ret >> 8 == 0:
436 with open(tmpfile) as fp:
437 multiarch_path_component = fp.readline().strip()
438 add_dir_to_list(self.compiler.library_dirs,
439 '/usr/lib/' + multiarch_path_component)
440 add_dir_to_list(self.compiler.include_dirs,
441 '/usr/include/' + multiarch_path_component)
442 finally:
443 os.unlink(tmpfile)
444
445 def add_gcc_paths(self):
446 gcc = sysconfig.get_config_var('CC')
447 tmpfile = os.path.join(self.build_temp, 'gccpaths')
448 if not os.path.exists(self.build_temp):
449 os.makedirs(self.build_temp)
450 ret = os.system('%s -E -v - </dev/null 2>%s 1>/dev/null' % (gcc, tmpfile ))
451 is_gcc = False
452 in_incdirs = False
453 inc_dirs = []
454 lib_dirs = []
455 try:
456 if ret >> 8 == 0:
457 with open(tmpfile) as fp:
458 for line in fp.readlines():
459 if line.startswith("gcc version"):
460 is_gcc = True
461 elif line.startswith("#include <...>"):
462 in_incdirs = True
463 elif line.startswith("End of search list"):
464 in_incdirs = False
465 elif is_gcc and line.startswith("LIBRARY_PATH"):
466 for d in line.strip().split("=")[1].split(":"):
467 d = os.path.normpath(d)
468 if '/gcc/' not in d:
469 add_dir_to_list(self.compiler.library_dirs,
470 d)
471 elif is_gcc and in_incdirs and '/gcc/' not in line:
472 add_dir_to_list(self.compiler.include_dirs,
473 line.strip())
474 finally:
475 os.unlink(tmpfile)
347 476
348 def detect_modules(self): 477 def detect_modules(self):
349 # Ensure that /usr/local is always used 478 pyconfig_h_data = open('pyconfig.h').read()
350 add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') 479 setup_info_data = open('setup_info').read()
351 add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') 480
481 # Ensure that /usr/local is always used, but the local build
482 # directories (i.e. '.' and 'Include') must be first. See issue
483 # 10520.
484 if not cross_compiling:
485 add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
486 add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
487 # only change this for cross builds for 3.3, issues on Mageia
488 if cross_compiling:
489 self.add_gcc_paths()
490 self.add_multiarch_paths()
352 491
353 # Add paths specified in the environment variables LDFLAGS and 492 # Add paths specified in the environment variables LDFLAGS and
354 # CPPFLAGS for header and library files. 493 # CPPFLAGS for header and library files.
355 # We must get the values from the Makefile and not the environment 494 # We must get the values from the Makefile and not the environment
356 # directly since an inconsistently reproducible issue comes up where 495 # directly since an inconsistently reproducible issue comes up where
357 # the environment variable is not set even though the value were passed 496 # the environment variable is not set even though the value were passed
358 # into configure and stored in the Makefile (issue found on OS X 10.3). 497 # into configure and stored in the Makefile (issue found on OS X 10.3).
359 for env_var, arg_name, dir_list in ( 498 for env_var, arg_name, dir_list in (
360 ('LDFLAGS', '-R', self.compiler.runtime_library_dirs), 499 ('LDFLAGS', '-R', self.compiler.runtime_library_dirs),
361 ('LDFLAGS', '-L', self.compiler.library_dirs), 500 ('LDFLAGS', '-L', self.compiler.library_dirs),
(...skipping 15 matching lines...) Expand all
377 # Make sure that allowing args interspersed with options is 516 # Make sure that allowing args interspersed with options is
378 # allowed 517 # allowed
379 parser.allow_interspersed_args = True 518 parser.allow_interspersed_args = True
380 parser.error = lambda msg: None 519 parser.error = lambda msg: None
381 parser.add_option(arg_name, dest="dirs", action="append") 520 parser.add_option(arg_name, dest="dirs", action="append")
382 options = parser.parse_args(env_val.split())[0] 521 options = parser.parse_args(env_val.split())[0]
383 if options.dirs: 522 if options.dirs:
384 for directory in reversed(options.dirs): 523 for directory in reversed(options.dirs):
385 add_dir_to_list(dir_list, directory) 524 add_dir_to_list(dir_list, directory)
386 525
387 if os.path.normpath(sys.prefix) != '/usr': 526 if os.path.normpath(sys.base_prefix) != '/usr' \
527 and not sysconfig.get_config_var('PYTHONFRAMEWORK'):
528 # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework
529 # (PYTHONFRAMEWORK is set) to avoid # linking problems when
530 # building a framework with different architectures than
531 # the one that is currently installed (issue #7473)
532 # NOTE: revision 25103:[ #420565 ] add search in sys.prefix
533 # before current source tree !?!?!?! No comment!
534 # Since add_dir_to_list prepend path issue with library paths
535 # is silently fixed ;) but introduce new one for header paths
536 # as path must be appended !
388 add_dir_to_list(self.compiler.library_dirs, 537 add_dir_to_list(self.compiler.library_dirs,
389 sysconfig.get_config_var("LIBDIR")) 538 sysconfig.get_config_var("LIBDIR"))
390 add_dir_to_list(self.compiler.include_dirs, 539 add_dir_to_list(self.compiler.include_dirs,
391 sysconfig.get_config_var("INCLUDEDIR")) 540 sysconfig.get_config_var("INCLUDEDIR"))
392 541
393 # lib_dirs and inc_dirs are used to search for files; 542 # lib_dirs and inc_dirs are used to search for files;
394 # if a file is found in one of those directories, it can 543 # if a file is found in one of those directories, it can
395 # be assumed that no additional -I,-L directives are needed. 544 # be assumed that no additional -I,-L directives are needed.
396 lib_dirs = self.compiler.library_dirs + [ 545 if not cross_compiling:
397 '/lib64', '/usr/lib64', 546 lib_dirs = self.compiler.library_dirs + [
398 '/lib', '/usr/lib', 547 '/lib64', '/usr/lib64',
399 ] 548 '/lib', '/usr/lib',
400 inc_dirs = self.compiler.include_dirs + ['/usr/include'] 549 ]
550 inc_dirs = self.compiler.include_dirs + ['/usr/include']
551 else:
552 lib_dirs = self.compiler.library_dirs[:]
553 inc_dirs = self.compiler.include_dirs[:]
401 exts = [] 554 exts = []
402 missing = [] 555 missing = []
403 556
404 config_h = sysconfig.get_config_h_filename() 557 config_h = sysconfig.get_config_h_filename()
405 config_h_vars = sysconfig.parse_config_h(open(config_h)) 558 with open(config_h) as file:
406 559 config_h_vars = sysconfig.parse_config_h(file)
407 platform = self.get_platform() 560
408 srcdir = sysconfig.get_config_var('srcdir') 561 srcdir = sysconfig.get_config_var('srcdir')
409 562
410 # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb) 563 # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb)
411 if platform in ['osf1', 'unixware7', 'openunix8']: 564 if host_platform in ['osf1', 'unixware7', 'openunix8']:
412 lib_dirs += ['/usr/ccs/lib'] 565 lib_dirs += ['/usr/ccs/lib']
413 566
414 if platform == 'darwin': 567 # HP-UX11iv3 keeps files in lib/hpux folders.
568 if host_platform == 'hp-ux11':
569 lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32']
570
571 if host_platform in ['darwin', 'mingw', 'win32']:
415 # This should work on any unixy platform ;-) 572 # This should work on any unixy platform ;-)
416 # If the user has bothered specifying additional -I and -L flags 573 # If the user has bothered specifying additional -I and -L flags
417 # in OPT and LDFLAGS we might as well use them here. 574 # in OPT and LDFLAGS we might as well use them here.
418 # NOTE: using shlex.split would technically be more correct, but 575 #
419 # also gives a bootstrap problem. Let's hope nobody uses directories 576 # NOTE: using shlex.split would technically be more correct, but
420 # with whitespace in the name to store libraries. 577 # also gives a bootstrap problem. Let's hope nobody uses
578 # directories with whitespace in the name to store libraries.
579 # FIXME: Why LDFLAGS again ?
421 cflags, ldflags = sysconfig.get_config_vars( 580 cflags, ldflags = sysconfig.get_config_vars(
422 'CFLAGS', 'LDFLAGS') 581 'CFLAGS', 'LDFLAGS')
423 for item in cflags.split(): 582 for item in cflags.split():
424 if item.startswith('-I'): 583 if item.startswith('-I'):
425 inc_dirs.append(item[2:]) 584 inc_dirs.append(item[2:])
426 585
427 for item in ldflags.split(): 586 for item in ldflags.split():
428 if item.startswith('-L'): 587 if item.startswith('-L'):
429 lib_dirs.append(item[2:]) 588 lib_dirs.append(item[2:])
430 589
431 # Check for MacOS X, which doesn't need libm.a at all 590 # Check for MacOS X, which doesn't need libm.a at all
432 math_libs = ['m'] 591 math_libs = ['m']
433 if platform == 'darwin': 592 if host_platform in ['darwin', 'mingw', 'win32']:
434 math_libs = [] 593 math_libs = []
435 594
436 # XXX Omitted modules: gl, pure, dl, SGI-specific modules 595 # XXX Omitted modules: gl, pure, dl, SGI-specific modules
437 596
438 # 597 #
439 # The following modules are all pretty straightforward, and compile 598 # The following modules are all pretty straightforward, and compile
440 # on pretty much any POSIXish platform. 599 # on pretty much any POSIXish platform.
441 # 600 #
442
443 # Some modules that are normally always on:
444 exts.append( Extension('_weakref', ['_weakref.c']) )
445 601
446 # array objects 602 # array objects
447 exts.append( Extension('array', ['arraymodule.c']) ) 603 exts.append( Extension('array', ['arraymodule.c']) )
448 # complex math library functions 604 # complex math library functions
449 exts.append( Extension('cmath', ['cmathmodule.c', '_math.c'], 605 exts.append( Extension('cmath', ['cmathmodule.c', '_math.c'],
450 depends=['_math.h'], 606 depends=['_math.h'],
451 libraries=math_libs) ) 607 libraries=math_libs) )
452 # math library functions, e.g. sin() 608 # math library functions, e.g. sin()
453 exts.append( Extension('math', ['mathmodule.c', '_math.c'], 609 exts.append( Extension('math', ['mathmodule.c', '_math.c'],
454 depends=['_math.h'], 610 depends=['_math.h'],
455 libraries=math_libs) ) 611 libraries=math_libs) )
612
613 # time libraries: librt may be needed for clock_gettime()
614 time_libs = []
615 lib = sysconfig.get_config_var('TIMEMODULE_LIB')
616
617 if lib:
618 time_libs.append(lib)
619
456 # time operations and variables 620 # time operations and variables
457 exts.append( Extension('time', ['timemodule.c', '_time.c'], 621 exts.append( Extension('time', ['timemodule.c'],
458 libraries=math_libs) ) 622 libraries=time_libs) )
459 exts.append( Extension('_datetime', ['_datetimemodule.c', '_time.c'], 623 exts.append( Extension('_datetime', ['_datetimemodule.c']) )
460 libraries=math_libs) )
461 # fast iterator tools implemented in C
462 exts.append( Extension("itertools", ["itertoolsmodule.c"]) )
463 # random number generator implemented in C 624 # random number generator implemented in C
464 exts.append( Extension("_random", ["_randommodule.c"]) ) 625 exts.append( Extension("_random", ["_randommodule.c"]) )
465 # high-performance collections
466 exts.append( Extension("_collections", ["_collectionsmodule.c"]) )
467 # bisect 626 # bisect
468 exts.append( Extension("_bisect", ["_bisectmodule.c"]) ) 627 exts.append( Extension("_bisect", ["_bisectmodule.c"]) )
469 # heapq 628 # heapq
470 exts.append( Extension("_heapq", ["_heapqmodule.c"]) ) 629 exts.append( Extension("_heapq", ["_heapqmodule.c"]) )
471 # operator.add() and similar goodies
472 exts.append( Extension('operator', ['operator.c']) )
473 # C-optimized pickle replacement 630 # C-optimized pickle replacement
474 exts.append( Extension("_pickle", ["_pickle.c"]) ) 631 exts.append( Extension("_pickle", ["_pickle.c"]) )
475 # atexit 632 # atexit
476 exts.append( Extension("atexit", ["atexitmodule.c"]) ) 633 exts.append( Extension("atexit", ["atexitmodule.c"]) )
477 # _json speedups 634 # _json speedups
478 exts.append( Extension("_json", ["_json.c"]) ) 635 exts.append( Extension("_json", ["_json.c"]) )
479 # Python C API test module 636 # Python C API test module
480 exts.append( Extension('_testcapi', ['_testcapimodule.c'], 637 exts.append( Extension('_testcapi', ['_testcapimodule.c'],
481 depends=['testcapi_long.h']) ) 638 depends=['testcapi_long.h']) )
639 # Python PEP-3118 (buffer protocol) test module
640 exts.append( Extension('_testbuffer', ['_testbuffer.c']) )
482 # profiler (_lsprof is for cProfile.py) 641 # profiler (_lsprof is for cProfile.py)
483 exts.append( Extension('_lsprof', ['_lsprof.c', 'rotatingtree.c']) ) 642 exts.append( Extension('_lsprof', ['_lsprof.c', 'rotatingtree.c']) )
484 # static Unicode character database 643 # static Unicode character database
485 exts.append( Extension('unicodedata', ['unicodedata.c']) ) 644 exts.append( Extension('unicodedata', ['unicodedata.c']) )
486 645
487 # Modules with some UNIX dependencies -- on by default: 646 # Modules with some UNIX dependencies -- on by default:
488 # (If you have a really backward UNIX, select and socket may not be 647 # (If you have a really backward UNIX, select and socket may not be
489 # supported...) 648 # supported...)
490 649
491 # fcntl(2) and ioctl(2) 650 # fcntl(2) and ioctl(2)
492 if config_h_vars.get('HAVE_SYS_FCNTL_H', False): 651 if host_platform not in ['mingw', 'win32']:
493 exts.append( Extension('fcntl', ['fcntlmodule.c']) ) 652 libs = []
494 else: 653 if (config_h_vars.get('FLOCK_NEEDS_LIBBSD', False)):
495 missing.append('fcntl') 654 # May be necessary on AIX for flock function
496 # pwd(3) 655 libs = ['bsd']
497 if config_h_vars.get('HAVE_PWD_H', False): 656 exts.append( Extension('fcntl', ['fcntlmodule.c'], libraries=libs) )
657 else:
658 missing.append('fcntl')
659 if host_platform not in ['mingw', 'win32']:
660 # pwd(3)
498 exts.append( Extension('pwd', ['pwdmodule.c']) ) 661 exts.append( Extension('pwd', ['pwdmodule.c']) )
499 else: 662 # grp(3)
500 missing.append('pwd')
501 # grp(3)
502 if config_h_vars.get('HAVE_GRP_H', False):
503 exts.append( Extension('grp', ['grpmodule.c']) ) 663 exts.append( Extension('grp', ['grpmodule.c']) )
504 else: 664 # spwd, shadow passwords
505 missing.append('grp') 665 if (config_h_vars.get('HAVE_GETSPNAM', False) or
506 # spwd, shadow passwords 666 config_h_vars.get('HAVE_GETSPENT', False)):
507 if (config_h_vars.get('HAVE_GETSPNAM', False) or 667 exts.append( Extension('spwd', ['spwdmodule.c']) )
508 config_h_vars.get('HAVE_GETSPENT', False)): 668 else:
509 exts.append( Extension('spwd', ['spwdmodule.c']) ) 669 missing.append('spwd')
510 else: 670 else:
511 missing.append('spwd') 671 missing.extend(['pwd', 'grp', 'spwd'])
512 672
513 # select(2); not on ancient System V 673 # select(2); not on ancient System V
674 if host_platform in ['mingw', 'win32']:
675 select_libs = ['ws2_32']
676 else:
677 select_libs = []
514 exts.append( Extension('select', ['selectmodule.c'], 678 exts.append( Extension('select', ['selectmodule.c'],
515 libraries=[] if 'msys' not in sys.builtin_module_names else ['ws 2_32'] 679 libraries=select_libs) )
516 ) )
517 680
518 # Fred Drake's interface to the Python parser 681 # Fred Drake's interface to the Python parser
519 exts.append( Extension('parser', ['parsermodule.c']) ) 682 exts.append( Extension('parser', ['parsermodule.c']) )
520 683
521 # Memory-mapped files (also works on Win32). 684 # Memory-mapped files (also works on Win32).
522 exts.append( Extension('mmap', ['mmapmodule.c']) ) 685 exts.append( Extension('mmap', ['mmapmodule.c']) )
523 686
524 # Lance Ellinghaus's syslog module 687 # Lance Ellinghaus's syslog module
525 # syslog daemon interface 688 if host_platform not in ['mingw', 'win32']:
526 if config_h_vars.get('HAVE_SYSLOG_H', False): 689 # syslog daemon interface
527 exts.append( Extension('syslog', ['syslogmodule.c']) ) 690 exts.append( Extension('syslog', ['syslogmodule.c']) )
528 else: 691 else:
529 missing.append('syslog') 692 missing.append('syslog')
530 693
531 # 694 #
532 # Here ends the simple stuff. From here on, modules need certain 695 # Here ends the simple stuff. From here on, modules need certain
533 # libraries, are platform-specific, or present other surprises. 696 # libraries, are platform-specific, or present other surprises.
534 # 697 #
535 698
536 # Multimedia modules 699 # Multimedia modules
537 # These don't work for 64-bit platforms!!! 700 # These don't work for 64-bit platforms!!!
538 # These represent audio samples or images as strings: 701 # These represent audio samples or images as strings:
539 702
540 # Operations on audio samples 703 # Operations on audio samples
541 # According to #993173, this one should actually work fine on 704 # According to #993173, this one should actually work fine on
542 # 64-bit platforms. 705 # 64-bit platforms.
543 exts.append( Extension('audioop', ['audioop.c']) ) 706 exts.append( Extension('audioop', ['audioop.c']) )
544 707
545 # readline 708 # readline
546 do_readline = self.compiler.find_library_file(lib_dirs, 'readline') 709 do_readline = re.search(r"#s*define\s+HAVE_LIBREADLINE\s+1\s*", pyconfig _h_data)
710
547 readline_termcap_library = "" 711 readline_termcap_library = ""
548 curses_library = "" 712 curses_library = ""
713 # Cannot use os.popen here in py3k.
714 tmpfile = os.path.join(self.build_temp, 'readline_termcap_lib')
715 if not os.path.exists(self.build_temp):
716 os.makedirs(self.build_temp)
549 # Determine if readline is already linked against curses or tinfo. 717 # Determine if readline is already linked against curses or tinfo.
550 if do_readline and find_executable('ldd'): 718 # NOTE readline_termcap_library flag is used only if
551 # Cannot use os.popen here in py3k. 719 # cannot determine readline libs (see configure.in checks)
552 tmpfile = os.path.join(self.build_temp, 'readline_termcap_lib') 720 readline_conf = False
553 if not os.path.exists(self.build_temp): 721 readline_conf_termcap = ""
554 os.makedirs(self.build_temp) 722 if do_readline:
555 ret = os.system("ldd %s > %s" % (do_readline, tmpfile)) 723 m = re.search(
724 r"\s*READLINE_LIBS\s*=\s*(?P<rl>-l.*)",
725 setup_info_data
726 )
727 if m:
728 readline_conf = True
729 ln = m.group('rl')
730 if 'curses' in ln:
731 readline_conf_termcap = re.sub(
732 r'.*-l(n?cursesw?).*', r'\1', ln
733 ).rstrip()
734 elif 'tinfo' in ln: # termcap interface split out from ncurses
735 readline_conf_termcap = 'tinfo'
736 else: # may be readline is linked with termcap interface library
737 readline_conf = False
738
739 if do_readline and not readline_conf and find_executable('ldd'):
740 do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
741 if cross_compiling:
742 ret = os.system("%s -d %s 2>/dev/null | grep '(NEEDED)' > %s" \
743 % (sysconfig.get_config_var('READELF'),
744 do_readline, tmpfile))
745 elif find_executable('ldd'):
746 ret = os.system("ldd %s > %s" % (do_readline, tmpfile))
747 else:
748 ret = 256
556 if ret >> 8 == 0: 749 if ret >> 8 == 0:
557 fp = open(tmpfile) 750 with open(tmpfile) as fp:
558 for ln in fp: 751 for ln in fp:
559 if 'curses' in ln: 752 if 'curses' in ln:
560 readline_termcap_library = re.sub( 753 readline_termcap_library = re.sub(
561 r'.*lib(n?cursesw?)\.so.*', r'\1', ln 754 r'.*lib(n?cursesw?)\.so.*', r'\1', ln
562 ).rstrip() 755 ).rstrip()
563 break 756 break
564 if 'tinfo' in ln: # termcap interface split out from ncurses 757 # termcap interface split out from ncurses
565 readline_termcap_library = 'tinfo' 758 if 'tinfo' in ln:
566 break 759 readline_termcap_library = 'tinfo'
567 fp.close() 760 break
568 os.unlink(tmpfile) 761 if os.path.exists(tmpfile):
762 os.unlink(tmpfile)
569 # Issue 7384: If readline is already linked against curses, 763 # Issue 7384: If readline is already linked against curses,
570 # use the same library for the readline and curses modules. 764 # use the same library for the readline and curses modules.
571 if 'curses' in readline_termcap_library: 765 if 'curses' in readline_conf_termcap:
766 curses_library = readline_conf_termcap
767 elif 'curses' in readline_termcap_library:
572 curses_library = readline_termcap_library 768 curses_library = readline_termcap_library
573 elif self.compiler.find_library_file(lib_dirs, 'ncursesw'): 769 elif self.compiler.find_library_file(lib_dirs, 'ncursesw'):
574 curses_library = 'ncursesw' 770 curses_library = 'ncursesw'
575 elif self.compiler.find_library_file(lib_dirs, 'ncurses'): 771 elif self.compiler.find_library_file(lib_dirs, 'ncurses'):
576 curses_library = 'ncurses' 772 curses_library = 'ncurses'
577 elif self.compiler.find_library_file(lib_dirs, 'curses'): 773 elif self.compiler.find_library_file(lib_dirs, 'curses'):
578 curses_library = 'curses' 774 curses_library = 'curses'
579 775
580 if platform == 'darwin': 776 if host_platform == 'darwin':
581 os_release = int(os.uname()[2].split('.')[0]) 777 os_release = int(os.uname()[2].split('.')[0])
582 dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') 778 dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
583 if dep_target and dep_target.split('.') < ['10', '5']: 779 if dep_target and dep_target.split('.') < ['10', '5']:
584 os_release = 8 780 os_release = 8
585 if os_release < 9: 781 if os_release < 9:
586 # MacOSX 10.4 has a broken readline. Don't try to build 782 # MacOSX 10.4 has a broken readline. Don't try to build
587 # the readline module unless the user has installed a fixed 783 # the readline module unless the user has installed a fixed
588 # readline package 784 # readline package
589 if find_file('readline/rlconf.h', inc_dirs, []) is None: 785 if find_file('readline/rlconf.h', inc_dirs, []) is None:
590 do_readline = False 786 do_readline = False
591 if do_readline: 787 if do_readline:
592 if platform == 'darwin' and os_release < 9: 788 if host_platform == 'darwin' and os_release < 9:
593 # In every directory on the search path search for a dynamic 789 # In every directory on the search path search for a dynamic
594 # library and then a static library, instead of first looking 790 # library and then a static library, instead of first looking
595 # for dynamic libraries on the entire path. 791 # for dynamic libraries on the entire path.
596 # This way a staticly linked custom readline gets picked up 792 # This way a staticly linked custom readline gets picked up
597 # before the (possibly broken) dynamic library in /usr/lib. 793 # before the (possibly broken) dynamic library in /usr/lib.
598 readline_extra_link_args = ('-Wl,-search_paths_first',) 794 readline_extra_link_args = ('-Wl,-search_paths_first',)
599 else: 795 else:
600 readline_extra_link_args = () 796 readline_extra_link_args = ()
601 797
602 readline_libs = ['readline'] 798 readline_libs = ['readline']
603 if readline_termcap_library: 799 if readline_termcap_library:
604 pass # Issue 7384: Already linked against curses or tinfo. 800 pass # Issue 7384: Already linked against curses or tinfo.
605 elif curses_library: 801 elif curses_library:
606 readline_libs.append(curses_library) 802 readline_libs.append(curses_library)
607 elif self.compiler.find_library_file(lib_dirs + 803 elif self.compiler.find_library_file(lib_dirs +
608 ['/usr/lib/termcap'], 804 ['/usr/lib/termcap'],
609 'termcap'): 805 'termcap'):
610 readline_libs.append('termcap') 806 readline_libs.append('termcap')
611 exts.append( Extension('readline', ['readline.c'], 807 exts.append( Extension('readline', ['readline.c'],
612 library_dirs=['/usr/lib/termcap'], 808 library_dirs=['/usr/lib/termcap'],
613 extra_link_args=readline_extra_link_args, 809 extra_link_args=readline_extra_link_args,
614 libraries=readline_libs) ) 810 libraries=readline_libs) )
615 else: 811 else:
616 missing.append('readline') 812 missing.append('readline')
617 813
618 # crypt module. 814 # crypt module.
619 815
620 if self.compiler.find_library_file(lib_dirs, 'crypt'): 816 if host_platform not in ['mingw', 'win32']:
621 libs = ['crypt'] 817 if self.compiler.find_library_file(lib_dirs, 'crypt'):
622 else: 818 libs = ['crypt']
623 libs = [] 819 else:
624 if 'msys' not in sys.builtin_module_names: 820 libs = []
625 exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) ) 821 exts.append( Extension('_crypt', ['_cryptmodule.c'], libraries=libs) )
626 else: 822 else:
627 missing.append('crypt') 823 missing.append('_crypt')
628 824
629 # CSV files 825 # CSV files
630 exts.append( Extension('_csv', ['_csv.c']) ) 826 exts.append( Extension('_csv', ['_csv.c']) )
631 827
632 # POSIX subprocess module helper. 828 # POSIX subprocess module helper.
633 if config_h_vars.get('HAVE_FORK', False): 829 if host_platform not in ['mingw', 'win32']:
634 exts.append( Extension('_posixsubprocess', ['_posixsubprocess.c']) ) 830 exts.append( Extension('_posixsubprocess', ['_posixsubprocess.c']) )
635 else: 831 else:
636 missing.append('_posixsubprocess') 832 missing.append('_posixsubprocess')
637 if sys.platform == 'win32':
638 exts.append( Extension('_subprocess', ['PC/_subprocess.c']) )
639 833
640 # socket(2) 834 # socket(2)
835 if host_platform in ['mingw', 'win32']:
836 socket_libs = ['ws2_32']
837 else:
838 socket_libs = []
641 exts.append( Extension('_socket', ['socketmodule.c'], 839 exts.append( Extension('_socket', ['socketmodule.c'],
642 depends = ['socketmodule.h'], 840 libraries=socket_libs,
643 libraries=[] if 'msys' not in sys.builtin_module_ names else ['ws2_32']) ) 841 depends = ['socketmodule.h']) )
644 # Detect SSL support for the socket module (via _ssl) 842 # Detect SSL support for the socket module (via _ssl)
645 search_for_ssl_incs_in = [ 843 search_for_ssl_incs_in = [
646 '/usr/local/ssl/include', 844 '/usr/local/ssl/include',
647 '/usr/contrib/ssl/include/' 845 '/usr/contrib/ssl/include/'
648 ] 846 ]
649 ssl_incs = find_file('openssl/ssl.h', inc_dirs, 847 ssl_incs = find_file('openssl/ssl.h', inc_dirs,
650 search_for_ssl_incs_in 848 search_for_ssl_incs_in
651 ) 849 )
652 if ssl_incs is not None: 850 if ssl_incs is not None:
653 krb5_h = find_file('krb5.h', inc_dirs, 851 krb5_h = find_file('krb5.h', inc_dirs,
654 ['/usr/kerberos/include']) 852 ['/usr/kerberos/include'])
655 if krb5_h: 853 if krb5_h:
656 ssl_incs += krb5_h 854 ssl_incs += krb5_h
657 ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs, 855 ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
658 ['/usr/local/ssl/lib', 856 ['/usr/local/ssl/lib',
659 '/usr/contrib/ssl/lib/' 857 '/usr/contrib/ssl/lib/'
660 ] ) 858 ] )
661 859
662 if (ssl_incs is not None and 860 if (ssl_incs is not None and
663 ssl_libs is not None): 861 ssl_libs is not None):
862 _ssl_libs = ['ssl', 'crypto']
863 if host_platform in ['mingw', 'win32']:
864 _ssl_libs.append('ws2_32')
664 exts.append( Extension('_ssl', ['_ssl.c'], 865 exts.append( Extension('_ssl', ['_ssl.c'],
665 include_dirs = ssl_incs, 866 include_dirs = ssl_incs,
666 library_dirs = ssl_libs, 867 library_dirs = ssl_libs,
667 libraries = ['ssl', 'crypto'], 868 libraries = _ssl_libs,
668 depends = ['socketmodule.h']), ) 869 depends = ['socketmodule.h']), )
669 else: 870 else:
670 missing.append('_ssl') 871 missing.append('_ssl')
671 872
672 # find out which version of OpenSSL we have 873 # find out which version of OpenSSL we have
673 openssl_ver = 0 874 openssl_ver = 0
674 openssl_ver_re = re.compile( 875 openssl_ver_re = re.compile(
675 '^\s*#\s*define\s+OPENSSL_VERSION_NUMBER\s+(0x[0-9a-fA-F]+)' ) 876 '^\s*#\s*define\s+OPENSSL_VERSION_NUMBER\s+(0x[0-9a-fA-F]+)' )
676 877
677 # look for the openssl version header on the compiler search path. 878 # look for the openssl version header on the compiler search path.
678 opensslv_h = find_file('openssl/opensslv.h', [], 879 opensslv_h = find_file('openssl/opensslv.h', [],
679 inc_dirs + search_for_ssl_incs_in) 880 inc_dirs + search_for_ssl_incs_in)
680 if opensslv_h: 881 if opensslv_h:
681 name = os.path.join(opensslv_h[0], 'openssl/opensslv.h') 882 name = os.path.join(opensslv_h[0], 'openssl/opensslv.h')
682 if sys.platform == 'darwin' and is_macosx_sdk_path(name): 883 if host_platform == 'darwin' and is_macosx_sdk_path(name):
683 name = os.path.join(macosx_sdk_root(), name[1:]) 884 name = os.path.join(macosx_sdk_root(), name[1:])
684 try: 885 try:
685 incfile = open(name, 'r') 886 with open(name, 'r') as incfile:
686 for line in incfile: 887 for line in incfile:
687 m = openssl_ver_re.match(line) 888 m = openssl_ver_re.match(line)
688 if m: 889 if m:
689 openssl_ver = eval(m.group(1)) 890 openssl_ver = eval(m.group(1))
690 except IOError as msg: 891 except IOError as msg:
691 print("IOError while reading opensshv.h:", msg) 892 print("IOError while reading opensshv.h:", msg)
692 pass 893 pass
693 894
694 #print('openssl_ver = 0x%08x' % openssl_ver) 895 #print('openssl_ver = 0x%08x' % openssl_ver)
695 min_openssl_ver = 0x00907000 896 min_openssl_ver = 0x00907000
696 have_any_openssl = ssl_incs is not None and ssl_libs is not None 897 have_any_openssl = ssl_incs is not None and ssl_libs is not None
697 have_usable_openssl = (have_any_openssl and 898 have_usable_openssl = (have_any_openssl and
698 openssl_ver >= min_openssl_ver) 899 openssl_ver >= min_openssl_ver)
699 900
700 if have_any_openssl: 901 if have_any_openssl:
701 if have_usable_openssl: 902 if have_usable_openssl:
702 # The _hashlib module wraps optimized implementations 903 # The _hashlib module wraps optimized implementations
703 # of hash functions from the OpenSSL library. 904 # of hash functions from the OpenSSL library.
905 # NOTE: _hashlib require only OpenSSL crypto library !
704 exts.append( Extension('_hashlib', ['_hashopenssl.c'], 906 exts.append( Extension('_hashlib', ['_hashopenssl.c'],
705 depends = ['hashlib.h'], 907 depends = ['hashlib.h'],
706 include_dirs = ssl_incs, 908 include_dirs = ssl_incs,
707 library_dirs = ssl_libs, 909 library_dirs = ssl_libs,
708 libraries = ['ssl', 'crypto']) ) 910 libraries = ['crypto']) )
709 else: 911 else:
710 print("warning: openssl 0x%08x is too old for _hashlib" % 912 print("warning: openssl 0x%08x is too old for _hashlib" %
711 openssl_ver) 913 openssl_ver)
712 missing.append('_hashlib') 914 missing.append('_hashlib')
713 915 # NOTE: MSVC build alwais include _md5 and _sha modules
714 min_sha2_openssl_ver = 0x00908000 916 # as build-in modules
715 if COMPILED_WITH_PYDEBUG or openssl_ver < min_sha2_openssl_ver: 917
716 # OpenSSL doesn't do these until 0.9.8 so we'll bring our own hash 918 # We always compile these even when OpenSSL is available (issue #14693).
717 exts.append( Extension('_sha256', ['sha256module.c'], 919 # It's harmless and the object code is tiny (40-50 KB per module,
718 depends=['hashlib.h']) ) 920 # only loaded when actually used).
719 exts.append( Extension('_sha512', ['sha512module.c'], 921 exts.append( Extension('_sha256', ['sha256module.c'],
720 depends=['hashlib.h']) ) 922 depends=['hashlib.h']) )
721 923 exts.append( Extension('_sha512', ['sha512module.c'],
722 if COMPILED_WITH_PYDEBUG or not have_usable_openssl: 924 depends=['hashlib.h']) )
723 # no openssl at all, use our own md5 and sha1 925 exts.append( Extension('_md5', ['md5module.c'],
724 exts.append( Extension('_md5', ['md5module.c'], 926 depends=['hashlib.h']) )
725 depends=['hashlib.h']) ) 927 exts.append( Extension('_sha1', ['sha1module.c'],
726 exts.append( Extension('_sha1', ['sha1module.c'], 928 depends=['hashlib.h']) )
727 depends=['hashlib.h']) )
728 929
729 # Modules that provide persistent dictionary-like semantics. You will 930 # Modules that provide persistent dictionary-like semantics. You will
730 # probably want to arrange for at least one of them to be available on 931 # probably want to arrange for at least one of them to be available on
731 # your machine, though none are defined by default because of library 932 # your machine, though none are defined by default because of library
732 # dependencies. The Python module dbm/__init__.py provides an 933 # dependencies. The Python module dbm/__init__.py provides an
733 # implementation independent wrapper for these; dbm/dumb.py provides 934 # implementation independent wrapper for these; dbm/dumb.py provides
734 # similar functionality (but slower of course) implemented in Python. 935 # similar functionality (but slower of course) implemented in Python.
735 936
736 # Sleepycat^WOracle Berkeley DB interface. 937 # Sleepycat^WOracle Berkeley DB interface.
737 # http://www.oracle.com/database/berkeley-db/db/index.html 938 # http://www.oracle.com/database/berkeley-db/db/index.html
738 # 939 #
739 # This requires the Sleepycat^WOracle DB code. The supported versions 940 # This requires the Sleepycat^WOracle DB code. The supported versions
740 # are set below. Visit the URL above to download 941 # are set below. Visit the URL above to download
741 # a release. Most open source OSes come with one or more 942 # a release. Most open source OSes come with one or more
742 # versions of BerkeleyDB already installed. 943 # versions of BerkeleyDB already installed.
743 944
744 max_db_ver = (4, 8) 945 max_db_ver = (5, 3)
745 min_db_ver = (3, 3) 946 min_db_ver = (3, 3)
746 db_setup_debug = False # verbose debug prints from this script? 947 db_setup_debug = False # verbose debug prints from this script?
948
949 # Modules with some Windows dependencies:
950 if host_platform in ['mingw', 'win32']:
951 srcdir = sysconfig.get_config_var('srcdir')
952 pc_srcdir = os.path.abspath(os.path.join(srcdir, 'PC'))
953
954 exts.append( Extension('msvcrt', [os.path.join(pc_srcdir, p)
955 for p in ['msvcrtmodule.c']]) )
956
957 #Note that PCbuild use fci but MSDN document as cabinet
958 exts.append( Extension('_msi', [os.path.join(pc_srcdir, p)
959 for p in ['_msi.c']],
960 libraries=['msi','cabinet','rpcrt4']) )
961
962 exts.append( Extension('_winapi', ['_winapi.c']) )
963
964 # On win32 host(mingw build in MSYS environment) show that site.py
965 # fail to load if some modules are not build-in:
966 #exts.append( Extension('winreg', [os.path.join(pc_srcdir, p)
967 # for p in ['winreg.c']]) )
968
969 exts.append( Extension('winsound', [os.path.join(pc_srcdir, p)
970 for p in ['winsound.c']],
971 libraries=['winmm']) )
747 972
748 def allow_db_ver(db_ver): 973 def allow_db_ver(db_ver):
749 """Returns a boolean if the given BerkeleyDB version is acceptable. 974 """Returns a boolean if the given BerkeleyDB version is acceptable.
750 975
751 Args: 976 Args:
752 db_ver: A tuple of the version to verify. 977 db_ver: A tuple of the version to verify.
753 """ 978 """
754 if not (min_db_ver <= db_ver <= max_db_ver): 979 if not (min_db_ver <= db_ver <= max_db_ver):
755 return False 980 return False
756 return True 981 return True
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 # MacPorts default (http://www.macports.org/) 1016 # MacPorts default (http://www.macports.org/)
792 db_inc_paths.append('/opt/local/include/db4%d' % x) 1017 db_inc_paths.append('/opt/local/include/db4%d' % x)
793 # 3.x minor number specific paths 1018 # 3.x minor number specific paths
794 for x in gen_db_minor_ver_nums(3): 1019 for x in gen_db_minor_ver_nums(3):
795 db_inc_paths.append('/usr/include/db3%d' % x) 1020 db_inc_paths.append('/usr/include/db3%d' % x)
796 db_inc_paths.append('/usr/local/BerkeleyDB.3.%d/include' % x) 1021 db_inc_paths.append('/usr/local/BerkeleyDB.3.%d/include' % x)
797 db_inc_paths.append('/usr/local/include/db3%d' % x) 1022 db_inc_paths.append('/usr/local/include/db3%d' % x)
798 db_inc_paths.append('/pkg/db-3.%d/include' % x) 1023 db_inc_paths.append('/pkg/db-3.%d/include' % x)
799 db_inc_paths.append('/opt/db-3.%d/include' % x) 1024 db_inc_paths.append('/opt/db-3.%d/include' % x)
800 1025
1026 if cross_compiling:
1027 db_inc_paths = []
1028
801 # Add some common subdirectories for Sleepycat DB to the list, 1029 # Add some common subdirectories for Sleepycat DB to the list,
802 # based on the standard include directories. This way DB3/4 gets 1030 # based on the standard include directories. This way DB3/4 gets
803 # picked up when it is installed in a non-standard prefix and 1031 # picked up when it is installed in a non-standard prefix and
804 # the user has added that prefix into inc_dirs. 1032 # the user has added that prefix into inc_dirs.
805 std_variants = [] 1033 std_variants = []
806 for dn in inc_dirs: 1034 for dn in inc_dirs:
807 std_variants.append(os.path.join(dn, 'db3')) 1035 std_variants.append(os.path.join(dn, 'db3'))
808 std_variants.append(os.path.join(dn, 'db4')) 1036 std_variants.append(os.path.join(dn, 'db4'))
809 for x in gen_db_minor_ver_nums(4): 1037 for x in gen_db_minor_ver_nums(4):
810 std_variants.append(os.path.join(dn, "db4%d"%x)) 1038 std_variants.append(os.path.join(dn, "db4%d"%x))
811 std_variants.append(os.path.join(dn, "db4.%d"%x)) 1039 std_variants.append(os.path.join(dn, "db4.%d"%x))
812 for x in gen_db_minor_ver_nums(3): 1040 for x in gen_db_minor_ver_nums(3):
813 std_variants.append(os.path.join(dn, "db3%d"%x)) 1041 std_variants.append(os.path.join(dn, "db3%d"%x))
814 std_variants.append(os.path.join(dn, "db3.%d"%x)) 1042 std_variants.append(os.path.join(dn, "db3.%d"%x))
815 1043
816 db_inc_paths = std_variants + db_inc_paths 1044 db_inc_paths = std_variants + db_inc_paths
817 db_inc_paths = [p for p in db_inc_paths if os.path.exists(p)] 1045 db_inc_paths = [p for p in db_inc_paths if os.path.exists(p)]
818 1046
819 db_ver_inc_map = {} 1047 db_ver_inc_map = {}
820 1048
821 if sys.platform == 'darwin': 1049 if host_platform == 'darwin':
822 sysroot = macosx_sdk_root() 1050 sysroot = macosx_sdk_root()
823 1051
824 class db_found(Exception): pass 1052 class db_found(Exception): pass
825 try: 1053 try:
826 # See whether there is a Sleepycat header in the standard 1054 # See whether there is a Sleepycat header in the standard
827 # search path. 1055 # search path.
828 for d in inc_dirs + db_inc_paths: 1056 for d in inc_dirs + db_inc_paths:
829 f = os.path.join(d, "db.h") 1057 f = os.path.join(d, "db.h")
830 if sys.platform == 'darwin' and is_macosx_sdk_path(d): 1058 if host_platform == 'darwin' and is_macosx_sdk_path(d):
831 f = os.path.join(sysroot, d[1:], "db.h") 1059 f = os.path.join(sysroot, d[1:], "db.h")
832 1060
833 if db_setup_debug: print("db: looking for db.h in", f) 1061 if db_setup_debug: print("db: looking for db.h in", f)
834 if os.path.exists(f): 1062 if os.path.exists(f):
835 f = open(f, "rb").read() 1063 with open(f, 'rb') as file:
1064 f = file.read()
836 m = re.search(br"#define\WDB_VERSION_MAJOR\W(\d+)", f) 1065 m = re.search(br"#define\WDB_VERSION_MAJOR\W(\d+)", f)
837 if m: 1066 if m:
838 db_major = int(m.group(1)) 1067 db_major = int(m.group(1))
839 m = re.search(br"#define\WDB_VERSION_MINOR\W(\d+)", f) 1068 m = re.search(br"#define\WDB_VERSION_MINOR\W(\d+)", f)
840 db_minor = int(m.group(1)) 1069 db_minor = int(m.group(1))
841 db_ver = (db_major, db_minor) 1070 db_ver = (db_major, db_minor)
842 1071
843 # Avoid 4.6 prior to 4.6.21 due to a BerkeleyDB bug 1072 # Avoid 4.6 prior to 4.6.21 due to a BerkeleyDB bug
844 if db_ver == (4, 6): 1073 if db_ver == (4, 6):
845 m = re.search(br"#define\WDB_VERSION_PATCH\W(\d+)", f) 1074 m = re.search(br"#define\WDB_VERSION_PATCH\W(\d+)", f)
(...skipping 24 matching lines...) Expand all
870 while db_found_vers: 1099 while db_found_vers:
871 db_ver = db_found_vers.pop() 1100 db_ver = db_found_vers.pop()
872 db_incdir = db_ver_inc_map[db_ver] 1101 db_incdir = db_ver_inc_map[db_ver]
873 1102
874 # check lib directories parallel to the location of the header 1103 # check lib directories parallel to the location of the header
875 db_dirs_to_check = [ 1104 db_dirs_to_check = [
876 db_incdir.replace("include", 'lib64'), 1105 db_incdir.replace("include", 'lib64'),
877 db_incdir.replace("include", 'lib'), 1106 db_incdir.replace("include", 'lib'),
878 ] 1107 ]
879 1108
880 if sys.platform != 'darwin': 1109 if host_platform != 'darwin':
881 db_dirs_to_check = list(filter(os.path.isdir, db_dirs_to_che ck)) 1110 db_dirs_to_check = list(filter(os.path.isdir, db_dirs_to_che ck))
882 1111
883 else: 1112 else:
884 # Same as other branch, but takes OSX SDK into account 1113 # Same as other branch, but takes OSX SDK into account
885 tmp = [] 1114 tmp = []
886 for dn in db_dirs_to_check: 1115 for dn in db_dirs_to_check:
887 if is_macosx_sdk_path(dn): 1116 if is_macosx_sdk_path(dn):
888 if os.path.isdir(os.path.join(sysroot, dn[1:])): 1117 if os.path.isdir(os.path.join(sysroot, dn[1:])):
889 tmp.append(dn) 1118 tmp.append(dn)
890 else: 1119 else:
891 if os.path.isdir(dn): 1120 if os.path.isdir(dn):
892 tmp.append(dn) 1121 tmp.append(dn)
893 db_dirs_to_check = tmp 1122 db_dirs_to_check = tmp
894 1123
895 db_dirs_to_check = tmp 1124 db_dirs_to_check = tmp
896 1125
897 # Look for a version specific db-X.Y before an ambiguoius dbX 1126 # Look for a version specific db-X.Y before an ambiguous dbX
898 # XXX should we -ever- look for a dbX name? Do any 1127 # XXX should we -ever- look for a dbX name? Do any
899 # systems really not name their library by version and 1128 # systems really not name their library by version and
900 # symlink to more general names? 1129 # symlink to more general names?
901 for dblib in (('db-%d.%d' % db_ver), 1130 for dblib in (('db-%d.%d' % db_ver),
902 ('db%d%d' % db_ver), 1131 ('db%d%d' % db_ver),
903 ('db%d' % db_ver[0])): 1132 ('db%d' % db_ver[0])):
904 dblib_file = self.compiler.find_library_file( 1133 dblib_file = self.compiler.find_library_file(
905 db_dirs_to_check + lib_dirs, dblib ) 1134 db_dirs_to_check + lib_dirs, dblib )
906 if dblib_file: 1135 if dblib_file:
907 dblib_dir = [ os.path.abspath(os.path.dirname(dblib_file )) ] 1136 dblib_dir = [ os.path.abspath(os.path.dirname(dblib_file )) ]
(...skipping 18 matching lines...) Expand all
926 1155
927 # We hunt for #define SQLITE_VERSION "n.n.n" 1156 # We hunt for #define SQLITE_VERSION "n.n.n"
928 # We need to find >= sqlite version 3.0.8 1157 # We need to find >= sqlite version 3.0.8
929 sqlite_incdir = sqlite_libdir = None 1158 sqlite_incdir = sqlite_libdir = None
930 sqlite_inc_paths = [ '/usr/include', 1159 sqlite_inc_paths = [ '/usr/include',
931 '/usr/include/sqlite', 1160 '/usr/include/sqlite',
932 '/usr/include/sqlite3', 1161 '/usr/include/sqlite3',
933 '/usr/local/include', 1162 '/usr/local/include',
934 '/usr/local/include/sqlite', 1163 '/usr/local/include/sqlite',
935 '/usr/local/include/sqlite3', 1164 '/usr/local/include/sqlite3',
936 ] 1165 ]
1166 if cross_compiling:
1167 sqlite_inc_paths = []
937 MIN_SQLITE_VERSION_NUMBER = (3, 0, 8) 1168 MIN_SQLITE_VERSION_NUMBER = (3, 0, 8)
938 MIN_SQLITE_VERSION = ".".join([str(x) 1169 MIN_SQLITE_VERSION = ".".join([str(x)
939 for x in MIN_SQLITE_VERSION_NUMBER]) 1170 for x in MIN_SQLITE_VERSION_NUMBER])
940 1171
941 # Scan the default include directories before the SQLite specific 1172 # Scan the default include directories before the SQLite specific
942 # ones. This allows one to override the copy of sqlite on OSX, 1173 # ones. This allows one to override the copy of sqlite on OSX,
943 # where /usr/include contains an old version of sqlite. 1174 # where /usr/include contains an old version of sqlite.
944 if sys.platform == 'darwin': 1175 if host_platform == 'darwin':
945 sysroot = macosx_sdk_root() 1176 sysroot = macosx_sdk_root()
946 1177
947 for d in inc_dirs + sqlite_inc_paths: 1178 for d_ in inc_dirs + sqlite_inc_paths:
1179 d = d_
1180 if host_platform == 'darwin' and is_macosx_sdk_path(d):
1181 d = os.path.join(sysroot, d[1:])
1182
948 f = os.path.join(d, "sqlite3.h") 1183 f = os.path.join(d, "sqlite3.h")
949
950 if sys.platform == 'darwin' and is_macosx_sdk_path(d):
951 f = os.path.join(sysroot, d[1:], "sqlite3.h")
952
953 if os.path.exists(f): 1184 if os.path.exists(f):
954 if sqlite_setup_debug: print("sqlite: found %s"%f) 1185 if sqlite_setup_debug: print("sqlite: found %s"%f)
955 incf = open(f).read() 1186 with open(f) as file:
1187 incf = file.read()
956 m = re.search( 1188 m = re.search(
957 r'\s*.*#\s*.*define\s.*SQLITE_VERSION\W*"(.*)"', incf) 1189 r'\s*.*#\s*.*define\s.*SQLITE_VERSION\W*"(.*)"', incf)
958 if m: 1190 if m:
959 sqlite_version = m.group(1) 1191 sqlite_version = m.group(1)
960 sqlite_version_tuple = tuple([int(x) 1192 sqlite_version_tuple = tuple([int(x)
961 for x in sqlite_version.split(".")]) 1193 for x in sqlite_version.split(".")])
962 if sqlite_version_tuple >= MIN_SQLITE_VERSION_NUMBER: 1194 if sqlite_version_tuple >= MIN_SQLITE_VERSION_NUMBER:
963 # we win! 1195 # we win!
964 if sqlite_setup_debug: 1196 if sqlite_setup_debug:
965 print("%s/sqlite3.h: version %s"%(d, sqlite_version) ) 1197 print("%s/sqlite3.h: version %s"%(d, sqlite_version) )
(...skipping 23 matching lines...) Expand all
989 '_sqlite/connection.c', 1221 '_sqlite/connection.c',
990 '_sqlite/cursor.c', 1222 '_sqlite/cursor.c',
991 '_sqlite/microprotocols.c', 1223 '_sqlite/microprotocols.c',
992 '_sqlite/module.c', 1224 '_sqlite/module.c',
993 '_sqlite/prepare_protocol.c', 1225 '_sqlite/prepare_protocol.c',
994 '_sqlite/row.c', 1226 '_sqlite/row.c',
995 '_sqlite/statement.c', 1227 '_sqlite/statement.c',
996 '_sqlite/util.c', ] 1228 '_sqlite/util.c', ]
997 1229
998 sqlite_defines = [] 1230 sqlite_defines = []
999 sqlite_defines.append(('MODULE_NAME', 'sqlite3')) 1231 #NOTE: don't add mingw here
1000 1232 if host_platform != "win32":
1001 # Comment this out if you want the sqlite3 module to be able to load extensions. 1233 sqlite_defines.append(('MODULE_NAME', '"sqlite3"'))
1002 sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1")) 1234 else:
1003 1235 sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"'))
1004 if sys.platform == 'darwin': 1236
1237 # Enable support for loadable extensions in the sqlite3 module
1238 # if --enable-loadable-sqlite-extensions configure option is used.
1239 if '--enable-loadable-sqlite-extensions' not in sysconfig.get_config _var("CONFIG_ARGS"):
1240 sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))
1241
1242 if host_platform == 'darwin':
1005 # In every directory on the search path search for a dynamic 1243 # In every directory on the search path search for a dynamic
1006 # library and then a static library, instead of first looking 1244 # library and then a static library, instead of first looking
1007 # for dynamic libraries on the entiry path. 1245 # for dynamic libraries on the entire path.
1008 # This way a staticly linked custom sqlite gets picked up 1246 # This way a statically linked custom sqlite gets picked up
1009 # before the dynamic library in /usr/lib. 1247 # before the dynamic library in /usr/lib.
1010 sqlite_extra_link_args = ('-Wl,-search_paths_first',) 1248 sqlite_extra_link_args = ('-Wl,-search_paths_first',)
1011 else: 1249 else:
1012 sqlite_extra_link_args = () 1250 sqlite_extra_link_args = ()
1013 1251
1252 include_dirs = ["Modules/_sqlite"]
1253 # Only include the directory where sqlite was found if it does
1254 # not already exist in set include directories, otherwise you
1255 # can end up with a bad search path order.
1256 if sqlite_incdir not in self.compiler.include_dirs:
1257 include_dirs.append(sqlite_incdir)
1014 exts.append(Extension('_sqlite3', sqlite_srcs, 1258 exts.append(Extension('_sqlite3', sqlite_srcs,
1015 define_macros=sqlite_defines, 1259 define_macros=sqlite_defines,
1016 include_dirs=["Modules/_sqlite", 1260 include_dirs=include_dirs,
1017 sqlite_incdir],
1018 library_dirs=sqlite_libdir, 1261 library_dirs=sqlite_libdir,
1019 runtime_library_dirs=sqlite_libdir, 1262 runtime_library_dirs=sqlite_libdir,
1020 extra_link_args=sqlite_extra_link_args, 1263 extra_link_args=sqlite_extra_link_args,
1021 libraries=["sqlite3",])) 1264 libraries=["sqlite3",]))
1022 else: 1265 else:
1023 missing.append('_sqlite3') 1266 missing.append('_sqlite3')
1024 1267
1268 dbm_setup_debug = False # verbose debug prints from this script?
1025 dbm_order = ['gdbm'] 1269 dbm_order = ['gdbm']
1026 # The standard Unix dbm module: 1270 # The standard Unix dbm module:
1027 if platform not in ['cygwin']: 1271 if host_platform not in ['cygwin']:
1028 config_args = [arg.strip("'") 1272 config_args = [arg.strip("'")
1029 for arg in sysconfig.get_config_var("CONFIG_ARGS").sp lit()] 1273 for arg in sysconfig.get_config_var("CONFIG_ARGS").sp lit()]
1030 dbm_args = [arg for arg in config_args 1274 dbm_args = [arg for arg in config_args
1031 if arg.startswith('--with-dbmliborder=')] 1275 if arg.startswith('--with-dbmliborder=')]
1032 if dbm_args: 1276 if dbm_args:
1033 dbm_order = [arg.split('=')[-1] for arg in dbm_args][-1].split(" :") 1277 dbm_order = [arg.split('=')[-1] for arg in dbm_args][-1].split(" :")
1034 else: 1278 else:
1035 dbm_order = "ndbm:gdbm:bdb".split(":") 1279 dbm_order = "ndbm:gdbm:bdb".split(":")
1036 dbmext = None 1280 dbmext = None
1037 for cand in dbm_order: 1281 for cand in dbm_order:
1038 if cand == "ndbm": 1282 if cand == "ndbm":
1039 if find_file("ndbm.h", inc_dirs, []) is not None: 1283 if find_file("ndbm.h", inc_dirs, []) is not None:
1040 # Some systems have -lndbm, others don't 1284 # Some systems have -lndbm, others have -lgdbm_compat,
1285 # others don't have either
1041 if self.compiler.find_library_file(lib_dirs, 1286 if self.compiler.find_library_file(lib_dirs,
1042 'ndbm'): 1287 'ndbm'):
1043 ndbm_libs = ['ndbm'] 1288 ndbm_libs = ['ndbm']
1289 elif self.compiler.find_library_file(lib_dirs,
1290 'gdbm_compat'):
1291 ndbm_libs = ['gdbm_compat']
1044 else: 1292 else:
1045 ndbm_libs = [] 1293 ndbm_libs = []
1046 print("building dbm using ndbm") 1294 if dbm_setup_debug: print("building dbm using ndbm")
1047 dbmext = Extension('_dbm', ['_dbmmodule.c'], 1295 dbmext = Extension('_dbm', ['_dbmmodule.c'],
1048 define_macros=[ 1296 define_macros=[
1049 ('HAVE_NDBM_H',None), 1297 ('HAVE_NDBM_H',None),
1050 ], 1298 ],
1051 libraries=ndbm_libs) 1299 libraries=ndbm_libs)
1052 break 1300 break
1053 1301
1054 elif cand == "gdbm": 1302 elif cand == "gdbm":
1055 if self.compiler.find_library_file(lib_dirs, 'gdbm'): 1303 if self.compiler.find_library_file(lib_dirs, 'gdbm'):
1056 gdbm_libs = ['gdbm'] 1304 gdbm_libs = ['gdbm']
1057 if self.compiler.find_library_file(lib_dirs, 1305 if self.compiler.find_library_file(lib_dirs,
1058 'gdbm_compat'): 1306 'gdbm_compat'):
1059 gdbm_libs.append('gdbm_compat') 1307 gdbm_libs.append('gdbm_compat')
1060 if find_file("gdbm/ndbm.h", inc_dirs, []) is not None: 1308 if find_file("gdbm/ndbm.h", inc_dirs, []) is not None:
1061 print("building dbm using gdbm") 1309 if dbm_setup_debug: print("building dbm using gdbm")
1062 dbmext = Extension( 1310 dbmext = Extension(
1063 '_dbm', ['_dbmmodule.c'], 1311 '_dbm', ['_dbmmodule.c'],
1064 define_macros=[ 1312 define_macros=[
1065 ('HAVE_GDBM_NDBM_H', None), 1313 ('HAVE_GDBM_NDBM_H', None),
1066 ], 1314 ],
1067 libraries = gdbm_libs) 1315 libraries = gdbm_libs)
1068 break 1316 break
1069 if find_file("gdbm-ndbm.h", inc_dirs, []) is not None: 1317 if find_file("gdbm-ndbm.h", inc_dirs, []) is not None:
1070 print("building dbm using gdbm") 1318 if dbm_setup_debug: print("building dbm using gdbm")
1071 dbmext = Extension( 1319 dbmext = Extension(
1072 '_dbm', ['_dbmmodule.c'], 1320 '_dbm', ['_dbmmodule.c'],
1073 define_macros=[ 1321 define_macros=[
1074 ('HAVE_GDBM_DASH_NDBM_H', None), 1322 ('HAVE_GDBM_DASH_NDBM_H', None),
1075 ], 1323 ],
1076 libraries = gdbm_libs) 1324 libraries = gdbm_libs)
1077 break 1325 break
1078 elif cand == "bdb": 1326 elif cand == "bdb":
1079 if db_incs is not None: 1327 if db_incs is not None:
1080 print("building dbm using bdb") 1328 if dbm_setup_debug: print("building dbm using bdb")
1081 dbmext = Extension('_dbm', ['_dbmmodule.c'], 1329 dbmext = Extension('_dbm', ['_dbmmodule.c'],
1082 library_dirs=dblib_dir, 1330 library_dirs=dblib_dir,
1083 runtime_library_dirs=dblib_dir, 1331 runtime_library_dirs=dblib_dir,
1084 include_dirs=db_incs, 1332 include_dirs=db_incs,
1085 define_macros=[ 1333 define_macros=[
1086 ('HAVE_BERKDB_H', None), 1334 ('HAVE_BERKDB_H', None),
1087 ('DB_DBM_HSEARCH', None), 1335 ('DB_DBM_HSEARCH', None),
1088 ], 1336 ],
1089 libraries=dblibs) 1337 libraries=dblibs)
1090 break 1338 break
1091 if dbmext is not None: 1339 if dbmext is not None:
1092 exts.append(dbmext) 1340 exts.append(dbmext)
1093 else: 1341 else:
1094 missing.append('_dbm') 1342 missing.append('_dbm')
1095 1343
1096 # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm: 1344 # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm:
1097 if ('gdbm' in dbm_order and 1345 if (host_platform not in ['mingw', 'win32'] and
1346 'gdbm' in dbm_order and
1098 self.compiler.find_library_file(lib_dirs, 'gdbm')): 1347 self.compiler.find_library_file(lib_dirs, 'gdbm')):
1099 exts.append( Extension('_gdbm', ['_gdbmmodule.c'], 1348 exts.append( Extension('_gdbm', ['_gdbmmodule.c'],
1100 libraries = ['gdbm'] ) ) 1349 libraries = ['gdbm'] ) )
1101 else: 1350 else:
1102 missing.append('_gdbm') 1351 missing.append('_gdbm')
1103 1352
1104 # Unix-only modules 1353 # Unix-only modules
1105 if platform != 'win32': 1354 if host_platform not in ['mingw', 'win32']:
1106 # Steen Lumholt's termios module 1355 # Steen Lumholt's termios module
1107 exts.append( Extension('termios', ['termios.c']) ) 1356 exts.append( Extension('termios', ['termios.c']) )
1108 # Jeremy Hylton's rlimit interface 1357 # Jeremy Hylton's rlimit interface
1109 exts.append( Extension('resource', ['resource.c']) ) 1358 exts.append( Extension('resource', ['resource.c']) )
1110 1359
1111 # Sun yellow pages. Some systems have the functions in libc. 1360 # Sun yellow pages. Some systems have the functions in libc.
1112 if (platform not in ['cygwin', 'qnx6'] and 1361 if (host_platform not in ['cygwin', 'qnx6'] and
1113 find_file('rpcsvc/yp_prot.h', inc_dirs, []) is not None): 1362 find_file('rpcsvc/yp_prot.h', inc_dirs, []) is not None):
1114 if (self.compiler.find_library_file(lib_dirs, 'nsl')): 1363 if (self.compiler.find_library_file(lib_dirs, 'nsl')):
1115 libs = ['nsl'] 1364 libs = ['nsl']
1116 else: 1365 else:
1117 libs = [] 1366 libs = []
1118 exts.append( Extension('nis', ['nismodule.c'], 1367 exts.append( Extension('nis', ['nismodule.c'],
1119 libraries = libs) ) 1368 libraries = libs) )
1120 else: 1369 else:
1121 missing.append('nis') 1370 missing.append('nis')
1122 else: 1371 else:
1123 missing.extend(['nis', 'resource', 'termios']) 1372 missing.extend(['nis', 'resource', 'termios'])
1124 1373
1125 # Curses support, requiring the System V version of curses, often 1374 # Curses support, requiring the System V version of curses, often
1126 # provided by the ncurses library. 1375 # provided by the ncurses library.
1376 curses_defines = []
1377 curses_includes = []
1127 panel_library = 'panel' 1378 panel_library = 'panel'
1379 if curses_library == 'ncursesw':
1380 curses_defines.append(('HAVE_NCURSESW', '1'))
1381 curses_includes.append('/usr/include/ncursesw')
1382 # Bug 1464056: If _curses.so links with ncursesw,
1383 # _curses_panel.so must link with panelw.
1384 panel_library = 'panelw'
1385 if host_platform == 'darwin':
1386 # On OS X, there is no separate /usr/lib/libncursesw nor
1387 # libpanelw. If we are here, we found a locally-supplied
1388 # version of libncursesw. There should be also be a
1389 # libpanelw. _XOPEN_SOURCE defines are usually excluded
1390 # for OS X but we need _XOPEN_SOURCE_EXTENDED here for
1391 # ncurses wide char support
1392 curses_defines.append(('_XOPEN_SOURCE_EXTENDED', '1'))
1393 elif host_platform == 'darwin' and curses_library == 'ncurses':
1394 # Building with the system-suppied combined libncurses/libpanel
1395 curses_defines.append(('HAVE_NCURSESW', '1'))
1396 curses_defines.append(('_XOPEN_SOURCE_EXTENDED', '1'))
1397
1128 if curses_library.startswith('ncurses'): 1398 if curses_library.startswith('ncurses'):
1129 if curses_library == 'ncursesw':
1130 # Bug 1464056: If _curses.so links with ncursesw,
1131 # _curses_panel.so must link with panelw.
1132 panel_library = 'panelw'
1133 curses_libs = [curses_library] 1399 curses_libs = [curses_library]
1134 exts.append( Extension('_curses', ['_cursesmodule.c'], 1400 exts.append( Extension('_curses', ['_cursesmodule.c'],
1401 include_dirs=curses_includes,
1402 define_macros=curses_defines,
1135 libraries = curses_libs) ) 1403 libraries = curses_libs) )
1136 elif curses_library == 'curses' and platform != 'darwin': 1404 elif curses_library == 'curses' and host_platform != 'darwin':
1137 # OSX has an old Berkeley curses, not good enough for 1405 # OSX has an old Berkeley curses, not good enough for
1138 # the _curses module. 1406 # the _curses module.
1139 if (self.compiler.find_library_file(lib_dirs, 'terminfo')): 1407 if (self.compiler.find_library_file(lib_dirs, 'terminfo')):
1140 curses_libs = ['curses', 'terminfo'] 1408 curses_libs = ['curses', 'terminfo']
1141 elif (self.compiler.find_library_file(lib_dirs, 'termcap')): 1409 elif (self.compiler.find_library_file(lib_dirs, 'termcap')):
1142 curses_libs = ['curses', 'termcap'] 1410 curses_libs = ['curses', 'termcap']
1143 else: 1411 else:
1144 curses_libs = ['curses'] 1412 curses_libs = ['curses']
1145 1413
1146 exts.append( Extension('_curses', ['_cursesmodule.c'], 1414 exts.append( Extension('_curses', ['_cursesmodule.c'],
1415 define_macros=curses_defines,
1147 libraries = curses_libs) ) 1416 libraries = curses_libs) )
1148 else: 1417 else:
1149 missing.append('_curses') 1418 missing.append('_curses')
1150 1419
1151 # If the curses module is enabled, check for the panel module 1420 # If the curses module is enabled, check for the panel module
1152 if (module_enabled(exts, '_curses') and 1421 if (module_enabled(exts, '_curses') and
1153 self.compiler.find_library_file(lib_dirs, panel_library)): 1422 self.compiler.find_library_file(lib_dirs, panel_library)):
1154 exts.append( Extension('_curses_panel', ['_curses_panel.c'], 1423 exts.append( Extension('_curses_panel', ['_curses_panel.c'],
1424 include_dirs=curses_includes,
1425 define_macros=curses_defines,
1155 libraries = [panel_library] + curses_libs) ) 1426 libraries = [panel_library] + curses_libs) )
1156 else: 1427 else:
1157 missing.append('_curses_panel') 1428 missing.append('_curses_panel')
1158 1429
1159 # Andrew Kuchling's zlib module. Note that some versions of zlib 1430 # Andrew Kuchling's zlib module. Note that some versions of zlib
1160 # 1.1.3 have security problems. See CERT Advisory CA-2002-07: 1431 # 1.1.3 have security problems. See CERT Advisory CA-2002-07:
1161 # http://www.cert.org/advisories/CA-2002-07.html 1432 # http://www.cert.org/advisories/CA-2002-07.html
1162 # 1433 #
1163 # zlib 1.1.4 is fixed, but at least one vendor (RedHat) has decided to 1434 # zlib 1.1.4 is fixed, but at least one vendor (RedHat) has decided to
1164 # patch its zlib 1.1.3 package instead of upgrading to 1.1.4. For 1435 # patch its zlib 1.1.3 package instead of upgrading to 1.1.4. For
1165 # now, we still accept 1.1.3, because we think it's difficult to 1436 # now, we still accept 1.1.3, because we think it's difficult to
1166 # exploit this in Python, and we'd rather make it RedHat's problem 1437 # exploit this in Python, and we'd rather make it RedHat's problem
1167 # than our problem <wink>. 1438 # than our problem <wink>.
1168 # 1439 #
1169 # You can upgrade zlib to version 1.1.4 yourself by going to 1440 # You can upgrade zlib to version 1.1.4 yourself by going to
1170 # http://www.gzip.org/zlib/ 1441 # http://www.gzip.org/zlib/
1171 zlib_inc = find_file('zlib.h', [], inc_dirs) 1442 zlib_inc = find_file('zlib.h', [], inc_dirs)
1172 have_zlib = False 1443 have_zlib = False
1173 if zlib_inc is not None: 1444 if zlib_inc is not None:
1174 zlib_h = zlib_inc[0] + '/zlib.h' 1445 zlib_h = zlib_inc[0] + '/zlib.h'
1175 version = '"0.0.0"' 1446 version = '"0.0.0"'
1176 version_req = '"1.1.3"' 1447 version_req = '"1.1.3"'
1177 fp = open(zlib_h) 1448 with open(zlib_h) as fp:
1178 while 1: 1449 while 1:
1179 line = fp.readline() 1450 line = fp.readline()
1180 if not line: 1451 if not line:
1181 break 1452 break
1182 if line.startswith('#define ZLIB_VERSION'): 1453 if line.startswith('#define ZLIB_VERSION'):
1183 version = line.split()[2] 1454 version = line.split()[2]
1184 break 1455 break
1185 if version >= version_req: 1456 if version >= version_req:
1186 if (self.compiler.find_library_file(lib_dirs, 'z')): 1457 if (self.compiler.find_library_file(lib_dirs, 'z')):
1187 if sys.platform == "darwin": 1458 if host_platform == "darwin":
1188 zlib_extra_link_args = ('-Wl,-search_paths_first',) 1459 zlib_extra_link_args = ('-Wl,-search_paths_first',)
1189 else: 1460 else:
1190 zlib_extra_link_args = () 1461 zlib_extra_link_args = ()
1191 exts.append( Extension('zlib', ['zlibmodule.c'], 1462 exts.append( Extension('zlib', ['zlibmodule.c'],
1192 libraries = ['z'], 1463 libraries = ['z'],
1193 extra_link_args = zlib_extra_link_arg s)) 1464 extra_link_args = zlib_extra_link_arg s))
1194 have_zlib = True 1465 have_zlib = True
1195 else: 1466 else:
1196 missing.append('zlib') 1467 missing.append('zlib')
1197 else: 1468 else:
(...skipping 11 matching lines...) Expand all
1209 extra_compile_args = [] 1480 extra_compile_args = []
1210 libraries = [] 1481 libraries = []
1211 extra_link_args = [] 1482 extra_link_args = []
1212 exts.append( Extension('binascii', ['binascii.c'], 1483 exts.append( Extension('binascii', ['binascii.c'],
1213 extra_compile_args = extra_compile_args, 1484 extra_compile_args = extra_compile_args,
1214 libraries = libraries, 1485 libraries = libraries,
1215 extra_link_args = extra_link_args) ) 1486 extra_link_args = extra_link_args) )
1216 1487
1217 # Gustavo Niemeyer's bz2 module. 1488 # Gustavo Niemeyer's bz2 module.
1218 if (self.compiler.find_library_file(lib_dirs, 'bz2')): 1489 if (self.compiler.find_library_file(lib_dirs, 'bz2')):
1219 if sys.platform == "darwin": 1490 if host_platform == "darwin":
1220 bz2_extra_link_args = ('-Wl,-search_paths_first',) 1491 bz2_extra_link_args = ('-Wl,-search_paths_first',)
1221 else: 1492 else:
1222 bz2_extra_link_args = () 1493 bz2_extra_link_args = ()
1223 exts.append( Extension('bz2', ['bz2module.c'], 1494 exts.append( Extension('_bz2', ['_bz2module.c'],
1224 libraries = ['bz2'], 1495 libraries = ['bz2'],
1225 extra_link_args = bz2_extra_link_args) ) 1496 extra_link_args = bz2_extra_link_args) )
1226 else: 1497 else:
1227 missing.append('bz2') 1498 missing.append('_bz2')
1499
1500 # LZMA compression support.
1501 if self.compiler.find_library_file(lib_dirs, 'lzma'):
1502 exts.append( Extension('_lzma', ['_lzmamodule.c'],
1503 libraries = ['lzma']) )
1504 else:
1505 missing.append('_lzma')
1228 1506
1229 # Interface to the Expat XML parser 1507 # Interface to the Expat XML parser
1230 # 1508 #
1231 # Expat was written by James Clark and is now maintained by a group of 1509 # Expat was written by James Clark and is now maintained by a group of
1232 # developers on SourceForge; see www.libexpat.org for more information. 1510 # developers on SourceForge; see www.libexpat.org for more information.
1233 # The pyexpat module was written by Paul Prescod after a prototype by 1511 # The pyexpat module was written by Paul Prescod after a prototype by
1234 # Jack Jansen. The Expat source is included in Modules/expat/. Usage 1512 # Jack Jansen. The Expat source is included in Modules/expat/. Usage
1235 # of a system shared libexpat.so is possible with --with-system-expat 1513 # of a system shared libexpat.so is possible with --with-system-expat
1236 # cofigure option. 1514 # configure option.
1237 # 1515 #
1238 # More information on Expat can be found at www.libexpat.org. 1516 # More information on Expat can be found at www.libexpat.org.
1239 # 1517 #
1240 if '--with-system-expat' in sysconfig.get_config_var("CONFIG_ARGS"): 1518 if '--with-system-expat' in sysconfig.get_config_var("CONFIG_ARGS"):
1241 expat_inc = [] 1519 expat_inc = []
1242 define_macros = [] 1520 define_macros = []
1243 expat_lib = ['expat'] 1521 expat_lib = ['expat']
1244 expat_sources = [] 1522 expat_sources = []
1245 else: 1523 else:
1246 expat_inc = [os.path.join(os.getcwd(), srcdir, 'Modules', 'expat')] 1524 expat_inc = [os.path.join(os.getcwd(), srcdir, 'Modules', 'expat')]
(...skipping 26 matching lines...) Expand all
1273 else: 1551 else:
1274 missing.append('_elementtree') 1552 missing.append('_elementtree')
1275 1553
1276 # Hye-Shik Chang's CJKCodecs modules. 1554 # Hye-Shik Chang's CJKCodecs modules.
1277 exts.append(Extension('_multibytecodec', 1555 exts.append(Extension('_multibytecodec',
1278 ['cjkcodecs/multibytecodec.c'])) 1556 ['cjkcodecs/multibytecodec.c']))
1279 for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'): 1557 for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'):
1280 exts.append(Extension('_codecs_%s' % loc, 1558 exts.append(Extension('_codecs_%s' % loc,
1281 ['cjkcodecs/_codecs_%s.c' % loc])) 1559 ['cjkcodecs/_codecs_%s.c' % loc]))
1282 1560
1561 # Stefan Krah's _decimal module
1562 exts.append(self._decimal_ext())
1563
1283 # Thomas Heller's _ctypes module 1564 # Thomas Heller's _ctypes module
1284 self.detect_ctypes(inc_dirs, lib_dirs) 1565 self.detect_ctypes(inc_dirs, lib_dirs)
1285 1566
1286 # Richard Oudkerk's multiprocessing module 1567 # Richard Oudkerk's multiprocessing module
1287 if platform == 'win32': # Windows 1568 if host_platform in ['mingw', 'win32']:
1288 macros = dict() 1569 macros = dict()
1289 libraries = ['ws2_32'] 1570 libraries = ['ws2_32']
1290 1571
1291 elif platform == 'darwin': # Mac OSX 1572 elif host_platform == 'darwin': # Mac OSX
1292 macros = dict() 1573 macros = dict()
1293 libraries = [] 1574 libraries = []
1294 1575
1295 elif platform == 'cygwin': # Cygwin 1576 elif host_platform == 'cygwin': # Cygwin
1296 macros = dict() 1577 macros = dict()
1297 libraries = [] 1578 libraries = []
1298 1579
1299 elif platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'freeb sd8'): 1580 elif host_platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', ' freebsd8'):
1300 # FreeBSD's P1003.1b semaphore support is very experimental 1581 # FreeBSD's P1003.1b semaphore support is very experimental
1301 # and has many known problems. (as of June 2008) 1582 # and has many known problems. (as of June 2008)
1302 macros = dict() 1583 macros = dict()
1303 libraries = [] 1584 libraries = []
1304 1585
1305 elif platform.startswith('openbsd'): 1586 elif host_platform.startswith('openbsd'):
1306 macros = dict() 1587 macros = dict()
1307 libraries = [] 1588 libraries = []
1308 1589
1309 elif platform.startswith('netbsd'): 1590 elif host_platform.startswith('netbsd'):
1310 macros = dict() 1591 macros = dict()
1311 libraries = [] 1592 libraries = []
1312 1593
1313 else: # Linux and other unices 1594 else: # Linux and other unices
1314 macros = dict() 1595 macros = dict()
1315 libraries = ['rt'] 1596 # NOTE: line below is never used before to add MINGW platform
1316 1597 #libraries = ['rt']
1317 if platform == 'win32': 1598 libraries = []
1599
1600 if host_platform in ['mingw', 'win32']:
1318 multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c', 1601 multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c',
1319 '_multiprocessing/semaphore.c', 1602 '_multiprocessing/semaphore.c',
1320 '_multiprocessing/pipe_connection.c',
1321 '_multiprocessing/socket_connection.c',
1322 '_multiprocessing/win32_functions.c'
1323 ] 1603 ]
1324 multiprocessing_libs = ['ws2_32']
1325 1604
1326 else: 1605 else:
1327 multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c', 1606 multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c',
1328 '_multiprocessing/socket_connection.c'
1329 ] 1607 ]
1330 multiprocessing_libs = []
1331 if (sysconfig.get_config_var('HAVE_SEM_OPEN') and not 1608 if (sysconfig.get_config_var('HAVE_SEM_OPEN') and not
1332 sysconfig.get_config_var('POSIX_SEMAPHORES_NOT_ENABLED')): 1609 sysconfig.get_config_var('POSIX_SEMAPHORES_NOT_ENABLED')):
1333 multiprocessing_srcs.append('_multiprocessing/semaphore.c') 1610 multiprocessing_srcs.append('_multiprocessing/semaphore.c')
1334 1611
1335 if sysconfig.get_config_var('WITH_THREAD'): 1612 if sysconfig.get_config_var('WITH_THREAD'):
1613 #FIXME: why above set libraries aren't used ?
1336 exts.append ( Extension('_multiprocessing', multiprocessing_srcs, 1614 exts.append ( Extension('_multiprocessing', multiprocessing_srcs,
1615 libraries=libraries,
1337 define_macros=list(macros.items()), 1616 define_macros=list(macros.items()),
1338 include_dirs=["Modules/_multiprocessing"], 1617 include_dirs=["Modules/_multiprocessing"]))
1339 libraries=multiprocessing_libs)
1340 )
1341 else: 1618 else:
1342 missing.append('_multiprocessing') 1619 missing.append('_multiprocessing')
1343 # End multiprocessing 1620 # End multiprocessing
1344 1621
1345 # Platform-specific libraries 1622 # Platform-specific libraries
1346 if (platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6', 1623 if host_platform.startswith(('linux', 'freebsd', 'gnukfreebsd')):
1347 'freebsd7', 'freebsd8')
1348 or platform.startswith("gnukfreebsd")):
1349 exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) ) 1624 exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) )
1350 else: 1625 else:
1351 missing.append('ossaudiodev') 1626 missing.append('ossaudiodev')
1352 1627
1353 if sys.platform == 'darwin': 1628 if host_platform == 'darwin':
1354 exts.append( 1629 exts.append(
1355 Extension('_gestalt', ['_gestalt.c'], 1630 Extension('_gestalt', ['_gestalt.c'],
1356 extra_link_args=['-framework', 'Carbon']) 1631 extra_link_args=['-framework', 'Carbon'])
1357 ) 1632 )
1358 exts.append( 1633 exts.append(
1359 Extension('_scproxy', ['_scproxy.c'], 1634 Extension('_scproxy', ['_scproxy.c'],
1360 extra_link_args=[ 1635 extra_link_args=[
1361 '-framework', 'SystemConfiguration', 1636 '-framework', 'SystemConfiguration',
1362 '-framework', 'CoreFoundation', 1637 '-framework', 'CoreFoundation',
1363 ])) 1638 ]))
1364 if sys.platform == 'win32':
1365 exts.append( Extension('msvcrt', ['PC/msvcrtmodule.c']) )
1366 exts.append( Extension('winreg', ['PC/winreg.c']) )
1367 exts.append( Extension('winsound', ['PC/winsound.c'],
1368 libraries=['winmm'])
1369 )
1370 1639
1371 self.extensions.extend(exts) 1640 self.extensions.extend(exts)
1372 1641
1373 # Call the method for detecting whether _tkinter can be compiled 1642 # Call the method for detecting whether _tkinter can be compiled
1374 self.detect_tkinter(inc_dirs, lib_dirs) 1643 self.detect_tkinter(inc_dirs, lib_dirs)
1375 1644
1376 if '_tkinter' not in [e.name for e in self.extensions]: 1645 if '_tkinter' not in [e.name for e in self.extensions]:
1377 missing.append('_tkinter') 1646 missing.append('_tkinter')
1378 1647
1379 return missing 1648 return missing
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1437 tmpfile = os.path.join(self.build_temp, 'tk.arch') 1706 tmpfile = os.path.join(self.build_temp, 'tk.arch')
1438 if not os.path.exists(self.build_temp): 1707 if not os.path.exists(self.build_temp):
1439 os.makedirs(self.build_temp) 1708 os.makedirs(self.build_temp)
1440 1709
1441 # Note: cannot use os.popen or subprocess here, that 1710 # Note: cannot use os.popen or subprocess here, that
1442 # requires extensions that are not available here. 1711 # requires extensions that are not available here.
1443 if is_macosx_sdk_path(F): 1712 if is_macosx_sdk_path(F):
1444 os.system("file %s/Tk.framework/Tk | grep 'for architecture' > %s"%( os.path.join(sysroot, F[1:]), tmpfile)) 1713 os.system("file %s/Tk.framework/Tk | grep 'for architecture' > %s"%( os.path.join(sysroot, F[1:]), tmpfile))
1445 else: 1714 else:
1446 os.system("file %s/Tk.framework/Tk | grep 'for architecture' > %s"%( F, tmpfile)) 1715 os.system("file %s/Tk.framework/Tk | grep 'for architecture' > %s"%( F, tmpfile))
1447 fp = open(tmpfile) 1716
1448 1717 with open(tmpfile) as fp:
1449 detected_archs = [] 1718 detected_archs = []
1450 for ln in fp: 1719 for ln in fp:
1451 a = ln.split()[-1] 1720 a = ln.split()[-1]
1452 if a in archs: 1721 if a in archs:
1453 detected_archs.append(ln.split()[-1]) 1722 detected_archs.append(ln.split()[-1])
1454 fp.close()
1455 os.unlink(tmpfile) 1723 os.unlink(tmpfile)
1456 1724
1457 for a in detected_archs: 1725 for a in detected_archs:
1458 frameworks.append('-arch') 1726 frameworks.append('-arch')
1459 frameworks.append(a) 1727 frameworks.append(a)
1460 1728
1461 ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], 1729 ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
1462 define_macros=[('WITH_APPINIT', 1)], 1730 define_macros=[('WITH_APPINIT', 1)],
1463 include_dirs = include_dirs, 1731 include_dirs = include_dirs,
1464 libraries = [], 1732 libraries = [],
1465 extra_compile_args = frameworks[2:], 1733 extra_compile_args = frameworks[2:],
1466 extra_link_args = frameworks, 1734 extra_link_args = frameworks,
1467 ) 1735 )
1468 self.extensions.append(ext) 1736 self.extensions.append(ext)
1469 return 1 1737 return 1
1470 1738
1471 1739
1472 def detect_tkinter(self, inc_dirs, lib_dirs): 1740 def detect_tkinter(self, inc_dirs, lib_dirs):
1473 # The _tkinter module. 1741 # The _tkinter module.
1474 1742
1475 # Rather than complicate the code below, detecting and building 1743 # Rather than complicate the code below, detecting and building
1476 # AquaTk is a separate method. Only one Tkinter will be built on 1744 # AquaTk is a separate method. Only one Tkinter will be built on
1477 # Darwin - either AquaTk, if it is found, or X11 based Tk. 1745 # Darwin - either AquaTk, if it is found, or X11 based Tk.
1478 platform = self.get_platform() 1746 if (host_platform == 'darwin' and
1479 if (platform == 'darwin' and
1480 self.detect_tkinter_darwin(inc_dirs, lib_dirs)): 1747 self.detect_tkinter_darwin(inc_dirs, lib_dirs)):
1481 return 1748 return
1482 1749
1483 # Assume we haven't found any of the libraries or include files 1750 # Assume we haven't found any of the libraries or include files
1484 # The versions with dots are used on Unix, and the versions without 1751 # The versions with dots are used on Unix, and the versions without
1485 # dots on Windows, for detection by cygwin. 1752 # dots on Windows, for detection by cygwin.
1486 tcllib = tklib = tcl_includes = tk_includes = None 1753 tcllib = tklib = tcl_includes = tk_includes = None
1487 for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83', 1754 for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83',
1488 '8.2', '82', '8.1', '81', '8.0', '80']: 1755 '8.2', '82', '8.1', '81', '8.0', '80']:
1489 tklib = self.compiler.find_library_file(lib_dirs, 1756 tklib = self.compiler.find_library_file(lib_dirs,
1490 'tk' + version) 1757 'tk' + version)
1491 tcllib = self.compiler.find_library_file(lib_dirs, 1758 tcllib = self.compiler.find_library_file(lib_dirs,
1492 'tcl' + version) 1759 'tcl' + version)
1493 if tklib and tcllib: 1760 if tklib and tcllib:
1494 # Exit the loop when we've found the Tcl/Tk libraries 1761 # Exit the loop when we've found the Tcl/Tk libraries
1495 break 1762 break
1496 1763
1497 # Now check for the header files 1764 # Now check for the header files
1498 if tklib and tcllib: 1765 if tklib and tcllib:
1499 # Check for the include files on Debian and {Free,Open}BSD, where 1766 # Check for the include files on Debian and {Free,Open}BSD, where
1500 # they're put in /usr/include/{tcl,tk}X.Y 1767 # they're put in /usr/include/{tcl,tk}X.Y
1501 dotversion = version 1768 dotversion = version
1502 if '.' not in dotversion and "bsd" in sys.platform.lower(): 1769 if '.' not in dotversion and "bsd" in host_platform.lower():
1503 # OpenBSD and FreeBSD use Tcl/Tk library names like libtcl83.a, 1770 # OpenBSD and FreeBSD use Tcl/Tk library names like libtcl83.a,
1504 # but the include subdirs are named like .../include/tcl8.3. 1771 # but the include subdirs are named like .../include/tcl8.3.
1505 dotversion = dotversion[:-1] + '.' + dotversion[-1] 1772 dotversion = dotversion[:-1] + '.' + dotversion[-1]
1506 tcl_include_sub = [] 1773 tcl_include_sub = []
1507 tk_include_sub = [] 1774 tk_include_sub = []
1508 for dir in inc_dirs: 1775 for dir in inc_dirs:
1509 tcl_include_sub += [dir + os.sep + "tcl" + dotversion] 1776 tcl_include_sub += [dir + os.sep + "tcl" + dotversion]
1510 tk_include_sub += [dir + os.sep + "tk" + dotversion] 1777 tk_include_sub += [dir + os.sep + "tk" + dotversion]
1511 tk_include_sub += tcl_include_sub 1778 tk_include_sub += tcl_include_sub
1512 tcl_includes = find_file('tcl.h', inc_dirs, tcl_include_sub) 1779 tcl_includes = find_file('tcl.h', inc_dirs, tcl_include_sub)
1513 tk_includes = find_file('tk.h', inc_dirs, tk_include_sub) 1780 tk_includes = find_file('tk.h', inc_dirs, tk_include_sub)
1514 1781
1515 if (tcllib is None or tklib is None or 1782 if (tcllib is None or tklib is None or
1516 tcl_includes is None or tk_includes is None): 1783 tcl_includes is None or tk_includes is None):
1517 self.announce("INFO: Can't locate Tcl/Tk libs and/or headers", 2) 1784 self.announce("INFO: Can't locate Tcl/Tk libs and/or headers", 2)
1518 return 1785 return
1519 1786
1520 # OK... everything seems to be present for Tcl/Tk. 1787 # OK... everything seems to be present for Tcl/Tk.
1521 1788
1522 include_dirs = [] ; libs = [] ; defs = [] ; added_lib_dirs = [] 1789 include_dirs = [] ; libs = [] ; defs = [] ; added_lib_dirs = []
1523 for dir in tcl_includes + tk_includes: 1790 for dir in tcl_includes + tk_includes:
1524 if dir not in include_dirs: 1791 if dir not in include_dirs:
1525 include_dirs.append(dir) 1792 include_dirs.append(dir)
1526 1793
1527 # Check for various platform-specific directories 1794 # Check for various platform-specific directories
1528 if platform == 'sunos5': 1795 if host_platform == 'sunos5':
1529 include_dirs.append('/usr/openwin/include') 1796 include_dirs.append('/usr/openwin/include')
1530 added_lib_dirs.append('/usr/openwin/lib') 1797 added_lib_dirs.append('/usr/openwin/lib')
1798 elif host_platform in ['mingw', 'win32']:
1799 # mingw&win32 don't use X11 headers and libraries
1800 pass
1531 elif os.path.exists('/usr/X11R6/include'): 1801 elif os.path.exists('/usr/X11R6/include'):
1532 include_dirs.append('/usr/X11R6/include') 1802 include_dirs.append('/usr/X11R6/include')
1533 added_lib_dirs.append('/usr/X11R6/lib64') 1803 added_lib_dirs.append('/usr/X11R6/lib64')
1534 added_lib_dirs.append('/usr/X11R6/lib') 1804 added_lib_dirs.append('/usr/X11R6/lib')
1535 elif os.path.exists('/usr/X11R5/include'): 1805 elif os.path.exists('/usr/X11R5/include'):
1536 include_dirs.append('/usr/X11R5/include') 1806 include_dirs.append('/usr/X11R5/include')
1537 added_lib_dirs.append('/usr/X11R5/lib') 1807 added_lib_dirs.append('/usr/X11R5/lib')
1538 else: 1808 else:
1539 # Assume default location for X11 1809 # Assume default location for X11
1540 include_dirs.append('/usr/X11/include') 1810 include_dirs.append('/usr/X11/include')
1541 added_lib_dirs.append('/usr/X11/lib') 1811 added_lib_dirs.append('/usr/X11/lib')
1542 1812
1543 # If Cygwin, then verify that X is installed before proceeding 1813 # If Cygwin, then verify that X is installed before proceeding
1544 if platform == 'cygwin': 1814 if host_platform == 'cygwin':
1815 include_dirs.append('/usr/include')
1545 x11_inc = find_file('X11/Xlib.h', [], include_dirs) 1816 x11_inc = find_file('X11/Xlib.h', [], include_dirs)
1546 if x11_inc is None: 1817 if x11_inc is None:
1547 return 1818 return
1548 1819
1549 # Check for BLT extension 1820 # Check for BLT extension
1550 if self.compiler.find_library_file(lib_dirs + added_lib_dirs, 1821 if self.compiler.find_library_file(lib_dirs + added_lib_dirs,
1551 'BLT8.0'): 1822 'BLT8.0'):
1552 defs.append( ('WITH_BLT', 1) ) 1823 defs.append( ('WITH_BLT', 1) )
1553 libs.append('BLT8.0') 1824 libs.append('BLT8.0')
1554 elif self.compiler.find_library_file(lib_dirs + added_lib_dirs, 1825 elif self.compiler.find_library_file(lib_dirs + added_lib_dirs,
1555 'BLT'): 1826 'BLT'):
1556 defs.append( ('WITH_BLT', 1) ) 1827 defs.append( ('WITH_BLT', 1) )
1557 libs.append('BLT') 1828 libs.append('BLT')
1558 1829
1559 # Add the Tcl/Tk libraries 1830 # Add the Tcl/Tk libraries
1560 libs.append('tk'+ version) 1831 libs.append('tk'+ version)
1561 libs.append('tcl'+ version) 1832 libs.append('tcl'+ version)
1562 1833
1563 if platform in ['aix3', 'aix4']: 1834 if host_platform in ['aix3', 'aix4']:
1564 libs.append('ld') 1835 libs.append('ld')
1565 1836
1566 # Finally, link with the X11 libraries (not appropriate on cygwin) 1837 # Finally, link with the X11 libraries (not appropriate on cygwin, mingw )
1567 if platform != "cygwin" and platform != "win32": 1838 if not host_platform in ['cygwin', 'mingw', 'win32']:
1568 libs.append('X11') 1839 libs.append('X11')
1569 1840
1570 ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], 1841 ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
1571 define_macros=[('WITH_APPINIT', 1)] + defs, 1842 define_macros=[('WITH_APPINIT', 1)] + defs,
1572 include_dirs = include_dirs, 1843 include_dirs = include_dirs,
1573 libraries = libs, 1844 libraries = libs,
1574 library_dirs = added_lib_dirs, 1845 library_dirs = added_lib_dirs,
1575 ) 1846 )
1576 self.extensions.append(ext) 1847 self.extensions.append(ext)
1577 1848
1578 ## # Uncomment these lines if you want to play with xxmodule.c 1849 ## # Uncomment these lines if you want to play with xxmodule.c
1579 ## ext = Extension('xx', ['xxmodule.c']) 1850 ## ext = Extension('xx', ['xxmodule.c'])
1580 ## self.extensions.append(ext) 1851 ## self.extensions.append(ext)
1852 if 'd' not in sys.abiflags:
1853 ext = Extension('xxlimited', ['xxlimited.c'],
1854 define_macros=[('Py_LIMITED_API', 1)])
1855 self.extensions.append(ext)
1581 1856
1582 # XXX handle these, but how to detect? 1857 # XXX handle these, but how to detect?
1583 # *** Uncomment and edit for PIL (TkImaging) extension only: 1858 # *** Uncomment and edit for PIL (TkImaging) extension only:
1584 # -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \ 1859 # -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \
1585 # *** Uncomment and edit for TOGL extension only: 1860 # *** Uncomment and edit for TOGL extension only:
1586 # -DWITH_TOGL togl.c \ 1861 # -DWITH_TOGL togl.c \
1587 # *** Uncomment these for TOGL extension only: 1862 # *** Uncomment these for TOGL extension only:
1588 # -lGL -lGLU -lXext -lXmu \ 1863 # -lGL -lGLU -lXext -lXmu \
1589 1864
1590 def configure_ctypes_darwin(self, ext): 1865 def configure_ctypes_darwin(self, ext):
(...skipping 17 matching lines...) Expand all
1608 # Add .S (preprocessed assembly) to C compiler source extensions. 1883 # Add .S (preprocessed assembly) to C compiler source extensions.
1609 self.compiler.src_extensions.append('.S') 1884 self.compiler.src_extensions.append('.S')
1610 1885
1611 include_dirs = [os.path.join(ffi_srcdir, 'include'), 1886 include_dirs = [os.path.join(ffi_srcdir, 'include'),
1612 os.path.join(ffi_srcdir, 'powerpc')] 1887 os.path.join(ffi_srcdir, 'powerpc')]
1613 ext.include_dirs.extend(include_dirs) 1888 ext.include_dirs.extend(include_dirs)
1614 ext.sources.extend(sources) 1889 ext.sources.extend(sources)
1615 return True 1890 return True
1616 1891
1617 def configure_ctypes(self, ext): 1892 def configure_ctypes(self, ext):
1893 if host_platform in ['mingw', 'win32']:
1894 # win32 platform use own sources and includes
1895 # from Modules/_ctypes/libffi_msvc/
1896 srcdir = sysconfig.get_config_var('srcdir')
1897
1898 ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules',
1899 '_ctypes'))
1900 sources = [os.path.join(ffi_srcdir, p)
1901 for p in ['malloc_closure.c',
1902 ]]
1903 ext.sources.extend(sources)
1904
1905 ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules',
1906 '_ctypes', 'libffi_msvc'))
1907 #FIXME: _ctypes/libffi_msvc/win64.asm ?
1908 sources = [os.path.join(ffi_srcdir, p)
1909 for p in ['ffi.c',
1910 'prep_cif.c',
1911 'win32.S',
1912 ]]
1913 # NOTE: issue2942 don't resolve problem with assembler code.
1914 # It seems to me that python refuse to build an extension
1915 # if exist a source with unknown suffix.
1916 self.compiler.src_extensions.append('.s')
1917 self.compiler.src_extensions.append('.S')
1918 ext.include_dirs.append(ffi_srcdir)
1919 ext.sources.extend(sources)
1920 ext.libraries.extend(['ole32', 'oleaut32', 'uuid'])
1921 #AdditionalOptions="/EXPORT:DllGetClassObject,PRIVATE /EXPORT:DllCan UnloadNow,PRIVATE"
1922 ext.export_symbols.extend(['DllGetClassObject PRIVATE',
1923 'DllCanUnloadNow PRIVATE'])
1924 return True
1618 if not self.use_system_libffi: 1925 if not self.use_system_libffi:
1619 if sys.platform == 'darwin': 1926 if host_platform == 'darwin':
1620 return self.configure_ctypes_darwin(ext) 1927 return self.configure_ctypes_darwin(ext)
1621 1928
1622 srcdir = sysconfig.get_config_var('srcdir') 1929 srcdir = sysconfig.get_config_var('srcdir')
1623 ffi_builddir = os.path.join(self.build_temp, 'libffi') 1930 ffi_builddir = os.path.join(self.build_temp, 'libffi')
1624 ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules', 1931 ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules',
1625 '_ctypes', 'libffi')) 1932 '_ctypes', 'libffi'))
1626 ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.py') 1933 ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.py')
1627 1934
1628 from distutils.dep_util import newer_group 1935 from distutils.dep_util import newer_group
1629 1936
1630 config_sources = [os.path.join(ffi_srcdir, fname) 1937 config_sources = [os.path.join(ffi_srcdir, fname)
1631 for fname in os.listdir(ffi_srcdir) 1938 for fname in os.listdir(ffi_srcdir)
1632 if os.path.isfile(os.path.join(ffi_srcdir, fname)) ] 1939 if os.path.isfile(os.path.join(ffi_srcdir, fname)) ]
1633 if self.force or newer_group(config_sources, 1940 if self.force or newer_group(config_sources,
1634 ffi_configfile): 1941 ffi_configfile):
1635 from distutils.dir_util import mkpath 1942 from distutils.dir_util import mkpath
1636 mkpath(ffi_builddir) 1943 mkpath(ffi_builddir)
1637 config_args = [] 1944 config_args = [arg for arg in sysconfig.get_config_var("CONFIG_A RGS").split()
1638 1945 if (('--host=' in arg) or ('--build=' in arg))]
1639 if 'msys' in sys.builtin_module_names: 1946 if not self.verbose:
1640 w32_ffi_srcdir = ffi_srcdir 1947 config_args.append("-q")
1641 ffi_srcdir = msysize(ffi_srcdir) 1948
1642 # Pass empty CFLAGS because we'll just append the resulting 1949 # Pass empty CFLAGS because we'll just append the resulting
1643 # CFLAGS to Python's; -g or -O2 is to be avoided. 1950 # CFLAGS to Python's; -g or -O2 is to be avoided.
1644 cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \ 1951 cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \
1645 % (ffi_builddir, ffi_srcdir, " ".join(config_args)) 1952 % (ffi_builddir, ffi_srcdir, " ".join(config_args))
1646 1953
1647 if 'msys' in sys.builtin_module_names:
1648 ffi_srcdir = w32_ffi_srcdir
1649
1650 res = os.system(cmd) 1954 res = os.system(cmd)
1651 if res or not os.path.exists(ffi_configfile): 1955 if res or not os.path.exists(ffi_configfile):
1652 print("Failed to configure _ctypes module") 1956 print("Failed to configure _ctypes module")
1653 return False 1957 return False
1654 1958
1655 fficonfig = {} 1959 fficonfig = {}
1656 with open(ffi_configfile) as f: 1960 with open(ffi_configfile) as f:
1657 exec(f.read(), globals(), fficonfig) 1961 exec(f.read(), globals(), fficonfig)
1658 1962
1659 # Add .S (preprocessed assembly) to C compiler source extensions. 1963 # Add .S (preprocessed assembly) to C compiler source extensions.
1660 self.compiler.src_extensions.append('.S') 1964 self.compiler.src_extensions.append('.S')
1661 1965
1662 include_dirs = [os.path.join(ffi_builddir, 'include'), 1966 include_dirs = [os.path.join(ffi_builddir, 'include'),
1663 ffi_builddir, 1967 ffi_builddir,
1664 os.path.join(ffi_srcdir, 'src')] 1968 os.path.join(ffi_srcdir, 'src')]
1665 extra_compile_args = fficonfig['ffi_cflags'].split() 1969 extra_compile_args = fficonfig['ffi_cflags'].split()
1666 1970
1667 ext.sources.extend(os.path.join(ffi_srcdir, f) for f in 1971 ext.sources.extend(os.path.join(ffi_srcdir, f) for f in
1668 fficonfig['ffi_sources']) 1972 fficonfig['ffi_sources'])
1669 ext.include_dirs.extend(include_dirs) 1973 ext.include_dirs.extend(include_dirs)
1670 ext.extra_compile_args.extend(extra_compile_args) 1974 ext.extra_compile_args.extend(extra_compile_args)
1975 if host_platform in ['mingw', 'win32']:
1976 ext.libraries.extend(['ole32', 'oleaut32', 'uuid'])
1977 #AdditionalOptions="/EXPORT:DllGetClassObject,PRIVATE /EXPORT:Dl lCanUnloadNow,PRIVATE"
1978 ext.export_symbols.extend(['DllGetClassObject PRIVATE',
1979 'DllCanUnloadNow PRIVATE'])
1671 return True 1980 return True
1672 1981
1673 def detect_ctypes(self, inc_dirs, lib_dirs): 1982 def detect_ctypes(self, inc_dirs, lib_dirs):
1674 self.use_system_libffi = False 1983 self.use_system_libffi = False
1675 include_dirs = [] 1984 include_dirs = []
1676 extra_compile_args = [] 1985 extra_compile_args = []
1677 extra_link_args = [] 1986 extra_link_args = []
1678 sources = ['_ctypes/_ctypes.c', 1987 sources = ['_ctypes/_ctypes.c',
1679 '_ctypes/callbacks.c', 1988 '_ctypes/callbacks.c',
1680 '_ctypes/callproc.c', 1989 '_ctypes/callproc.c',
1681 '_ctypes/stgdict.c', 1990 '_ctypes/stgdict.c',
1682 '_ctypes/cfield.c', 1991 '_ctypes/cfield.c']
1683 '_ctypes/malloc_closure.c']
1684 depends = ['_ctypes/ctypes.h'] 1992 depends = ['_ctypes/ctypes.h']
1685 1993
1686 if sys.platform == 'darwin': 1994 if host_platform == 'darwin':
1995 sources.append('_ctypes/malloc_closure.c')
1687 sources.append('_ctypes/darwin/dlfcn_simple.c') 1996 sources.append('_ctypes/darwin/dlfcn_simple.c')
1688 extra_compile_args.append('-DMACOSX') 1997 extra_compile_args.append('-DMACOSX')
1689 include_dirs.append('_ctypes/darwin') 1998 include_dirs.append('_ctypes/darwin')
1690 # XXX Is this still needed? 1999 # XXX Is this still needed?
1691 ## extra_link_args.extend(['-read_only_relocs', 'warning']) 2000 ## extra_link_args.extend(['-read_only_relocs', 'warning'])
1692 2001
1693 elif sys.platform == 'sunos5': 2002 elif host_platform == 'sunos5':
1694 # XXX This shouldn't be necessary; it appears that some 2003 # XXX This shouldn't be necessary; it appears that some
1695 # of the assembler code is non-PIC (i.e. it has relocations 2004 # of the assembler code is non-PIC (i.e. it has relocations
1696 # when it shouldn't. The proper fix would be to rewrite 2005 # when it shouldn't. The proper fix would be to rewrite
1697 # the assembler code to be PIC. 2006 # the assembler code to be PIC.
1698 # This only works with GCC; the Sun compiler likely refuses 2007 # This only works with GCC; the Sun compiler likely refuses
1699 # this option. If you want to compile ctypes with the Sun 2008 # this option. If you want to compile ctypes with the Sun
1700 # compiler, please research a proper solution, instead of 2009 # compiler, please research a proper solution, instead of
1701 # finding some -z option for the Sun compiler. 2010 # finding some -z option for the Sun compiler.
1702 extra_link_args.append('-mimpure-text') 2011 extra_link_args.append('-mimpure-text')
1703 2012
1704 elif sys.platform.startswith('hp-ux'): 2013 elif host_platform.startswith('hp-ux'):
1705 extra_link_args.append('-fPIC') 2014 extra_link_args.append('-fPIC')
1706 2015
1707 ext = Extension('_ctypes', 2016 ext = Extension('_ctypes',
1708 include_dirs=include_dirs, 2017 include_dirs=include_dirs,
1709 extra_compile_args=extra_compile_args, 2018 extra_compile_args=extra_compile_args,
1710 extra_link_args=extra_link_args, 2019 extra_link_args=extra_link_args,
1711 libraries=[] if 'msys' not in sys.builtin_module_names e lse ['uuid', 'ole32', 'oleaut32'], 2020 libraries=[],
1712 sources=sources, 2021 sources=sources,
1713 depends=depends) 2022 depends=depends)
2023 if host_platform in ['mingw', 'win32']:
2024 ctypes_test_libs = ['oleaut32']
2025 else:
2026 ctypes_test_libs = []
1714 ext_test = Extension('_ctypes_test', 2027 ext_test = Extension('_ctypes_test',
1715 libraries=[] if 'msys' not in sys.builtin_module_na mes else ['oleaut32'], 2028 libraries=ctypes_test_libs,
1716 sources=['_ctypes/_ctypes_test.c']) 2029 sources=['_ctypes/_ctypes_test.c'])
1717 self.extensions.extend([ext, ext_test]) 2030 self.extensions.extend([ext, ext_test])
1718 2031
1719 if not '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"): 2032 if not '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"):
1720 return 2033 return
1721 2034
1722 if sys.platform == 'darwin': 2035 if host_platform == 'darwin':
1723 # OS X 10.5 comes with libffi.dylib; the include files are 2036 # OS X 10.5 comes with libffi.dylib; the include files are
1724 # in /usr/include/ffi 2037 # in /usr/include/ffi
1725 inc_dirs.append('/usr/include/ffi') 2038 inc_dirs.append('/usr/include/ffi')
1726 2039
1727 ffi_inc = [sysconfig.get_config_var("LIBFFI_INCLUDEDIR")] 2040 ffi_inc = [sysconfig.get_config_var("LIBFFI_INCLUDEDIR")]
1728 if not ffi_inc or ffi_inc[0] == '': 2041 if not ffi_inc or ffi_inc[0] == '':
1729 ffi_inc = find_file('ffi.h', [], inc_dirs) 2042 ffi_inc = find_file('ffi.h', [], inc_dirs)
1730 if ffi_inc is not None: 2043 if ffi_inc is not None:
1731 ffi_h = ffi_inc[0] + '/ffi.h' 2044 ffi_h = ffi_inc[0] + '/ffi.h'
1732 fp = open(ffi_h) 2045 with open(ffi_h) as fp:
1733 while 1: 2046 while 1:
1734 line = fp.readline() 2047 line = fp.readline()
1735 if not line: 2048 if not line:
1736 ffi_inc = None 2049 ffi_inc = None
1737 break 2050 break
1738 if line.startswith('#define LIBFFI_H'): 2051 if line.startswith('#define LIBFFI_H'):
1739 break 2052 break
1740 ffi_lib = None 2053 ffi_lib = None
1741 if ffi_inc is not None: 2054 if ffi_inc is not None:
1742 for lib_name in ('ffi_convenience', 'ffi_pic', 'ffi'): 2055 for lib_name in ('ffi_convenience', 'ffi_pic', 'ffi'):
1743 if (self.compiler.find_library_file(lib_dirs, lib_name)): 2056 if (self.compiler.find_library_file(lib_dirs, lib_name)):
1744 ffi_lib = lib_name 2057 ffi_lib = lib_name
1745 break 2058 break
1746 2059
1747 if ffi_inc and ffi_lib: 2060 if ffi_inc and ffi_lib:
1748 ext.include_dirs.extend(ffi_inc) 2061 ext.include_dirs.extend(ffi_inc)
1749 ext.libraries.append(ffi_lib) 2062 ext.libraries.append(ffi_lib)
1750 self.use_system_libffi = True 2063 self.use_system_libffi = True
1751 2064
2065 def _decimal_ext(self):
2066 extra_compile_args = []
2067 undef_macros = []
2068 if '--with-system-libmpdec' in sysconfig.get_config_var("CONFIG_ARGS"):
2069 include_dirs = []
2070 libraries = ['mpdec']
2071 sources = ['_decimal/_decimal.c']
2072 depends = ['_decimal/docstrings.h']
2073 else:
2074 srcdir = sysconfig.get_config_var('srcdir')
2075 include_dirs = [os.path.abspath(os.path.join(srcdir,
2076 'Modules',
2077 '_decimal',
2078 'libmpdec'))]
2079 libraries = []
2080 sources = [
2081 '_decimal/_decimal.c',
2082 '_decimal/libmpdec/basearith.c',
2083 '_decimal/libmpdec/constants.c',
2084 '_decimal/libmpdec/context.c',
2085 '_decimal/libmpdec/convolute.c',
2086 '_decimal/libmpdec/crt.c',
2087 '_decimal/libmpdec/difradix2.c',
2088 '_decimal/libmpdec/fnt.c',
2089 '_decimal/libmpdec/fourstep.c',
2090 '_decimal/libmpdec/io.c',
2091 '_decimal/libmpdec/memory.c',
2092 '_decimal/libmpdec/mpdecimal.c',
2093 '_decimal/libmpdec/numbertheory.c',
2094 '_decimal/libmpdec/sixstep.c',
2095 '_decimal/libmpdec/transpose.c',
2096 ]
2097 depends = [
2098 '_decimal/docstrings.h',
2099 '_decimal/libmpdec/basearith.h',
2100 '_decimal/libmpdec/bits.h',
2101 '_decimal/libmpdec/constants.h',
2102 '_decimal/libmpdec/convolute.h',
2103 '_decimal/libmpdec/crt.h',
2104 '_decimal/libmpdec/difradix2.h',
2105 '_decimal/libmpdec/fnt.h',
2106 '_decimal/libmpdec/fourstep.h',
2107 '_decimal/libmpdec/io.h',
2108 '_decimal/libmpdec/memory.h',
2109 '_decimal/libmpdec/mpdecimal.h',
2110 '_decimal/libmpdec/numbertheory.h',
2111 '_decimal/libmpdec/sixstep.h',
2112 '_decimal/libmpdec/transpose.h',
2113 '_decimal/libmpdec/typearith.h',
2114 '_decimal/libmpdec/umodarith.h',
2115 ]
2116
2117 config = {
2118 'x64': [('CONFIG_64','1'), ('ASM','1')],
2119 'uint128': [('CONFIG_64','1'), ('ANSI','1'), ('HAVE_UINT128_T','1')],
2120 'ansi64': [('CONFIG_64','1'), ('ANSI','1')],
2121 'ppro': [('CONFIG_32','1'), ('PPRO','1'), ('ASM','1')],
2122 'ansi32': [('CONFIG_32','1'), ('ANSI','1')],
2123 'ansi-legacy': [('CONFIG_32','1'), ('ANSI','1'),
2124 ('LEGACY_COMPILER','1')],
2125 'universal': [('UNIVERSAL','1')]
2126 }
2127
2128 cc = sysconfig.get_config_var('CC')
2129 sizeof_size_t = sysconfig.get_config_var('SIZEOF_SIZE_T')
2130 machine = os.environ.get('PYTHON_DECIMAL_WITH_MACHINE')
2131
2132 if machine:
2133 # Override automatic configuration to facilitate testing.
2134 define_macros = config[machine]
2135 elif host_platform == 'darwin':
2136 # Universal here means: build with the same options Python
2137 # was built with.
2138 define_macros = config['universal']
2139 elif sizeof_size_t == 8:
2140 if sysconfig.get_config_var('HAVE_GCC_ASM_FOR_X64'):
2141 define_macros = config['x64']
2142 elif sysconfig.get_config_var('HAVE_GCC_UINT128_T'):
2143 define_macros = config['uint128']
2144 else:
2145 define_macros = config['ansi64']
2146 elif sizeof_size_t == 4:
2147 ppro = sysconfig.get_config_var('HAVE_GCC_ASM_FOR_X87')
2148 if ppro and ('gcc' in cc or 'clang' in cc) and \
2149 not 'sunos' in host_platform:
2150 # solaris: problems with register allocation.
2151 # icc >= 11.0 works as well.
2152 define_macros = config['ppro']
2153 extra_compile_args.append('-Wno-unknown-pragmas')
2154 else:
2155 define_macros = config['ansi32']
2156 else:
2157 raise DistutilsError("_decimal: unsupported architecture")
2158
2159 # Workarounds for toolchain bugs:
2160 if sysconfig.get_config_var('HAVE_IPA_PURE_CONST_BUG'):
2161 # Some versions of gcc miscompile inline asm:
2162 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
2163 # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
2164 extra_compile_args.append('-fno-ipa-pure-const')
2165 if sysconfig.get_config_var('HAVE_GLIBC_MEMMOVE_BUG'):
2166 # _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
2167 # http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
2168 undef_macros.append('_FORTIFY_SOURCE')
2169
2170 # Faster version without thread local contexts:
2171 if not sysconfig.get_config_var('WITH_THREAD'):
2172 define_macros.append(('WITHOUT_THREADS', 1))
2173
2174 # Uncomment for extra functionality:
2175 #define_macros.append(('EXTRA_FUNCTIONALITY', 1))
2176 ext = Extension (
2177 '_decimal',
2178 include_dirs=include_dirs,
2179 libraries=libraries,
2180 define_macros=define_macros,
2181 undef_macros=undef_macros,
2182 extra_compile_args=extra_compile_args,
2183 sources=sources,
2184 depends=depends
2185 )
2186 return ext
1752 2187
1753 class PyBuildInstall(install): 2188 class PyBuildInstall(install):
1754 # Suppress the warning about installation into the lib_dynload 2189 # Suppress the warning about installation into the lib_dynload
1755 # directory, which is not in sys.path when running Python during 2190 # directory, which is not in sys.path when running Python during
1756 # installation: 2191 # installation:
1757 def initialize_options (self): 2192 def initialize_options (self):
1758 install.initialize_options(self) 2193 install.initialize_options(self)
1759 self.warn_dir=0 2194 self.warn_dir=0
1760 2195
2196 # Customize subcommands to not install an egg-info file for Python
2197 sub_commands = [('install_lib', install.has_lib),
2198 ('install_headers', install.has_headers),
2199 ('install_scripts', install.has_scripts),
2200 ('install_data', install.has_data)]
2201
2202
1761 class PyBuildInstallLib(install_lib): 2203 class PyBuildInstallLib(install_lib):
1762 # Do exactly what install_lib does but make sure correct access modes get 2204 # Do exactly what install_lib does but make sure correct access modes get
1763 # set on installed directories and files. All installed files with get 2205 # set on installed directories and files. All installed files with get
1764 # mode 644 unless they are a shared library in which case they will get 2206 # mode 644 unless they are a shared library in which case they will get
1765 # mode 755. All installed directories will get mode 755. 2207 # mode 755. All installed directories will get mode 755.
1766 2208
1767 so_ext = sysconfig.get_config_var("SO") 2209 so_ext = sysconfig.get_config_var("SO")
1768 2210
1769 def install(self): 2211 def install(self):
1770 outfiles = install_lib.install(self) 2212 outfiles = install_lib.install(self)
(...skipping 15 matching lines...) Expand all
1786 def set_dir_modes(self, dirname, mode): 2228 def set_dir_modes(self, dirname, mode):
1787 if not self.is_chmod_supported(): return 2229 if not self.is_chmod_supported(): return
1788 for dirpath, dirnames, fnames in os.walk(dirname): 2230 for dirpath, dirnames, fnames in os.walk(dirname):
1789 if os.path.islink(dirpath): 2231 if os.path.islink(dirpath):
1790 continue 2232 continue
1791 log.info("changing mode of %s to %o", dirpath, mode) 2233 log.info("changing mode of %s to %o", dirpath, mode)
1792 if not self.dry_run: os.chmod(dirpath, mode) 2234 if not self.dry_run: os.chmod(dirpath, mode)
1793 2235
1794 def is_chmod_supported(self): 2236 def is_chmod_supported(self):
1795 return hasattr(os, 'chmod') 2237 return hasattr(os, 'chmod')
2238
2239 class PyBuildScripts(build_scripts):
2240 def copy_scripts(self):
2241 outfiles, updated_files = build_scripts.copy_scripts(self)
2242 print('sys.version_info=%s' % str(sys.version_info))
2243 fullversion = '-{0[0]}{0[1]}'.format(sys.version_info)
2244 minoronly = '{0[1]}'.format(sys.version_info)
2245 newoutfiles = []
2246 newupdated_files = []
2247 for filename in outfiles:
2248 if filename.endswith(('2to3', 'pyvenv')):
2249 newfilename = filename + fullversion
2250 else:
2251 newfilename = filename + minoronly
2252 log.info('renaming {} to {}'.format(filename, newfilename))
2253 if os.path.isfile(newfilename):
2254 os.remove(newfilename)
2255 os.rename(filename, newfilename)
2256 newoutfiles.append(newfilename)
2257 if filename in updated_files:
2258 newupdated_files.append(newfilename)
2259 return newoutfiles, newupdated_files
1796 2260
1797 SUMMARY = """ 2261 SUMMARY = """
1798 Python is an interpreted, interactive, object-oriented programming 2262 Python is an interpreted, interactive, object-oriented programming
1799 language. It is often compared to Tcl, Perl, Scheme or Java. 2263 language. It is often compared to Tcl, Perl, Scheme or Java.
1800 2264
1801 Python combines remarkable power with very clear syntax. It has 2265 Python combines remarkable power with very clear syntax. It has
1802 modules, classes, exceptions, very high level dynamic data types, and 2266 modules, classes, exceptions, very high level dynamic data types, and
1803 dynamic typing. There are interfaces to many system calls and 2267 dynamic typing. There are interfaces to many system calls and
1804 libraries, as well as to various windowing systems (X11, Motif, Tk, 2268 libraries, as well as to various windowing systems (X11, Motif, Tk,
1805 Mac, MFC). New built-in modules are easily written in C or C++. Python 2269 Mac, MFC). New built-in modules are easily written in C or C++. Python
(...skipping 26 matching lines...) Expand all
1832 url = "http://www.python.org/%s" % sys.version[:3], 2296 url = "http://www.python.org/%s" % sys.version[:3],
1833 maintainer = "Guido van Rossum and the Python community", 2297 maintainer = "Guido van Rossum and the Python community",
1834 maintainer_email = "python-dev@python.org", 2298 maintainer_email = "python-dev@python.org",
1835 description = "A high-level object-oriented programming language", 2299 description = "A high-level object-oriented programming language",
1836 long_description = SUMMARY.strip(), 2300 long_description = SUMMARY.strip(),
1837 license = "PSF license", 2301 license = "PSF license",
1838 classifiers = [x for x in CLASSIFIERS.split("\n") if x], 2302 classifiers = [x for x in CLASSIFIERS.split("\n") if x],
1839 platforms = ["Many"], 2303 platforms = ["Many"],
1840 2304
1841 # Build info 2305 # Build info
1842 cmdclass = {'build_ext':PyBuildExt, 'install':PyBuildInstall, 2306 cmdclass = {'build_ext': PyBuildExt,
1843 'install_lib':PyBuildInstallLib}, 2307 'build_scripts': PyBuildScripts,
2308 'install': PyBuildInstall,
2309 'install_lib': PyBuildInstallLib},
1844 # The struct module is defined here, because build_ext won't be 2310 # The struct module is defined here, because build_ext won't be
1845 # called unless there's at least one extension module defined. 2311 # called unless there's at least one extension module defined.
1846 ext_modules=[Extension('_struct', ['_struct.c'])], 2312 ext_modules=[Extension('_struct', ['_struct.c'])],
1847 2313
2314 # If you change the scripts installed here, you also need to
2315 # check the PyBuildScripts command above, and change the links
2316 # created by the bininstall target in Makefile.pre.in
1848 scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3", 2317 scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3",
1849 "Tools/scripts/2to3"] 2318 "Tools/scripts/2to3", "Tools/scripts/pyvenv"]
1850 ) 2319 )
1851 2320
1852 # --install-platlib 2321 # --install-platlib
1853 if __name__ == '__main__': 2322 if __name__ == '__main__':
1854 main() 2323 main()
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+