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

Side by Side Diff: setup.py

Issue 3871: cross and native build of python for mingw32 with distutils
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:
View unified diff | Download patch
« no previous file with comments | « setup_info.in ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Autodetecting setup.py script for building the Python extensions 1 # Autodetecting setup.py script for building the Python extensions
2 # 2 #
3 3
4 import sys, os, imp, re, optparse 4 import sys, os, imp, re, optparse
5 from glob import glob 5 from glob import glob
6 import sysconfig 6 import sysconfig
7 7
8 from distutils import log 8 from distutils import log
9 from distutils import text_file 9 from distutils import text_file
10 from distutils.errors import * 10 from distutils.errors import *
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 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))
185 if "_ctypes" in ext_map: 185 if "_ctypes" in ext_map:
186 ctypes = extensions.pop(ext_map["_ctypes"]) 186 ctypes = extensions.pop(ext_map["_ctypes"])
187 extensions.append(ctypes) 187 extensions.append(ctypes)
188 self.extensions = extensions 188 self.extensions = extensions
189 189
190 # Fix up the autodetected modules, prefixing all the source files 190 # Fix up the autodetected modules, prefixing all the source files
191 # with Modules/. 191 # with Modules/.
192 srcdir = sysconfig.get_config_var('srcdir') 192 srcdir = sysconfig.get_config_var('srcdir')
193 if not srcdir: 193 if not srcdir:
194 # Maybe running on Windows but not using CYGWIN? 194 # Maybe running on Windows but not using posix build?
195 raise ValueError("No source directory; cannot proceed.") 195 raise ValueError("No source directory; cannot proceed.")
196 srcdir = os.path.abspath(srcdir) 196 srcdir = os.path.abspath(srcdir)
197 moddirlist = [os.path.join(srcdir, 'Modules')] 197 moddirlist = [os.path.join(srcdir, 'Modules')]
198 198
199 # Fix up the paths for scripts, too 199 # Fix up the paths for scripts, too
200 self.distribution.scripts = [os.path.join(srcdir, filename) 200 self.distribution.scripts = [os.path.join(srcdir, filename)
201 for filename in self.distribution.scripts] 201 for filename in self.distribution.scripts]
202 202
203 # Python header files 203 # Python header files
204 headers = [sysconfig.get_config_h_filename()] 204 headers = [sysconfig.get_config_h_filename()]
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 238
239 # 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
240 # those environment variables passed into the setup.py phase. Here's 240 # those environment variables passed into the setup.py phase. Here's
241 # a small set of useful ones. 241 # a small set of useful ones.
242 compiler = os.environ.get('CC') 242 compiler = os.environ.get('CC')
243 args = {} 243 args = {}
244 # unfortunately, distutils doesn't let us provide separate C and C++ 244 # unfortunately, distutils doesn't let us provide separate C and C++
245 # compilers 245 # compilers
246 if compiler is not None: 246 if compiler is not None:
247 (ccshared,cflags) = sysconfig.get_config_vars('CCSHARED','CFLAGS') 247 (ccshared,cflags) = sysconfig.get_config_vars('CCSHARED','CFLAGS')
248 args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags 248 # distutils set first cflags then ccshared
249 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)
250 280
251 build_ext.build_extensions(self) 281 build_ext.build_extensions(self)
252 282
253 longest = max([len(e.name) for e in self.extensions]) 283 longest = max([len(e.name) for e in self.extensions])
254 if self.failed: 284 if self.failed:
255 longest = max(longest, max([len(name) for name in self.failed])) 285 longest = max(longest, max([len(name) for name in self.failed]))
256 286
257 def print_three_column(lst): 287 def print_three_column(lst):
258 lst.sort(key=str.lower) 288 lst.sort(key=str.lower)
259 # guarantee zip() doesn't drop anything 289 # guarantee zip() doesn't drop anything
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 # process will fail. 339 # process will fail.
310 self.announce( 340 self.announce(
311 'WARNING: skipping import check for "%s"' % 341 'WARNING: skipping import check for "%s"' %
312 ext.name) 342 ext.name)
313 return 343 return
314 344
315 # Workaround for Cygwin: Cygwin currently has fork issues when many 345 # Workaround for Cygwin: Cygwin currently has fork issues when many
316 # modules have been imported 346 # modules have been imported
317 if host_platform == 'cygwin': 347 if host_platform == 'cygwin':
318 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 "'
319 % ext.name) 353 % ext.name)
320 return 354 return
321 ext_filename = os.path.join( 355 ext_filename = os.path.join(
322 self.build_lib, 356 self.build_lib,
323 self.get_ext_filename(self.get_ext_fullname(ext.name))) 357 self.get_ext_filename(self.get_ext_fullname(ext.name)))
324 358
325 # If the build directory didn't exist when setup.py was 359 # If the build directory didn't exist when setup.py was
326 # started, sys.path_importer_cache has a negative result 360 # started, sys.path_importer_cache has a negative result
327 # cached. Clear that cache before trying to import. 361 # cached. Clear that cache before trying to import.
328 sys.path_importer_cache.clear() 362 sys.path_importer_cache.clear()
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 if '/gcc/' not in d: 468 if '/gcc/' not in d:
435 add_dir_to_list(self.compiler.library_dirs, 469 add_dir_to_list(self.compiler.library_dirs,
436 d) 470 d)
437 elif is_gcc and in_incdirs and '/gcc/' not in line: 471 elif is_gcc and in_incdirs and '/gcc/' not in line:
438 add_dir_to_list(self.compiler.include_dirs, 472 add_dir_to_list(self.compiler.include_dirs,
439 line.strip()) 473 line.strip())
440 finally: 474 finally:
441 os.unlink(tmpfile) 475 os.unlink(tmpfile)
442 476
443 def detect_modules(self): 477 def detect_modules(self):
478 pyconfig_h_data = open('pyconfig.h').read()
479 setup_info_data = open('setup_info').read()
480
444 # Ensure that /usr/local is always used, but the local build 481 # Ensure that /usr/local is always used, but the local build
445 # directories (i.e. '.' and 'Include') must be first. See issue 482 # directories (i.e. '.' and 'Include') must be first. See issue
446 # 10520. 483 # 10520.
447 if not cross_compiling: 484 if not cross_compiling:
448 add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') 485 add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
449 add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') 486 add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
450 # only change this for cross builds for 3.3, issues on Mageia 487 # only change this for cross builds for 3.3, issues on Mageia
451 if cross_compiling: 488 if cross_compiling:
452 self.add_gcc_paths() 489 self.add_gcc_paths()
453 self.add_multiarch_paths() 490 self.add_multiarch_paths()
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 if options.dirs: 522 if options.dirs:
486 for directory in reversed(options.dirs): 523 for directory in reversed(options.dirs):
487 add_dir_to_list(dir_list, directory) 524 add_dir_to_list(dir_list, directory)
488 525
489 if os.path.normpath(sys.base_prefix) != '/usr' \ 526 if os.path.normpath(sys.base_prefix) != '/usr' \
490 and not sysconfig.get_config_var('PYTHONFRAMEWORK'): 527 and not sysconfig.get_config_var('PYTHONFRAMEWORK'):
491 # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework 528 # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework
492 # (PYTHONFRAMEWORK is set) to avoid # linking problems when 529 # (PYTHONFRAMEWORK is set) to avoid # linking problems when
493 # building a framework with different architectures than 530 # building a framework with different architectures than
494 # the one that is currently installed (issue #7473) 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 !
495 add_dir_to_list(self.compiler.library_dirs, 537 add_dir_to_list(self.compiler.library_dirs,
496 sysconfig.get_config_var("LIBDIR")) 538 sysconfig.get_config_var("LIBDIR"))
497 add_dir_to_list(self.compiler.include_dirs, 539 add_dir_to_list(self.compiler.include_dirs,
498 sysconfig.get_config_var("INCLUDEDIR")) 540 sysconfig.get_config_var("INCLUDEDIR"))
499 541
500 # lib_dirs and inc_dirs are used to search for files; 542 # lib_dirs and inc_dirs are used to search for files;
501 # 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
502 # be assumed that no additional -I,-L directives are needed. 544 # be assumed that no additional -I,-L directives are needed.
503 if not cross_compiling: 545 if not cross_compiling:
504 lib_dirs = self.compiler.library_dirs + [ 546 lib_dirs = self.compiler.library_dirs + [
(...skipping 14 matching lines...) Expand all
519 srcdir = sysconfig.get_config_var('srcdir') 561 srcdir = sysconfig.get_config_var('srcdir')
520 562
521 # 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)
522 if host_platform in ['osf1', 'unixware7', 'openunix8']: 564 if host_platform in ['osf1', 'unixware7', 'openunix8']:
523 lib_dirs += ['/usr/ccs/lib'] 565 lib_dirs += ['/usr/ccs/lib']
524 566
525 # HP-UX11iv3 keeps files in lib/hpux folders. 567 # HP-UX11iv3 keeps files in lib/hpux folders.
526 if host_platform == 'hp-ux11': 568 if host_platform == 'hp-ux11':
527 lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32'] 569 lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32']
528 570
529 if host_platform == 'darwin': 571 if host_platform in ['darwin', 'mingw', 'win32']:
530 # This should work on any unixy platform ;-) 572 # This should work on any unixy platform ;-)
531 # If the user has bothered specifying additional -I and -L flags 573 # If the user has bothered specifying additional -I and -L flags
532 # in OPT and LDFLAGS we might as well use them here. 574 # in OPT and LDFLAGS we might as well use them here.
533 # 575 #
534 # NOTE: using shlex.split would technically be more correct, but 576 # NOTE: using shlex.split would technically be more correct, but
535 # also gives a bootstrap problem. Let's hope nobody uses 577 # also gives a bootstrap problem. Let's hope nobody uses
536 # directories with whitespace in the name to store libraries. 578 # directories with whitespace in the name to store libraries.
579 # FIXME: Why LDFLAGS again ?
537 cflags, ldflags = sysconfig.get_config_vars( 580 cflags, ldflags = sysconfig.get_config_vars(
538 'CFLAGS', 'LDFLAGS') 581 'CFLAGS', 'LDFLAGS')
539 for item in cflags.split(): 582 for item in cflags.split():
540 if item.startswith('-I'): 583 if item.startswith('-I'):
541 inc_dirs.append(item[2:]) 584 inc_dirs.append(item[2:])
542 585
543 for item in ldflags.split(): 586 for item in ldflags.split():
544 if item.startswith('-L'): 587 if item.startswith('-L'):
545 lib_dirs.append(item[2:]) 588 lib_dirs.append(item[2:])
546 589
547 # 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
548 math_libs = ['m'] 591 math_libs = ['m']
549 if host_platform == 'darwin': 592 if host_platform in ['darwin', 'mingw', 'win32']:
550 math_libs = [] 593 math_libs = []
551 594
552 # XXX Omitted modules: gl, pure, dl, SGI-specific modules 595 # XXX Omitted modules: gl, pure, dl, SGI-specific modules
553 596
554 # 597 #
555 # The following modules are all pretty straightforward, and compile 598 # The following modules are all pretty straightforward, and compile
556 # on pretty much any POSIXish platform. 599 # on pretty much any POSIXish platform.
557 # 600 #
558 601
559 # array objects 602 # array objects
560 exts.append( Extension('array', ['arraymodule.c']) ) 603 exts.append( Extension('array', ['arraymodule.c']) )
561 # complex math library functions 604 # complex math library functions
562 exts.append( Extension('cmath', ['cmathmodule.c', '_math.c'], 605 exts.append( Extension('cmath', ['cmathmodule.c', '_math.c'],
563 depends=['_math.h'], 606 depends=['_math.h'],
564 libraries=math_libs) ) 607 libraries=math_libs) )
565 # math library functions, e.g. sin() 608 # math library functions, e.g. sin()
566 exts.append( Extension('math', ['mathmodule.c', '_math.c'], 609 exts.append( Extension('math', ['mathmodule.c', '_math.c'],
567 depends=['_math.h'], 610 depends=['_math.h'],
568 libraries=math_libs) ) 611 libraries=math_libs) )
569 612
570 # time libraries: librt may be needed for clock_gettime() 613 # time libraries: librt may be needed for clock_gettime()
571 time_libs = [] 614 time_libs = []
572 lib = sysconfig.get_config_var('TIMEMODULE_LIB') 615 lib = sysconfig.get_config_var('TIMEMODULE_LIB')
616
573 if lib: 617 if lib:
574 time_libs.append(lib) 618 time_libs.append(lib)
575 619
576 # time operations and variables 620 # time operations and variables
577 exts.append( Extension('time', ['timemodule.c'], 621 exts.append( Extension('time', ['timemodule.c'],
578 libraries=time_libs) ) 622 libraries=time_libs) )
579 exts.append( Extension('_datetime', ['_datetimemodule.c']) ) 623 exts.append( Extension('_datetime', ['_datetimemodule.c']) )
580 # random number generator implemented in C 624 # random number generator implemented in C
581 exts.append( Extension("_random", ["_randommodule.c"]) ) 625 exts.append( Extension("_random", ["_randommodule.c"]) )
582 # bisect 626 # bisect
(...skipping 14 matching lines...) Expand all
597 # profiler (_lsprof is for cProfile.py) 641 # profiler (_lsprof is for cProfile.py)
598 exts.append( Extension('_lsprof', ['_lsprof.c', 'rotatingtree.c']) ) 642 exts.append( Extension('_lsprof', ['_lsprof.c', 'rotatingtree.c']) )
599 # static Unicode character database 643 # static Unicode character database
600 exts.append( Extension('unicodedata', ['unicodedata.c']) ) 644 exts.append( Extension('unicodedata', ['unicodedata.c']) )
601 645
602 # Modules with some UNIX dependencies -- on by default: 646 # Modules with some UNIX dependencies -- on by default:
603 # (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
604 # supported...) 648 # supported...)
605 649
606 # fcntl(2) and ioctl(2) 650 # fcntl(2) and ioctl(2)
607 libs = [] 651 if host_platform not in ['mingw', 'win32']:
608 if (config_h_vars.get('FLOCK_NEEDS_LIBBSD', False)): 652 libs = []
609 # May be necessary on AIX for flock function 653 if (config_h_vars.get('FLOCK_NEEDS_LIBBSD', False)):
610 libs = ['bsd'] 654 # May be necessary on AIX for flock function
611 exts.append( Extension('fcntl', ['fcntlmodule.c'], libraries=libs) ) 655 libs = ['bsd']
612 # pwd(3) 656 exts.append( Extension('fcntl', ['fcntlmodule.c'], libraries=libs) )
613 exts.append( Extension('pwd', ['pwdmodule.c']) )
614 # grp(3)
615 exts.append( Extension('grp', ['grpmodule.c']) )
616 # spwd, shadow passwords
617 if (config_h_vars.get('HAVE_GETSPNAM', False) or
618 config_h_vars.get('HAVE_GETSPENT', False)):
619 exts.append( Extension('spwd', ['spwdmodule.c']) )
620 else: 657 else:
621 missing.append('spwd') 658 missing.append('fcntl')
659 if host_platform not in ['mingw', 'win32']:
660 # pwd(3)
661 exts.append( Extension('pwd', ['pwdmodule.c']) )
662 # grp(3)
663 exts.append( Extension('grp', ['grpmodule.c']) )
664 # spwd, shadow passwords
665 if (config_h_vars.get('HAVE_GETSPNAM', False) or
666 config_h_vars.get('HAVE_GETSPENT', False)):
667 exts.append( Extension('spwd', ['spwdmodule.c']) )
668 else:
669 missing.append('spwd')
670 else:
671 missing.extend(['pwd', 'grp', 'spwd'])
622 672
623 # select(2); not on ancient System V 673 # select(2); not on ancient System V
624 exts.append( Extension('select', ['selectmodule.c']) ) 674 if host_platform in ['mingw', 'win32']:
675 select_libs = ['ws2_32']
676 else:
677 select_libs = []
678 exts.append( Extension('select', ['selectmodule.c'],
679 libraries=select_libs) )
625 680
626 # Fred Drake's interface to the Python parser 681 # Fred Drake's interface to the Python parser
627 exts.append( Extension('parser', ['parsermodule.c']) ) 682 exts.append( Extension('parser', ['parsermodule.c']) )
628 683
629 # Memory-mapped files (also works on Win32). 684 # Memory-mapped files (also works on Win32).
630 exts.append( Extension('mmap', ['mmapmodule.c']) ) 685 exts.append( Extension('mmap', ['mmapmodule.c']) )
631 686
632 # Lance Ellinghaus's syslog module 687 # Lance Ellinghaus's syslog module
633 # syslog daemon interface 688 if host_platform not in ['mingw', 'win32']:
634 exts.append( Extension('syslog', ['syslogmodule.c']) ) 689 # syslog daemon interface
690 exts.append( Extension('syslog', ['syslogmodule.c']) )
691 else:
692 missing.append('syslog')
635 693
636 # 694 #
637 # Here ends the simple stuff. From here on, modules need certain 695 # Here ends the simple stuff. From here on, modules need certain
638 # libraries, are platform-specific, or present other surprises. 696 # libraries, are platform-specific, or present other surprises.
639 # 697 #
640 698
641 # Multimedia modules 699 # Multimedia modules
642 # These don't work for 64-bit platforms!!! 700 # These don't work for 64-bit platforms!!!
643 # These represent audio samples or images as strings: 701 # These represent audio samples or images as strings:
644 702
645 # Operations on audio samples 703 # Operations on audio samples
646 # According to #993173, this one should actually work fine on 704 # According to #993173, this one should actually work fine on
647 # 64-bit platforms. 705 # 64-bit platforms.
648 exts.append( Extension('audioop', ['audioop.c']) ) 706 exts.append( Extension('audioop', ['audioop.c']) )
649 707
650 # readline 708 # readline
651 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
652 readline_termcap_library = "" 711 readline_termcap_library = ""
653 curses_library = "" 712 curses_library = ""
654 # Cannot use os.popen here in py3k. 713 # Cannot use os.popen here in py3k.
655 tmpfile = os.path.join(self.build_temp, 'readline_termcap_lib') 714 tmpfile = os.path.join(self.build_temp, 'readline_termcap_lib')
656 if not os.path.exists(self.build_temp): 715 if not os.path.exists(self.build_temp):
657 os.makedirs(self.build_temp) 716 os.makedirs(self.build_temp)
658 # Determine if readline is already linked against curses or tinfo. 717 # Determine if readline is already linked against curses or tinfo.
718 # NOTE readline_termcap_library flag is used only if
719 # cannot determine readline libs (see configure.in checks)
720 readline_conf = False
721 readline_conf_termcap = ""
659 if do_readline: 722 if do_readline:
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')
660 if cross_compiling: 741 if cross_compiling:
661 ret = os.system("%s -d %s | grep '(NEEDED)' > %s" \ 742 ret = os.system("%s -d %s 2>/dev/null | grep '(NEEDED)' > %s" \
662 % (sysconfig.get_config_var('READELF'), 743 % (sysconfig.get_config_var('READELF'),
663 do_readline, tmpfile)) 744 do_readline, tmpfile))
664 elif find_executable('ldd'): 745 elif find_executable('ldd'):
665 ret = os.system("ldd %s > %s" % (do_readline, tmpfile)) 746 ret = os.system("ldd %s > %s" % (do_readline, tmpfile))
666 else: 747 else:
667 ret = 256 748 ret = 256
668 if ret >> 8 == 0: 749 if ret >> 8 == 0:
669 with open(tmpfile) as fp: 750 with open(tmpfile) as fp:
670 for ln in fp: 751 for ln in fp:
671 if 'curses' in ln: 752 if 'curses' in ln:
672 readline_termcap_library = re.sub( 753 readline_termcap_library = re.sub(
673 r'.*lib(n?cursesw?)\.so.*', r'\1', ln 754 r'.*lib(n?cursesw?)\.so.*', r'\1', ln
674 ).rstrip() 755 ).rstrip()
675 break 756 break
676 # termcap interface split out from ncurses 757 # termcap interface split out from ncurses
677 if 'tinfo' in ln: 758 if 'tinfo' in ln:
678 readline_termcap_library = 'tinfo' 759 readline_termcap_library = 'tinfo'
679 break 760 break
680 if os.path.exists(tmpfile): 761 if os.path.exists(tmpfile):
681 os.unlink(tmpfile) 762 os.unlink(tmpfile)
682 # Issue 7384: If readline is already linked against curses, 763 # Issue 7384: If readline is already linked against curses,
683 # use the same library for the readline and curses modules. 764 # use the same library for the readline and curses modules.
684 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:
685 curses_library = readline_termcap_library 768 curses_library = readline_termcap_library
686 elif self.compiler.find_library_file(lib_dirs, 'ncursesw'): 769 elif self.compiler.find_library_file(lib_dirs, 'ncursesw'):
687 curses_library = 'ncursesw' 770 curses_library = 'ncursesw'
688 elif self.compiler.find_library_file(lib_dirs, 'ncurses'): 771 elif self.compiler.find_library_file(lib_dirs, 'ncurses'):
689 curses_library = 'ncurses' 772 curses_library = 'ncurses'
690 elif self.compiler.find_library_file(lib_dirs, 'curses'): 773 elif self.compiler.find_library_file(lib_dirs, 'curses'):
691 curses_library = 'curses' 774 curses_library = 'curses'
692 775
693 if host_platform == 'darwin': 776 if host_platform == 'darwin':
694 os_release = int(os.uname()[2].split('.')[0]) 777 os_release = int(os.uname()[2].split('.')[0])
(...skipping 28 matching lines...) Expand all
723 readline_libs.append('termcap') 806 readline_libs.append('termcap')
724 exts.append( Extension('readline', ['readline.c'], 807 exts.append( Extension('readline', ['readline.c'],
725 library_dirs=['/usr/lib/termcap'], 808 library_dirs=['/usr/lib/termcap'],
726 extra_link_args=readline_extra_link_args, 809 extra_link_args=readline_extra_link_args,
727 libraries=readline_libs) ) 810 libraries=readline_libs) )
728 else: 811 else:
729 missing.append('readline') 812 missing.append('readline')
730 813
731 # crypt module. 814 # crypt module.
732 815
733 if self.compiler.find_library_file(lib_dirs, 'crypt'): 816 if host_platform not in ['mingw', 'win32']:
734 libs = ['crypt'] 817 if self.compiler.find_library_file(lib_dirs, 'crypt'):
818 libs = ['crypt']
819 else:
820 libs = []
821 exts.append( Extension('_crypt', ['_cryptmodule.c'], libraries=libs) )
735 else: 822 else:
736 libs = [] 823 missing.append('_crypt')
737 exts.append( Extension('_crypt', ['_cryptmodule.c'], libraries=libs) )
738 824
739 # CSV files 825 # CSV files
740 exts.append( Extension('_csv', ['_csv.c']) ) 826 exts.append( Extension('_csv', ['_csv.c']) )
741 827
742 # POSIX subprocess module helper. 828 # POSIX subprocess module helper.
743 exts.append( Extension('_posixsubprocess', ['_posixsubprocess.c']) ) 829 if host_platform not in ['mingw', 'win32']:
830 exts.append( Extension('_posixsubprocess', ['_posixsubprocess.c']) )
831 else:
832 missing.append('_posixsubprocess')
744 833
745 # socket(2) 834 # socket(2)
835 if host_platform in ['mingw', 'win32']:
836 socket_libs = ['ws2_32']
837 else:
838 socket_libs = []
746 exts.append( Extension('_socket', ['socketmodule.c'], 839 exts.append( Extension('_socket', ['socketmodule.c'],
840 libraries=socket_libs,
747 depends = ['socketmodule.h']) ) 841 depends = ['socketmodule.h']) )
748 # Detect SSL support for the socket module (via _ssl) 842 # Detect SSL support for the socket module (via _ssl)
749 search_for_ssl_incs_in = [ 843 search_for_ssl_incs_in = [
750 '/usr/local/ssl/include', 844 '/usr/local/ssl/include',
751 '/usr/contrib/ssl/include/' 845 '/usr/contrib/ssl/include/'
752 ] 846 ]
753 ssl_incs = find_file('openssl/ssl.h', inc_dirs, 847 ssl_incs = find_file('openssl/ssl.h', inc_dirs,
754 search_for_ssl_incs_in 848 search_for_ssl_incs_in
755 ) 849 )
756 if ssl_incs is not None: 850 if ssl_incs is not None:
757 krb5_h = find_file('krb5.h', inc_dirs, 851 krb5_h = find_file('krb5.h', inc_dirs,
758 ['/usr/kerberos/include']) 852 ['/usr/kerberos/include'])
759 if krb5_h: 853 if krb5_h:
760 ssl_incs += krb5_h 854 ssl_incs += krb5_h
761 ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs, 855 ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
762 ['/usr/local/ssl/lib', 856 ['/usr/local/ssl/lib',
763 '/usr/contrib/ssl/lib/' 857 '/usr/contrib/ssl/lib/'
764 ] ) 858 ] )
765 859
766 if (ssl_incs is not None and 860 if (ssl_incs is not None and
767 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')
768 exts.append( Extension('_ssl', ['_ssl.c'], 865 exts.append( Extension('_ssl', ['_ssl.c'],
769 include_dirs = ssl_incs, 866 include_dirs = ssl_incs,
770 library_dirs = ssl_libs, 867 library_dirs = ssl_libs,
771 libraries = ['ssl', 'crypto'], 868 libraries = _ssl_libs,
772 depends = ['socketmodule.h']), ) 869 depends = ['socketmodule.h']), )
773 else: 870 else:
774 missing.append('_ssl') 871 missing.append('_ssl')
775 872
776 # find out which version of OpenSSL we have 873 # find out which version of OpenSSL we have
777 openssl_ver = 0 874 openssl_ver = 0
778 openssl_ver_re = re.compile( 875 openssl_ver_re = re.compile(
779 '^\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]+)' )
780 877
781 # look for the openssl version header on the compiler search path. 878 # look for the openssl version header on the compiler search path.
(...skipping 16 matching lines...) Expand all
798 #print('openssl_ver = 0x%08x' % openssl_ver) 895 #print('openssl_ver = 0x%08x' % openssl_ver)
799 min_openssl_ver = 0x00907000 896 min_openssl_ver = 0x00907000
800 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
801 have_usable_openssl = (have_any_openssl and 898 have_usable_openssl = (have_any_openssl and
802 openssl_ver >= min_openssl_ver) 899 openssl_ver >= min_openssl_ver)
803 900
804 if have_any_openssl: 901 if have_any_openssl:
805 if have_usable_openssl: 902 if have_usable_openssl:
806 # The _hashlib module wraps optimized implementations 903 # The _hashlib module wraps optimized implementations
807 # of hash functions from the OpenSSL library. 904 # of hash functions from the OpenSSL library.
905 # NOTE: _hashlib require only OpenSSL crypto library !
808 exts.append( Extension('_hashlib', ['_hashopenssl.c'], 906 exts.append( Extension('_hashlib', ['_hashopenssl.c'],
809 depends = ['hashlib.h'], 907 depends = ['hashlib.h'],
810 include_dirs = ssl_incs, 908 include_dirs = ssl_incs,
811 library_dirs = ssl_libs, 909 library_dirs = ssl_libs,
812 libraries = ['ssl', 'crypto']) ) 910 libraries = ['crypto']) )
813 else: 911 else:
814 print("warning: openssl 0x%08x is too old for _hashlib" % 912 print("warning: openssl 0x%08x is too old for _hashlib" %
815 openssl_ver) 913 openssl_ver)
816 missing.append('_hashlib') 914 missing.append('_hashlib')
915 # NOTE: MSVC build alwais include _md5 and _sha modules
916 # as build-in modules
817 917
818 # We always compile these even when OpenSSL is available (issue #14693). 918 # We always compile these even when OpenSSL is available (issue #14693).
819 # It's harmless and the object code is tiny (40-50 KB per module, 919 # It's harmless and the object code is tiny (40-50 KB per module,
820 # only loaded when actually used). 920 # only loaded when actually used).
821 exts.append( Extension('_sha256', ['sha256module.c'], 921 exts.append( Extension('_sha256', ['sha256module.c'],
822 depends=['hashlib.h']) ) 922 depends=['hashlib.h']) )
823 exts.append( Extension('_sha512', ['sha512module.c'], 923 exts.append( Extension('_sha512', ['sha512module.c'],
824 depends=['hashlib.h']) ) 924 depends=['hashlib.h']) )
825 exts.append( Extension('_md5', ['md5module.c'], 925 exts.append( Extension('_md5', ['md5module.c'],
826 depends=['hashlib.h']) ) 926 depends=['hashlib.h']) )
(...skipping 11 matching lines...) Expand all
838 # http://www.oracle.com/database/berkeley-db/db/index.html 938 # http://www.oracle.com/database/berkeley-db/db/index.html
839 # 939 #
840 # This requires the Sleepycat^WOracle DB code. The supported versions 940 # This requires the Sleepycat^WOracle DB code. The supported versions
841 # are set below. Visit the URL above to download 941 # are set below. Visit the URL above to download
842 # a release. Most open source OSes come with one or more 942 # a release. Most open source OSes come with one or more
843 # versions of BerkeleyDB already installed. 943 # versions of BerkeleyDB already installed.
844 944
845 max_db_ver = (5, 3) 945 max_db_ver = (5, 3)
846 min_db_ver = (3, 3) 946 min_db_ver = (3, 3)
847 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']) )
848 972
849 def allow_db_ver(db_ver): 973 def allow_db_ver(db_ver):
850 """Returns a boolean if the given BerkeleyDB version is acceptable. 974 """Returns a boolean if the given BerkeleyDB version is acceptable.
851 975
852 Args: 976 Args:
853 db_ver: A tuple of the version to verify. 977 db_ver: A tuple of the version to verify.
854 """ 978 """
855 if not (min_db_ver <= db_ver <= max_db_ver): 979 if not (min_db_ver <= db_ver <= max_db_ver):
856 return False 980 return False
857 return True 981 return True
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 '_sqlite/connection.c', 1221 '_sqlite/connection.c',
1098 '_sqlite/cursor.c', 1222 '_sqlite/cursor.c',
1099 '_sqlite/microprotocols.c', 1223 '_sqlite/microprotocols.c',
1100 '_sqlite/module.c', 1224 '_sqlite/module.c',
1101 '_sqlite/prepare_protocol.c', 1225 '_sqlite/prepare_protocol.c',
1102 '_sqlite/row.c', 1226 '_sqlite/row.c',
1103 '_sqlite/statement.c', 1227 '_sqlite/statement.c',
1104 '_sqlite/util.c', ] 1228 '_sqlite/util.c', ]
1105 1229
1106 sqlite_defines = [] 1230 sqlite_defines = []
1231 #NOTE: don't add mingw here
1107 if host_platform != "win32": 1232 if host_platform != "win32":
1108 sqlite_defines.append(('MODULE_NAME', '"sqlite3"')) 1233 sqlite_defines.append(('MODULE_NAME', '"sqlite3"'))
1109 else: 1234 else:
1110 sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"')) 1235 sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"'))
1111 1236
1112 # Enable support for loadable extensions in the sqlite3 module 1237 # Enable support for loadable extensions in the sqlite3 module
1113 # if --enable-loadable-sqlite-extensions configure option is used. 1238 # if --enable-loadable-sqlite-extensions configure option is used.
1114 if '--enable-loadable-sqlite-extensions' not in sysconfig.get_config _var("CONFIG_ARGS"): 1239 if '--enable-loadable-sqlite-extensions' not in sysconfig.get_config _var("CONFIG_ARGS"):
1115 sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1")) 1240 sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))
1116 1241
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 ('DB_DBM_HSEARCH', None), 1335 ('DB_DBM_HSEARCH', None),
1211 ], 1336 ],
1212 libraries=dblibs) 1337 libraries=dblibs)
1213 break 1338 break
1214 if dbmext is not None: 1339 if dbmext is not None:
1215 exts.append(dbmext) 1340 exts.append(dbmext)
1216 else: 1341 else:
1217 missing.append('_dbm') 1342 missing.append('_dbm')
1218 1343
1219 # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm: 1344 # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm:
1220 if ('gdbm' in dbm_order and 1345 if (host_platform not in ['mingw', 'win32'] and
1346 'gdbm' in dbm_order and
1221 self.compiler.find_library_file(lib_dirs, 'gdbm')): 1347 self.compiler.find_library_file(lib_dirs, 'gdbm')):
1222 exts.append( Extension('_gdbm', ['_gdbmmodule.c'], 1348 exts.append( Extension('_gdbm', ['_gdbmmodule.c'],
1223 libraries = ['gdbm'] ) ) 1349 libraries = ['gdbm'] ) )
1224 else: 1350 else:
1225 missing.append('_gdbm') 1351 missing.append('_gdbm')
1226 1352
1227 # Unix-only modules 1353 # Unix-only modules
1228 if host_platform != 'win32': 1354 if host_platform not in ['mingw', 'win32']:
1229 # Steen Lumholt's termios module 1355 # Steen Lumholt's termios module
1230 exts.append( Extension('termios', ['termios.c']) ) 1356 exts.append( Extension('termios', ['termios.c']) )
1231 # Jeremy Hylton's rlimit interface 1357 # Jeremy Hylton's rlimit interface
1232 exts.append( Extension('resource', ['resource.c']) ) 1358 exts.append( Extension('resource', ['resource.c']) )
1233 1359
1234 # Sun yellow pages. Some systems have the functions in libc. 1360 # Sun yellow pages. Some systems have the functions in libc.
1235 if (host_platform not in ['cygwin', 'qnx6'] and 1361 if (host_platform not in ['cygwin', 'qnx6'] and
1236 find_file('rpcsvc/yp_prot.h', inc_dirs, []) is not None): 1362 find_file('rpcsvc/yp_prot.h', inc_dirs, []) is not None):
1237 if (self.compiler.find_library_file(lib_dirs, 'nsl')): 1363 if (self.compiler.find_library_file(lib_dirs, 'nsl')):
1238 libs = ['nsl'] 1364 libs = ['nsl']
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 exts.append(Extension('_codecs_%s' % loc, 1558 exts.append(Extension('_codecs_%s' % loc,
1433 ['cjkcodecs/_codecs_%s.c' % loc])) 1559 ['cjkcodecs/_codecs_%s.c' % loc]))
1434 1560
1435 # Stefan Krah's _decimal module 1561 # Stefan Krah's _decimal module
1436 exts.append(self._decimal_ext()) 1562 exts.append(self._decimal_ext())
1437 1563
1438 # Thomas Heller's _ctypes module 1564 # Thomas Heller's _ctypes module
1439 self.detect_ctypes(inc_dirs, lib_dirs) 1565 self.detect_ctypes(inc_dirs, lib_dirs)
1440 1566
1441 # Richard Oudkerk's multiprocessing module 1567 # Richard Oudkerk's multiprocessing module
1442 if host_platform == 'win32': # Windows 1568 if host_platform in ['mingw', 'win32']:
1443 macros = dict() 1569 macros = dict()
1444 libraries = ['ws2_32'] 1570 libraries = ['ws2_32']
1445 1571
1446 elif host_platform == 'darwin': # Mac OSX 1572 elif host_platform == 'darwin': # Mac OSX
1447 macros = dict() 1573 macros = dict()
1448 libraries = [] 1574 libraries = []
1449 1575
1450 elif host_platform == 'cygwin': # Cygwin 1576 elif host_platform == 'cygwin': # Cygwin
1451 macros = dict() 1577 macros = dict()
1452 libraries = [] 1578 libraries = []
1453 1579
1454 elif host_platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', ' freebsd8'): 1580 elif host_platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', ' freebsd8'):
1455 # FreeBSD's P1003.1b semaphore support is very experimental 1581 # FreeBSD's P1003.1b semaphore support is very experimental
1456 # and has many known problems. (as of June 2008) 1582 # and has many known problems. (as of June 2008)
1457 macros = dict() 1583 macros = dict()
1458 libraries = [] 1584 libraries = []
1459 1585
1460 elif host_platform.startswith('openbsd'): 1586 elif host_platform.startswith('openbsd'):
1461 macros = dict() 1587 macros = dict()
1462 libraries = [] 1588 libraries = []
1463 1589
1464 elif host_platform.startswith('netbsd'): 1590 elif host_platform.startswith('netbsd'):
1465 macros = dict() 1591 macros = dict()
1466 libraries = [] 1592 libraries = []
1467 1593
1468 else: # Linux and other unices 1594 else: # Linux and other unices
1469 macros = dict() 1595 macros = dict()
1470 libraries = ['rt'] 1596 # NOTE: line below is never used before to add MINGW platform
1597 #libraries = ['rt']
1598 libraries = []
1471 1599
1472 if host_platform == 'win32': 1600 if host_platform in ['mingw', 'win32']:
1473 multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c', 1601 multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c',
1474 '_multiprocessing/semaphore.c', 1602 '_multiprocessing/semaphore.c',
1475 ] 1603 ]
1476 1604
1477 else: 1605 else:
1478 multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c', 1606 multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c',
1479 ] 1607 ]
1480 if (sysconfig.get_config_var('HAVE_SEM_OPEN') and not 1608 if (sysconfig.get_config_var('HAVE_SEM_OPEN') and not
1481 sysconfig.get_config_var('POSIX_SEMAPHORES_NOT_ENABLED')): 1609 sysconfig.get_config_var('POSIX_SEMAPHORES_NOT_ENABLED')):
1482 multiprocessing_srcs.append('_multiprocessing/semaphore.c') 1610 multiprocessing_srcs.append('_multiprocessing/semaphore.c')
1483 1611
1484 if sysconfig.get_config_var('WITH_THREAD'): 1612 if sysconfig.get_config_var('WITH_THREAD'):
1613 #FIXME: why above set libraries aren't used ?
1485 exts.append ( Extension('_multiprocessing', multiprocessing_srcs, 1614 exts.append ( Extension('_multiprocessing', multiprocessing_srcs,
1615 libraries=libraries,
1486 define_macros=list(macros.items()), 1616 define_macros=list(macros.items()),
1487 include_dirs=["Modules/_multiprocessing"])) 1617 include_dirs=["Modules/_multiprocessing"]))
1488 else: 1618 else:
1489 missing.append('_multiprocessing') 1619 missing.append('_multiprocessing')
1490 # End multiprocessing 1620 # End multiprocessing
1491 1621
1492 # Platform-specific libraries 1622 # Platform-specific libraries
1493 if host_platform.startswith(('linux', 'freebsd', 'gnukfreebsd')): 1623 if host_platform.startswith(('linux', 'freebsd', 'gnukfreebsd')):
1494 exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) ) 1624 exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) )
1495 else: 1625 else:
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 1788
1659 include_dirs = [] ; libs = [] ; defs = [] ; added_lib_dirs = [] 1789 include_dirs = [] ; libs = [] ; defs = [] ; added_lib_dirs = []
1660 for dir in tcl_includes + tk_includes: 1790 for dir in tcl_includes + tk_includes:
1661 if dir not in include_dirs: 1791 if dir not in include_dirs:
1662 include_dirs.append(dir) 1792 include_dirs.append(dir)
1663 1793
1664 # Check for various platform-specific directories 1794 # Check for various platform-specific directories
1665 if host_platform == 'sunos5': 1795 if host_platform == 'sunos5':
1666 include_dirs.append('/usr/openwin/include') 1796 include_dirs.append('/usr/openwin/include')
1667 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
1668 elif os.path.exists('/usr/X11R6/include'): 1801 elif os.path.exists('/usr/X11R6/include'):
1669 include_dirs.append('/usr/X11R6/include') 1802 include_dirs.append('/usr/X11R6/include')
1670 added_lib_dirs.append('/usr/X11R6/lib64') 1803 added_lib_dirs.append('/usr/X11R6/lib64')
1671 added_lib_dirs.append('/usr/X11R6/lib') 1804 added_lib_dirs.append('/usr/X11R6/lib')
1672 elif os.path.exists('/usr/X11R5/include'): 1805 elif os.path.exists('/usr/X11R5/include'):
1673 include_dirs.append('/usr/X11R5/include') 1806 include_dirs.append('/usr/X11R5/include')
1674 added_lib_dirs.append('/usr/X11R5/lib') 1807 added_lib_dirs.append('/usr/X11R5/lib')
1675 else: 1808 else:
1676 # Assume default location for X11 1809 # Assume default location for X11
1677 include_dirs.append('/usr/X11/include') 1810 include_dirs.append('/usr/X11/include')
1678 added_lib_dirs.append('/usr/X11/lib') 1811 added_lib_dirs.append('/usr/X11/lib')
1679 1812
1680 # If Cygwin, then verify that X is installed before proceeding 1813 # If Cygwin, then verify that X is installed before proceeding
1681 if host_platform == 'cygwin': 1814 if host_platform == 'cygwin':
1815 include_dirs.append('/usr/include')
1682 x11_inc = find_file('X11/Xlib.h', [], include_dirs) 1816 x11_inc = find_file('X11/Xlib.h', [], include_dirs)
1683 if x11_inc is None: 1817 if x11_inc is None:
1684 return 1818 return
1685 1819
1686 # Check for BLT extension 1820 # Check for BLT extension
1687 if self.compiler.find_library_file(lib_dirs + added_lib_dirs, 1821 if self.compiler.find_library_file(lib_dirs + added_lib_dirs,
1688 'BLT8.0'): 1822 'BLT8.0'):
1689 defs.append( ('WITH_BLT', 1) ) 1823 defs.append( ('WITH_BLT', 1) )
1690 libs.append('BLT8.0') 1824 libs.append('BLT8.0')
1691 elif self.compiler.find_library_file(lib_dirs + added_lib_dirs, 1825 elif self.compiler.find_library_file(lib_dirs + added_lib_dirs,
1692 'BLT'): 1826 'BLT'):
1693 defs.append( ('WITH_BLT', 1) ) 1827 defs.append( ('WITH_BLT', 1) )
1694 libs.append('BLT') 1828 libs.append('BLT')
1695 1829
1696 # Add the Tcl/Tk libraries 1830 # Add the Tcl/Tk libraries
1697 libs.append('tk'+ version) 1831 libs.append('tk'+ version)
1698 libs.append('tcl'+ version) 1832 libs.append('tcl'+ version)
1699 1833
1700 if host_platform in ['aix3', 'aix4']: 1834 if host_platform in ['aix3', 'aix4']:
1701 libs.append('ld') 1835 libs.append('ld')
1702 1836
1703 # Finally, link with the X11 libraries (not appropriate on cygwin) 1837 # Finally, link with the X11 libraries (not appropriate on cygwin, mingw )
1704 if host_platform != "cygwin": 1838 if not host_platform in ['cygwin', 'mingw', 'win32']:
1705 libs.append('X11') 1839 libs.append('X11')
1706 1840
1707 ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], 1841 ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
1708 define_macros=[('WITH_APPINIT', 1)] + defs, 1842 define_macros=[('WITH_APPINIT', 1)] + defs,
1709 include_dirs = include_dirs, 1843 include_dirs = include_dirs,
1710 libraries = libs, 1844 libraries = libs,
1711 library_dirs = added_lib_dirs, 1845 library_dirs = added_lib_dirs,
1712 ) 1846 )
1713 self.extensions.append(ext) 1847 self.extensions.append(ext)
1714 1848
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 # Add .S (preprocessed assembly) to C compiler source extensions. 1883 # Add .S (preprocessed assembly) to C compiler source extensions.
1750 self.compiler.src_extensions.append('.S') 1884 self.compiler.src_extensions.append('.S')
1751 1885
1752 include_dirs = [os.path.join(ffi_srcdir, 'include'), 1886 include_dirs = [os.path.join(ffi_srcdir, 'include'),
1753 os.path.join(ffi_srcdir, 'powerpc')] 1887 os.path.join(ffi_srcdir, 'powerpc')]
1754 ext.include_dirs.extend(include_dirs) 1888 ext.include_dirs.extend(include_dirs)
1755 ext.sources.extend(sources) 1889 ext.sources.extend(sources)
1756 return True 1890 return True
1757 1891
1758 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
1759 if not self.use_system_libffi: 1925 if not self.use_system_libffi:
1760 if host_platform == 'darwin': 1926 if host_platform == 'darwin':
1761 return self.configure_ctypes_darwin(ext) 1927 return self.configure_ctypes_darwin(ext)
1762 1928
1763 srcdir = sysconfig.get_config_var('srcdir') 1929 srcdir = sysconfig.get_config_var('srcdir')
1764 ffi_builddir = os.path.join(self.build_temp, 'libffi') 1930 ffi_builddir = os.path.join(self.build_temp, 'libffi')
1765 ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules', 1931 ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules',
1766 '_ctypes', 'libffi')) 1932 '_ctypes', 'libffi'))
1767 ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.py') 1933 ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.py')
1768 1934
(...skipping 30 matching lines...) Expand all
1799 1965
1800 include_dirs = [os.path.join(ffi_builddir, 'include'), 1966 include_dirs = [os.path.join(ffi_builddir, 'include'),
1801 ffi_builddir, 1967 ffi_builddir,
1802 os.path.join(ffi_srcdir, 'src')] 1968 os.path.join(ffi_srcdir, 'src')]
1803 extra_compile_args = fficonfig['ffi_cflags'].split() 1969 extra_compile_args = fficonfig['ffi_cflags'].split()
1804 1970
1805 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
1806 fficonfig['ffi_sources']) 1972 fficonfig['ffi_sources'])
1807 ext.include_dirs.extend(include_dirs) 1973 ext.include_dirs.extend(include_dirs)
1808 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'])
1809 return True 1980 return True
1810 1981
1811 def detect_ctypes(self, inc_dirs, lib_dirs): 1982 def detect_ctypes(self, inc_dirs, lib_dirs):
1812 self.use_system_libffi = False 1983 self.use_system_libffi = False
1813 include_dirs = [] 1984 include_dirs = []
1814 extra_compile_args = [] 1985 extra_compile_args = []
1815 extra_link_args = [] 1986 extra_link_args = []
1816 sources = ['_ctypes/_ctypes.c', 1987 sources = ['_ctypes/_ctypes.c',
1817 '_ctypes/callbacks.c', 1988 '_ctypes/callbacks.c',
1818 '_ctypes/callproc.c', 1989 '_ctypes/callproc.c',
(...skipping 23 matching lines...) Expand all
1842 elif host_platform.startswith('hp-ux'): 2013 elif host_platform.startswith('hp-ux'):
1843 extra_link_args.append('-fPIC') 2014 extra_link_args.append('-fPIC')
1844 2015
1845 ext = Extension('_ctypes', 2016 ext = Extension('_ctypes',
1846 include_dirs=include_dirs, 2017 include_dirs=include_dirs,
1847 extra_compile_args=extra_compile_args, 2018 extra_compile_args=extra_compile_args,
1848 extra_link_args=extra_link_args, 2019 extra_link_args=extra_link_args,
1849 libraries=[], 2020 libraries=[],
1850 sources=sources, 2021 sources=sources,
1851 depends=depends) 2022 depends=depends)
2023 if host_platform in ['mingw', 'win32']:
2024 ctypes_test_libs = ['oleaut32']
2025 else:
2026 ctypes_test_libs = []
1852 ext_test = Extension('_ctypes_test', 2027 ext_test = Extension('_ctypes_test',
2028 libraries=ctypes_test_libs,
1853 sources=['_ctypes/_ctypes_test.c']) 2029 sources=['_ctypes/_ctypes_test.c'])
1854 self.extensions.extend([ext, ext_test]) 2030 self.extensions.extend([ext, ext_test])
1855 2031
1856 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"):
1857 return 2033 return
1858 2034
1859 if host_platform == 'darwin': 2035 if host_platform == 'darwin':
1860 # 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
1861 # in /usr/include/ffi 2037 # in /usr/include/ffi
1862 inc_dirs.append('/usr/include/ffi') 2038 inc_dirs.append('/usr/include/ffi')
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 continue 2232 continue
2057 log.info("changing mode of %s to %o", dirpath, mode) 2233 log.info("changing mode of %s to %o", dirpath, mode)
2058 if not self.dry_run: os.chmod(dirpath, mode) 2234 if not self.dry_run: os.chmod(dirpath, mode)
2059 2235
2060 def is_chmod_supported(self): 2236 def is_chmod_supported(self):
2061 return hasattr(os, 'chmod') 2237 return hasattr(os, 'chmod')
2062 2238
2063 class PyBuildScripts(build_scripts): 2239 class PyBuildScripts(build_scripts):
2064 def copy_scripts(self): 2240 def copy_scripts(self):
2065 outfiles, updated_files = build_scripts.copy_scripts(self) 2241 outfiles, updated_files = build_scripts.copy_scripts(self)
2066 fullversion = '-{0[0]}.{0[1]}'.format(sys.version_info) 2242 print('sys.version_info=%s' % str(sys.version_info))
2067 minoronly = '.{0[1]}'.format(sys.version_info) 2243 fullversion = '-{0[0]}{0[1]}'.format(sys.version_info)
2244 minoronly = '{0[1]}'.format(sys.version_info)
2068 newoutfiles = [] 2245 newoutfiles = []
2069 newupdated_files = [] 2246 newupdated_files = []
2070 for filename in outfiles: 2247 for filename in outfiles:
2071 if filename.endswith(('2to3', 'pyvenv')): 2248 if filename.endswith(('2to3', 'pyvenv')):
2072 newfilename = filename + fullversion 2249 newfilename = filename + fullversion
2073 else: 2250 else:
2074 newfilename = filename + minoronly 2251 newfilename = filename + minoronly
2075 log.info('renaming {} to {}'.format(filename, newfilename)) 2252 log.info('renaming {} to {}'.format(filename, newfilename))
2253 if os.path.isfile(newfilename):
2254 os.remove(newfilename)
2076 os.rename(filename, newfilename) 2255 os.rename(filename, newfilename)
2077 newoutfiles.append(newfilename) 2256 newoutfiles.append(newfilename)
2078 if filename in updated_files: 2257 if filename in updated_files:
2079 newupdated_files.append(newfilename) 2258 newupdated_files.append(newfilename)
2080 return newoutfiles, newupdated_files 2259 return newoutfiles, newupdated_files
2081 2260
2082 SUMMARY = """ 2261 SUMMARY = """
2083 Python is an interpreted, interactive, object-oriented programming 2262 Python is an interpreted, interactive, object-oriented programming
2084 language. It is often compared to Tcl, Perl, Scheme or Java. 2263 language. It is often compared to Tcl, Perl, Scheme or Java.
2085 2264
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2135 # If you change the scripts installed here, you also need to 2314 # If you change the scripts installed here, you also need to
2136 # check the PyBuildScripts command above, and change the links 2315 # check the PyBuildScripts command above, and change the links
2137 # created by the bininstall target in Makefile.pre.in 2316 # created by the bininstall target in Makefile.pre.in
2138 scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3", 2317 scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3",
2139 "Tools/scripts/2to3", "Tools/scripts/pyvenv"] 2318 "Tools/scripts/2to3", "Tools/scripts/pyvenv"]
2140 ) 2319 )
2141 2320
2142 # --install-platlib 2321 # --install-platlib
2143 if __name__ == '__main__': 2322 if __name__ == '__main__':
2144 main() 2323 main()
OLDNEW
« no previous file with comments | « setup_info.in ('k') | no next file » | no next file with comments »

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