annotate Lib/distutils/command/build_ext.py @ 65035:87f4b32905df 2.7

Cosmetic fix to use print function.
author Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
date Fri, 01 Oct 2010 10:48:47 +0000
parents e27030e0cced
children 3b5cc6638f3d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
1 """distutils.command.build_ext
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
2
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
3 Implements the Distutils 'build_ext' command, for building extension
13050
a195962e389c typos fixed by Rob Hooft
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 13046
diff changeset
4 modules (currently limited to C extensions, should accommodate C++
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
5 extensions ASAP)."""
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
6
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
7 # This module should be kept compatible with Python 2.1.
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
8
11897
017e592c0fd2 Changed '__rcsid__' to '__revision__'.
Greg Ward <gward@python.net>
parents: 11896
diff changeset
9 __revision__ = "$Id$"
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
10
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
11 import sys, os, string, re
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
12 from types import *
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
13 from site import USER_BASE, USER_SITE
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
14 from distutils.core import Command
58450
fa69e891edf4 taking sysconfig out of distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 57847
diff changeset
15 from distutils.errors import *
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
16 from distutils.sysconfig import customize_compiler, get_python_version
12764
c8a9d1766465 Rene Liebscher: check if the extension file (.so or .pyd) is
Greg Ward <gward@python.net>
parents: 12743
diff changeset
17 from distutils.dep_util import newer_group
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
18 from distutils.extension import Extension
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
19 from distutils.util import get_platform
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 23273
diff changeset
20 from distutils import log
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
21
44117
ead0d47b012b Applied my patch #1455 with some extra fixes for VS 2005
Christian Heimes <christian@cheimes.de>
parents: 41521
diff changeset
22 if os.name == 'nt':
ead0d47b012b Applied my patch #1455 with some extra fixes for VS 2005
Christian Heimes <christian@cheimes.de>
parents: 41521
diff changeset
23 from distutils.msvccompiler import get_build_version
ead0d47b012b Applied my patch #1455 with some extra fixes for VS 2005
Christian Heimes <christian@cheimes.de>
parents: 41521
diff changeset
24 MSVC_VERSION = int(get_build_version())
ead0d47b012b Applied my patch #1455 with some extra fixes for VS 2005
Christian Heimes <christian@cheimes.de>
parents: 41521
diff changeset
25
11300
8ec6d2c6c598 Some option changes:
Greg Ward <gward@python.net>
parents: 11281
diff changeset
26 # An extension name is just a dot-separated list of Python NAMEs (ie.
8ec6d2c6c598 Some option changes:
Greg Ward <gward@python.net>
parents: 11281
diff changeset
27 # the same as a fully-qualified module name).
8ec6d2c6c598 Some option changes:
Greg Ward <gward@python.net>
parents: 11281
diff changeset
28 extension_name_re = re.compile \
8ec6d2c6c598 Some option changes:
Greg Ward <gward@python.net>
parents: 11281
diff changeset
29 (r'^[a-zA-Z_][a-zA-Z_0-9]*(\.[a-zA-Z_][a-zA-Z_0-9]*)*$')
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
30
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
31
12999
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12996
diff changeset
32 def show_compilers ():
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12996
diff changeset
33 from distutils.ccompiler import show_compilers
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12996
diff changeset
34 show_compilers()
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12996
diff changeset
35
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12996
diff changeset
36
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
37 class build_ext (Command):
21268
d296e6bb17e5 Whitespace normalization.
Fred Drake <fdrake@acm.org>
parents: 18835
diff changeset
38
11683
47f75a17b103 Added 'description' class attribute to every command class (to help the
Greg Ward <gward@python.net>
parents: 11544
diff changeset
39 description = "build C/C++ extensions (compile/link to build directory)"
47f75a17b103 Added 'description' class attribute to every command class (to help the
Greg Ward <gward@python.net>
parents: 11544
diff changeset
40
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
41 # XXX thoughts on how to deal with complex command-line options like
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
42 # these, i.e. how to make it so fancy_getopt can suck them off the
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
43 # command line and make it look like setup.py defined the appropriate
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
44 # lists of tuples of what-have-you.
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
45 # - each command needs a callback to process its command-line options
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
46 # - Command.__init__() needs access to its share of the whole
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
47 # command line (must ultimately come from
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
48 # Distribution.parse_command_line())
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
49 # - it then calls the current command class' option-parsing
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
50 # callback to deal with weird options like -D, which have to
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
51 # parse the option text and churn out some custom data
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
52 # structure
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
53 # - that data structure (in this case, a list of 2-tuples)
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
54 # will then be present in the command object by the time
11817
476eaa38e2d6 Renamed 'set_default_options()' to 'initialize_options()', and
Greg Ward <gward@python.net>
parents: 11815
diff changeset
55 # we get to finalize_options() (i.e. the constructor
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
56 # takes care of both command-line and client options
11817
476eaa38e2d6 Renamed 'set_default_options()' to 'initialize_options()', and
Greg Ward <gward@python.net>
parents: 11815
diff changeset
57 # in between initialize_options() and finalize_options())
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
58
14612
1e6c044d8e59 Document the directory separatory for include dir and library dir lists.
Greg Ward <gward@python.net>
parents: 14574
diff changeset
59 sep_by = " (separated by '%s')" % os.pathsep
11815
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
60 user_options = [
11886
270a11488c6c Build reorg:
Greg Ward <gward@python.net>
parents: 11817
diff changeset
61 ('build-lib=', 'b',
11815
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
62 "directory for compiled extension modules"),
11886
270a11488c6c Build reorg:
Greg Ward <gward@python.net>
parents: 11817
diff changeset
63 ('build-temp=', 't',
270a11488c6c Build reorg:
Greg Ward <gward@python.net>
parents: 11817
diff changeset
64 "directory for temporary files (build by-products)"),
46331
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
65 ('plat-name=', 'p',
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
66 "platform name to cross-compile for, if supported "
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
67 "(default: %s)" % get_platform()),
11886
270a11488c6c Build reorg:
Greg Ward <gward@python.net>
parents: 11817
diff changeset
68 ('inplace', 'i',
14434
34379127ee3b Typo fix.
Greg Ward <gward@python.net>
parents: 14216
diff changeset
69 "ignore build-lib and put compiled extensions into the source " +
11886
270a11488c6c Build reorg:
Greg Ward <gward@python.net>
parents: 11817
diff changeset
70 "directory alongside your pure Python modules"),
11815
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
71 ('include-dirs=', 'I',
14612
1e6c044d8e59 Document the directory separatory for include dir and library dir lists.
Greg Ward <gward@python.net>
parents: 14574
diff changeset
72 "list of directories to search for header files" + sep_by),
11815
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
73 ('define=', 'D',
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
74 "C preprocessor macros to define"),
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
75 ('undef=', 'U',
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
76 "C preprocessor macros to undefine"),
12057
42d8d76dae6d Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents: 12029
diff changeset
77 ('libraries=', 'l',
11815
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
78 "external C libraries to link with"),
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
79 ('library-dirs=', 'L',
14612
1e6c044d8e59 Document the directory separatory for include dir and library dir lists.
Greg Ward <gward@python.net>
parents: 14574
diff changeset
80 "directories to search for external C libraries" + sep_by),
11815
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
81 ('rpath=', 'R',
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
82 "directories to search for shared C libraries at runtime"),
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
83 ('link-objects=', 'O',
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
84 "extra explicit link objects to include in the link"),
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
85 ('debug', 'g',
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
86 "compile/link with debugging information"),
12314
20a5cbf9fcc0 Added '--force' option -- very clear what it means for building (ignore
Greg Ward <gward@python.net>
parents: 12164
diff changeset
87 ('force', 'f',
12671
a02e6a43ca15 Fix from Lyle Johnson: add the '--compiler' option.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12624
diff changeset
88 "forcibly build everything (ignore file timestamps)"),
a02e6a43ca15 Fix from Lyle Johnson: add the '--compiler' option.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12624
diff changeset
89 ('compiler=', 'c',
a02e6a43ca15 Fix from Lyle Johnson: add the '--compiler' option.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12624
diff changeset
90 "specify the compiler type"),
13032
1240bc997c8f Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support.
Greg Ward <gward@python.net>
parents: 13014
diff changeset
91 ('swig-cpp', None,
1240bc997c8f Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support.
Greg Ward <gward@python.net>
parents: 13014
diff changeset
92 "make SWIG create C++ files (default is C)"),
33759
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
93 ('swig-opts=', None,
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
94 "list of SWIG command line options"),
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
95 ('swig=', None,
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
96 "path to the SWIG executable"),
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
97 ('user', None,
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
98 "add user include, library and rpath"),
11815
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
99 ]
12999
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12996
diff changeset
100
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
101 boolean_options = ['inplace', 'debug', 'force', 'swig-cpp', 'user']
14829
b1f220f636ed Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents: 14652
diff changeset
102
12869
88872791998a Patch from Rene Liebscher: this adds "--help-foo" options to list the
Greg Ward <gward@python.net>
parents: 12800
diff changeset
103 help_options = [
88872791998a Patch from Rene Liebscher: this adds "--help-foo" options to list the
Greg Ward <gward@python.net>
parents: 12800
diff changeset
104 ('help-compiler', None,
12999
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12996
diff changeset
105 "list available compilers", show_compilers),
13797
e00d3ce71f89 Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents: 13725
diff changeset
106 ]
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
107
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
108 def initialize_options (self):
11262
810c25d5041c Changed to reflect the new "command options" regime -- in particular,
Greg Ward <gward@python.net>
parents: 11246
diff changeset
109 self.extensions = None
11886
270a11488c6c Build reorg:
Greg Ward <gward@python.net>
parents: 11817
diff changeset
110 self.build_lib = None
46331
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
111 self.plat_name = None
11886
270a11488c6c Build reorg:
Greg Ward <gward@python.net>
parents: 11817
diff changeset
112 self.build_temp = None
270a11488c6c Build reorg:
Greg Ward <gward@python.net>
parents: 11817
diff changeset
113 self.inplace = 0
11281
cae4b09273b3 Added support for 'package' option, including where to link the
Greg Ward <gward@python.net>
parents: 11262
diff changeset
114 self.package = None
cae4b09273b3 Added support for 'package' option, including where to link the
Greg Ward <gward@python.net>
parents: 11262
diff changeset
115
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
116 self.include_dirs = None
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
117 self.define = None
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
118 self.undef = None
12057
42d8d76dae6d Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents: 12029
diff changeset
119 self.libraries = None
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
120 self.library_dirs = None
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
121 self.rpath = None
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
122 self.link_objects = None
11732
c976d693ddeb Added 'debug' option, and changed compile/link calls to use it.
Greg Ward <gward@python.net>
parents: 11719
diff changeset
123 self.debug = None
12314
20a5cbf9fcc0 Added '--force' option -- very clear what it means for building (ignore
Greg Ward <gward@python.net>
parents: 12164
diff changeset
124 self.force = None
12671
a02e6a43ca15 Fix from Lyle Johnson: add the '--compiler' option.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12624
diff changeset
125 self.compiler = None
33759
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
126 self.swig = None
13032
1240bc997c8f Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support.
Greg Ward <gward@python.net>
parents: 13014
diff changeset
127 self.swig_cpp = None
33759
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
128 self.swig_opts = None
46788
f3f6a895a555 Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents: 46331
diff changeset
129 self.user = None
11340
7ae5c4051041 Added 'package' option.
Greg Ward <gward@python.net>
parents: 11300
diff changeset
130
53968
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
131 def finalize_options(self):
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
132 from distutils import sysconfig
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
133
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14914
diff changeset
134 self.set_undefined_options('build',
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14914
diff changeset
135 ('build_lib', 'build_lib'),
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14914
diff changeset
136 ('build_temp', 'build_temp'),
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14914
diff changeset
137 ('compiler', 'compiler'),
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14914
diff changeset
138 ('debug', 'debug'),
46331
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
139 ('force', 'force'),
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
140 ('plat_name', 'plat_name'),
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
141 )
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
142
11281
cae4b09273b3 Added support for 'package' option, including where to link the
Greg Ward <gward@python.net>
parents: 11262
diff changeset
143 if self.package is None:
11300
8ec6d2c6c598 Some option changes:
Greg Ward <gward@python.net>
parents: 11281
diff changeset
144 self.package = self.distribution.ext_package
8ec6d2c6c598 Some option changes:
Greg Ward <gward@python.net>
parents: 11281
diff changeset
145
8ec6d2c6c598 Some option changes:
Greg Ward <gward@python.net>
parents: 11281
diff changeset
146 self.extensions = self.distribution.ext_modules
21268
d296e6bb17e5 Whitespace normalization.
Fred Drake <fdrake@acm.org>
parents: 18835
diff changeset
147
18835
2dea40e40d9d Patch #411138: Rename config.h to pyconfig.h. Closes bug #231774.
Martin v. Löwis <martin@v.loewis.de>
parents: 17065
diff changeset
148 # Make sure Python's include directories (for Python.h, pyconfig.h,
12402
4c51a966d2a3 Use 'get_python_inc()' to figure out the Python include directories
Greg Ward <gward@python.net>
parents: 12314
diff changeset
149 # etc.) are in the include search path.
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
150 py_include = sysconfig.get_python_inc()
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
151 plat_py_include = sysconfig.get_python_inc(plat_specific=1)
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
152 if self.include_dirs is None:
11300
8ec6d2c6c598 Some option changes:
Greg Ward <gward@python.net>
parents: 11281
diff changeset
153 self.include_dirs = self.distribution.include_dirs or []
53968
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
154 if isinstance(self.include_dirs, str):
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
155 self.include_dirs = self.include_dirs.split(os.pathsep)
11340
7ae5c4051041 Added 'package' option.
Greg Ward <gward@python.net>
parents: 11300
diff changeset
156
12108
6fd43867aa4f Put the Python "system" include dir last, rather than first.
Greg Ward <gward@python.net>
parents: 12095
diff changeset
157 # Put the Python "system" include dir at the end, so that
6fd43867aa4f Put the Python "system" include dir last, rather than first.
Greg Ward <gward@python.net>
parents: 12095
diff changeset
158 # any local include dirs take precedence.
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14914
diff changeset
159 self.include_dirs.append(py_include)
12402
4c51a966d2a3 Use 'get_python_inc()' to figure out the Python include directories
Greg Ward <gward@python.net>
parents: 12314
diff changeset
160 if plat_py_include != py_include:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14914
diff changeset
161 self.include_dirs.append(plat_py_include)
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
162
53968
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
163 if isinstance(self.libraries, str):
12057
42d8d76dae6d Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents: 12029
diff changeset
164 self.libraries = [self.libraries]
12017
e7820352cb80 In 'finalize_options()': if 'self.libs' is a string, make it a singleton list.
Greg Ward <gward@python.net>
parents: 11913
diff changeset
165
12164
42387ade6afb Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents: 12117
diff changeset
166 # Life is easier if we're not forever checking for None, so
42387ade6afb Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents: 12117
diff changeset
167 # simplify these options to empty lists if unset
42387ade6afb Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents: 12117
diff changeset
168 if self.libraries is None:
42387ade6afb Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents: 12117
diff changeset
169 self.libraries = []
42387ade6afb Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents: 12117
diff changeset
170 if self.library_dirs is None:
42387ade6afb Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents: 12117
diff changeset
171 self.library_dirs = []
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
172 elif type(self.library_dirs) is StringType:
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
173 self.library_dirs = string.split(self.library_dirs, os.pathsep)
16637
59f4f6960101 Split the rpath argument into multiple paths, turning it into a list.
Andrew M. Kuchling <amk@amk.ca>
parents: 16281
diff changeset
174
12164
42387ade6afb Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents: 12117
diff changeset
175 if self.rpath is None:
42387ade6afb Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents: 12117
diff changeset
176 self.rpath = []
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
177 elif type(self.rpath) is StringType:
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
178 self.rpath = string.split(self.rpath, os.pathsep)
11712
9250e5d3aa31 Tweaked various comments, docstrings, and error messages.
Greg Ward <gward@python.net>
parents: 11702
diff changeset
179
12164
42387ade6afb Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents: 12117
diff changeset
180 # for extensions under windows use different directories
42387ade6afb Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents: 12117
diff changeset
181 # for Release and Debug builds.
42387ade6afb Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents: 12117
diff changeset
182 # also Python's library directory must be appended to library_dirs
42387ade6afb Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents: 12117
diff changeset
183 if os.name == 'nt':
46331
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
184 # the 'libs' directory is for binary installs - we assume that
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
185 # must be the *native* platform. But we don't really support
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
186 # cross-compiling via a binary install anyway, so we let it go.
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14914
diff changeset
187 self.library_dirs.append(os.path.join(sys.exec_prefix, 'libs'))
12164
42387ade6afb Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents: 12117
diff changeset
188 if self.debug:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14914
diff changeset
189 self.build_temp = os.path.join(self.build_temp, "Debug")
12164
42387ade6afb Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents: 12117
diff changeset
190 else:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14914
diff changeset
191 self.build_temp = os.path.join(self.build_temp, "Release")
16211
98b65484ade6 Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents: 15770
diff changeset
192
23273
70a089722393 Append the PC specific include 'PC' and library 'PCBuild' directories
Thomas Heller <theller@ctypes.org>
parents: 21851
diff changeset
193 # Append the source distribution include and library directories,
70a089722393 Append the PC specific include 'PC' and library 'PCBuild' directories
Thomas Heller <theller@ctypes.org>
parents: 21851
diff changeset
194 # this allows distutils on windows to work in the source tree
70a089722393 Append the PC specific include 'PC' and library 'PCBuild' directories
Thomas Heller <theller@ctypes.org>
parents: 21851
diff changeset
195 self.include_dirs.append(os.path.join(sys.exec_prefix, 'PC'))
44117
ead0d47b012b Applied my patch #1455 with some extra fixes for VS 2005
Christian Heimes <christian@cheimes.de>
parents: 41521
diff changeset
196 if MSVC_VERSION == 9:
46331
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
197 # Use the .lib files for the correct architecture
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
198 if self.plat_name == 'win32':
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
199 suffix = ''
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
200 else:
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
201 # win-amd64 or win-ia64
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
202 suffix = self.plat_name[4:]
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
203 new_lib = os.path.join(sys.exec_prefix, 'PCbuild')
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
204 if suffix:
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
205 new_lib = os.path.join(new_lib, suffix)
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
206 self.library_dirs.append(new_lib)
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
207
44117
ead0d47b012b Applied my patch #1455 with some extra fixes for VS 2005
Christian Heimes <christian@cheimes.de>
parents: 41521
diff changeset
208 elif MSVC_VERSION == 8:
ead0d47b012b Applied my patch #1455 with some extra fixes for VS 2005
Christian Heimes <christian@cheimes.de>
parents: 41521
diff changeset
209 self.library_dirs.append(os.path.join(sys.exec_prefix,
45133
4ad09565579d Fixed paths to Windows build directories in build_ext.py
Christian Heimes <christian@cheimes.de>
parents: 44117
diff changeset
210 'PC', 'VS8.0', 'win32release'))
48228
0600fce67835 Fixed test_distutils error (test_build_ext) on VC6.
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 46788
diff changeset
211 elif MSVC_VERSION == 7:
0600fce67835 Fixed test_distutils error (test_build_ext) on VC6.
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 46788
diff changeset
212 self.library_dirs.append(os.path.join(sys.exec_prefix,
0600fce67835 Fixed test_distutils error (test_build_ext) on VC6.
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 46788
diff changeset
213 'PC', 'VS7.1'))
44117
ead0d47b012b Applied my patch #1455 with some extra fixes for VS 2005
Christian Heimes <christian@cheimes.de>
parents: 41521
diff changeset
214 else:
ead0d47b012b Applied my patch #1455 with some extra fixes for VS 2005
Christian Heimes <christian@cheimes.de>
parents: 41521
diff changeset
215 self.library_dirs.append(os.path.join(sys.exec_prefix,
48228
0600fce67835 Fixed test_distutils error (test_build_ext) on VC6.
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 46788
diff changeset
216 'PC', 'VC6'))
23273
70a089722393 Append the PC specific include 'PC' and library 'PCBuild' directories
Thomas Heller <theller@ctypes.org>
parents: 21851
diff changeset
217
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 32063
diff changeset
218 # OS/2 (EMX) doesn't support Debug vs Release builds, but has the
21851
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
219 # import libraries in its "Config" subdirectory
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
220 if os.name == 'os2':
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
221 self.library_dirs.append(os.path.join(sys.exec_prefix, 'Config'))
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
222
23777
bec1b942e0bc Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents: 23668
diff changeset
223 # for extensions under Cygwin and AtheOS Python's library directory must be
16211
98b65484ade6 Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents: 15770
diff changeset
224 # appended to library_dirs
40779
4d9156464673 Bug #1600860: Search for shared python library in LIBDIR, not
Martin v. Löwis <martin@v.loewis.de>
parents: 40420
diff changeset
225 if sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos':
41149
b13e6128efa7 Patch #1569798: fix a bug in distutils when building Python from a
Georg Brandl <georg@python.org>
parents: 40779
diff changeset
226 if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")):
16211
98b65484ade6 Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents: 15770
diff changeset
227 # building third party extensions
23273
70a089722393 Append the PC specific include 'PC' and library 'PCBuild' directories
Thomas Heller <theller@ctypes.org>
parents: 21851
diff changeset
228 self.library_dirs.append(os.path.join(sys.prefix, "lib",
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
229 "python" + get_python_version(),
23273
70a089722393 Append the PC specific include 'PC' and library 'PCBuild' directories
Thomas Heller <theller@ctypes.org>
parents: 21851
diff changeset
230 "config"))
16211
98b65484ade6 Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents: 15770
diff changeset
231 else:
98b65484ade6 Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents: 15770
diff changeset
232 # building python standard extensions
98b65484ade6 Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents: 15770
diff changeset
233 self.library_dirs.append('.')
98b65484ade6 Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents: 15770
diff changeset
234
51352
466eb9784e8b Fixed #5132: enable extensions to link on Solaris
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51047
diff changeset
235 # for extensions under Linux or Solaris with a shared Python library,
40779
4d9156464673 Bug #1600860: Search for shared python library in LIBDIR, not
Martin v. Löwis <martin@v.loewis.de>
parents: 40420
diff changeset
236 # Python's library directory must be appended to library_dirs
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
237 sysconfig.get_config_var('Py_ENABLE_SHARED')
51352
466eb9784e8b Fixed #5132: enable extensions to link on Solaris
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51047
diff changeset
238 if ((sys.platform.startswith('linux') or sys.platform.startswith('gnu')
466eb9784e8b Fixed #5132: enable extensions to link on Solaris
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51047
diff changeset
239 or sys.platform.startswith('sunos'))
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
240 and sysconfig.get_config_var('Py_ENABLE_SHARED')):
41149
b13e6128efa7 Patch #1569798: fix a bug in distutils when building Python from a
Georg Brandl <georg@python.org>
parents: 40779
diff changeset
241 if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")):
40779
4d9156464673 Bug #1600860: Search for shared python library in LIBDIR, not
Martin v. Löwis <martin@v.loewis.de>
parents: 40420
diff changeset
242 # building third party extensions
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
243 self.library_dirs.append(sysconfig.get_config_var('LIBDIR'))
40779
4d9156464673 Bug #1600860: Search for shared python library in LIBDIR, not
Martin v. Löwis <martin@v.loewis.de>
parents: 40420
diff changeset
244 else:
4d9156464673 Bug #1600860: Search for shared python library in LIBDIR, not
Martin v. Löwis <martin@v.loewis.de>
parents: 40420
diff changeset
245 # building python standard extensions
4d9156464673 Bug #1600860: Search for shared python library in LIBDIR, not
Martin v. Löwis <martin@v.loewis.de>
parents: 40420
diff changeset
246 self.library_dirs.append('.')
4d9156464673 Bug #1600860: Search for shared python library in LIBDIR, not
Martin v. Löwis <martin@v.loewis.de>
parents: 40420
diff changeset
247
17065
dd04bbfd5a76 Fix bug #233253: the --define and --undef options didn't work, whether
Andrew M. Kuchling <amk@amk.ca>
parents: 17021
diff changeset
248 # The argument parsing will result in self.define being a string, but
dd04bbfd5a76 Fix bug #233253: the --define and --undef options didn't work, whether
Andrew M. Kuchling <amk@amk.ca>
parents: 17021
diff changeset
249 # it has to be a list of 2-tuples. All the preprocessor symbols
dd04bbfd5a76 Fix bug #233253: the --define and --undef options didn't work, whether
Andrew M. Kuchling <amk@amk.ca>
parents: 17021
diff changeset
250 # specified by the 'define' option will be set to '1'. Multiple
dd04bbfd5a76 Fix bug #233253: the --define and --undef options didn't work, whether
Andrew M. Kuchling <amk@amk.ca>
parents: 17021
diff changeset
251 # symbols can be separated with commas.
21268
d296e6bb17e5 Whitespace normalization.
Fred Drake <fdrake@acm.org>
parents: 18835
diff changeset
252
17065
dd04bbfd5a76 Fix bug #233253: the --define and --undef options didn't work, whether
Andrew M. Kuchling <amk@amk.ca>
parents: 17021
diff changeset
253 if self.define:
53968
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
254 defines = self.define.split(',')
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
255 self.define = map(lambda symbol: (symbol, '1'), defines)
17065
dd04bbfd5a76 Fix bug #233253: the --define and --undef options didn't work, whether
Andrew M. Kuchling <amk@amk.ca>
parents: 17021
diff changeset
256
dd04bbfd5a76 Fix bug #233253: the --define and --undef options didn't work, whether
Andrew M. Kuchling <amk@amk.ca>
parents: 17021
diff changeset
257 # The option for macros to undefine is also a string from the
dd04bbfd5a76 Fix bug #233253: the --define and --undef options didn't work, whether
Andrew M. Kuchling <amk@amk.ca>
parents: 17021
diff changeset
258 # option parsing, but has to be a list. Multiple symbols can also
dd04bbfd5a76 Fix bug #233253: the --define and --undef options didn't work, whether
Andrew M. Kuchling <amk@amk.ca>
parents: 17021
diff changeset
259 # be separated with commas here.
dd04bbfd5a76 Fix bug #233253: the --define and --undef options didn't work, whether
Andrew M. Kuchling <amk@amk.ca>
parents: 17021
diff changeset
260 if self.undef:
53968
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
261 self.undef = self.undef.split(',')
17065
dd04bbfd5a76 Fix bug #233253: the --define and --undef options didn't work, whether
Andrew M. Kuchling <amk@amk.ca>
parents: 17021
diff changeset
262
33759
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
263 if self.swig_opts is None:
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
264 self.swig_opts = []
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
265 else:
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
266 self.swig_opts = self.swig_opts.split(' ')
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
267
46788
f3f6a895a555 Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents: 46331
diff changeset
268 # Finally add the user include and library directories if requested
f3f6a895a555 Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents: 46331
diff changeset
269 if self.user:
f3f6a895a555 Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents: 46331
diff changeset
270 user_include = os.path.join(USER_BASE, "include")
f3f6a895a555 Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents: 46331
diff changeset
271 user_lib = os.path.join(USER_BASE, "lib")
f3f6a895a555 Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents: 46331
diff changeset
272 if os.path.isdir(user_include):
f3f6a895a555 Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents: 46331
diff changeset
273 self.include_dirs.append(user_include)
f3f6a895a555 Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents: 46331
diff changeset
274 if os.path.isdir(user_lib):
f3f6a895a555 Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents: 46331
diff changeset
275 self.library_dirs.append(user_lib)
f3f6a895a555 Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents: 46331
diff changeset
276 self.rpath.append(user_lib)
f3f6a895a555 Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents: 46331
diff changeset
277
53968
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
278 def run(self):
11683
47f75a17b103 Added 'description' class attribute to every command class (to help the
Greg Ward <gward@python.net>
parents: 11544
diff changeset
279 from distutils.ccompiler import new_compiler
47f75a17b103 Added 'description' class attribute to every command class (to help the
Greg Ward <gward@python.net>
parents: 11544
diff changeset
280
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
281 # 'self.extensions', as supplied by setup.py, is a list of
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
282 # Extension instances. See the documentation for Extension (in
12942
a8530d36021c Pulled the MSVC++-specific hackery out to a new method, 'prelink_hook()',
Greg Ward <gward@python.net>
parents: 12869
diff changeset
283 # distutils.extension) for details.
21268
d296e6bb17e5 Whitespace normalization.
Fred Drake <fdrake@acm.org>
parents: 18835
diff changeset
284 #
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
285 # For backwards compatibility with Distutils 0.8.2 and earlier, we
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
286 # also allow the 'extensions' list to be a list of tuples:
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
287 # (ext_name, build_info)
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
288 # where build_info is a dictionary containing everything that
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
289 # Extension instances do except the name, with a few things being
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
290 # differently named. We convert these 2-tuples to Extension
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
291 # instances as needed.
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
292
11262
810c25d5041c Changed to reflect the new "command options" regime -- in particular,
Greg Ward <gward@python.net>
parents: 11246
diff changeset
293 if not self.extensions:
810c25d5041c Changed to reflect the new "command options" regime -- in particular,
Greg Ward <gward@python.net>
parents: 11246
diff changeset
294 return
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
295
12057
42d8d76dae6d Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents: 12029
diff changeset
296 # If we were asked to build any C/C++ libraries, make sure that the
42d8d76dae6d Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents: 12029
diff changeset
297 # directory where we put them is in the library search path for
42d8d76dae6d Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents: 12029
diff changeset
298 # linking extensions.
12095
4387606a1281 Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents: 12057
diff changeset
299 if self.distribution.has_c_libraries():
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14914
diff changeset
300 build_clib = self.get_finalized_command('build_clib')
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14914
diff changeset
301 self.libraries.extend(build_clib.get_library_names() or [])
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14914
diff changeset
302 self.library_dirs.append(build_clib.build_clib)
12057
42d8d76dae6d Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents: 12029
diff changeset
303
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
304 # Setup the CCompiler object that we'll use to do all the
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
305 # compiling and linking
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
306 self.compiler = new_compiler(compiler=self.compiler,
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
307 verbose=self.verbose,
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
308 dry_run=self.dry_run,
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
309 force=self.force)
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
310 customize_compiler(self.compiler)
46331
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
311 # If we are cross-compiling, init the compiler now (if we are not
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
312 # cross-compiling, init would not hurt, but people may rely on
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
313 # late initialization of compiler even if they shouldn't...)
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 45413
diff changeset
314 if os.name == 'nt' and self.plat_name != get_platform():
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
315 self.compiler.initialize(self.plat_name)
12057
42d8d76dae6d Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents: 12029
diff changeset
316
42d8d76dae6d Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents: 12029
diff changeset
317 # And make sure that any compile/link-related options (which might
42d8d76dae6d Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents: 12029
diff changeset
318 # come from the command-line or from the setup script) are set in
42d8d76dae6d Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents: 12029
diff changeset
319 # that CCompiler object -- that way, they automatically apply to
42d8d76dae6d Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents: 12029
diff changeset
320 # all compiling and linking done here.
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
321 if self.include_dirs is not None:
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
322 self.compiler.set_include_dirs(self.include_dirs)
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
323 if self.define is not None:
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
324 # 'define' option is a list of (name,value) tuples
53968
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
325 for (name, value) in self.define:
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
326 self.compiler.define_macro(name, value)
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
327 if self.undef is not None:
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
328 for macro in self.undef:
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
329 self.compiler.undefine_macro(macro)
12057
42d8d76dae6d Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents: 12029
diff changeset
330 if self.libraries is not None:
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
331 self.compiler.set_libraries(self.libraries)
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
332 if self.library_dirs is not None:
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
333 self.compiler.set_library_dirs(self.library_dirs)
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
334 if self.rpath is not None:
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
335 self.compiler.set_runtime_library_dirs(self.rpath)
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
336 if self.link_objects is not None:
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
337 self.compiler.set_link_objects(self.link_objects)
11896
2802fb52e99b If the "build_lib" command built any C libraries, link with them all
Greg Ward <gward@python.net>
parents: 11886
diff changeset
338
12057
42d8d76dae6d Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents: 12029
diff changeset
339 # Now actually compile and link everything.
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14914
diff changeset
340 self.build_extensions()
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
341
53968
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
342 def check_extensions_list(self, extensions):
11712
9250e5d3aa31 Tweaked various comments, docstrings, and error messages.
Greg Ward <gward@python.net>
parents: 11702
diff changeset
343 """Ensure that the list of extensions (presumably provided as a
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
344 command option 'extensions') is valid, i.e. it is a list of
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
345 Extension objects. We also support the old-style list of 2-tuples,
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
346 where the tuples are (ext_name, build_info), which are converted to
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
347 Extension instances here.
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
348
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
349 Raise DistutilsSetupError if the structure is invalid anywhere;
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
350 just returns otherwise.
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
351 """
53968
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
352 if not isinstance(extensions, list):
12407
01cff9fe2d45 Cleaned up/simplified error-handling:
Greg Ward <gward@python.net>
parents: 12402
diff changeset
353 raise DistutilsSetupError, \
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
354 "'ext_modules' option must be a list of Extension instances"
21268
d296e6bb17e5 Whitespace normalization.
Fred Drake <fdrake@acm.org>
parents: 18835
diff changeset
355
53968
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
356 for i, ext in enumerate(extensions):
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
357 if isinstance(ext, Extension):
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
358 continue # OK! (assume type-checking done
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
359 # by Extension constructor)
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
360
53968
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
361 if not isinstance(ext, tuple) or len(ext) != 2:
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
362 raise DistutilsSetupError, \
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
363 ("each element of 'ext_modules' option must be an "
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
364 "Extension instance or 2-tuple")
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
365
53968
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
366 ext_name, build_info = ext
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
367
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
368 log.warn(("old-style (ext_name, build_info) tuple found in "
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
369 "ext_modules for extension '%s'"
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
370 "-- please convert to Extension instance" % ext_name))
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
371
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
372 if not (isinstance(ext_name, str) and
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
373 extension_name_re.match(ext_name)):
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
374 raise DistutilsSetupError, \
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
375 ("first element of each tuple in 'ext_modules' "
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
376 "must be the extension name (a string)")
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
377
53968
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
378 if not isinstance(build_info, dict):
12407
01cff9fe2d45 Cleaned up/simplified error-handling:
Greg Ward <gward@python.net>
parents: 12402
diff changeset
379 raise DistutilsSetupError, \
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
380 ("second element of each tuple in 'ext_modules' "
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
381 "must be a dictionary (build info)")
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
382
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
383 # OK, the (ext_name, build_info) dict is type-safe: convert it
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
384 # to an Extension instance.
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
385 ext = Extension(ext_name, build_info['sources'])
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
386
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
387 # Easy stuff: one-to-one mapping from dict elements to
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
388 # instance attributes.
53968
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
389 for key in ('include_dirs', 'library_dirs', 'libraries',
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
390 'extra_objects', 'extra_compile_args',
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
391 'extra_link_args'):
14216
d33179cdc511 In 'check_extensions_list()': when converting old-style 'buildinfo' dict,
Greg Ward <gward@python.net>
parents: 13950
diff changeset
392 val = build_info.get(key)
d33179cdc511 In 'check_extensions_list()': when converting old-style 'buildinfo' dict,
Greg Ward <gward@python.net>
parents: 13950
diff changeset
393 if val is not None:
d33179cdc511 In 'check_extensions_list()': when converting old-style 'buildinfo' dict,
Greg Ward <gward@python.net>
parents: 13950
diff changeset
394 setattr(ext, key, val)
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
395
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
396 # Medium-easy stuff: same syntax/semantics, different names.
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
397 ext.runtime_library_dirs = build_info.get('rpath')
45413
8a187f562959 Removed uses of dict.has_key() from distutils, and uses of
Guido van Rossum <guido@python.org>
parents: 45133
diff changeset
398 if 'def_file' in build_info:
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 23273
diff changeset
399 log.warn("'def_file' element of build info dict "
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 23273
diff changeset
400 "no longer supported")
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
401
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
402 # Non-trivial stuff: 'macros' split into 'define_macros'
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
403 # and 'undef_macros'.
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
404 macros = build_info.get('macros')
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
405 if macros:
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
406 ext.define_macros = []
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
407 ext.undef_macros = []
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
408 for macro in macros:
53968
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
409 if not (isinstance(macro, tuple) and len(macro) in (1, 2)):
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
410 raise DistutilsSetupError, \
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
411 ("'macros' element of build info dict "
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
412 "must be 1- or 2-tuple")
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
413 if len(macro) == 1:
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
414 ext.undef_macros.append(macro[0])
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
415 elif len(macro) == 2:
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
416 ext.define_macros.append(macro)
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
417
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
418 extensions[i] = ext
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
419
53968
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
420 def get_source_files(self):
13599
3260220aaee4 Typo fix from Bastian Kleineidam
Andrew M. Kuchling <amk@amk.ca>
parents: 13413
diff changeset
421 self.check_extensions_list(self.extensions)
11340
7ae5c4051041 Added 'package' option.
Greg Ward <gward@python.net>
parents: 11300
diff changeset
422 filenames = []
7ae5c4051041 Added 'package' option.
Greg Ward <gward@python.net>
parents: 11300
diff changeset
423
7ae5c4051041 Added 'package' option.
Greg Ward <gward@python.net>
parents: 11300
diff changeset
424 # Wouldn't it be neat if we knew the names of header files too...
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
425 for ext in self.extensions:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14914
diff changeset
426 filenames.extend(ext.sources)
11340
7ae5c4051041 Added 'package' option.
Greg Ward <gward@python.net>
parents: 11300
diff changeset
427
7ae5c4051041 Added 'package' option.
Greg Ward <gward@python.net>
parents: 11300
diff changeset
428 return filenames
7ae5c4051041 Added 'package' option.
Greg Ward <gward@python.net>
parents: 11300
diff changeset
429
53968
e91a77a482eb fixed #5984 and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 52616
diff changeset
430 def get_outputs(self):
12095
4387606a1281 Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents: 12057
diff changeset
431 # Sanity check the 'extensions' list -- can't assume this is being
4387606a1281 Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents: 12057
diff changeset
432 # done in the same run as a 'build_extensions()' call (in fact, we
4387606a1281 Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents: 12057
diff changeset
433 # can probably assume that it *isn't*!).
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14914
diff changeset
434 self.check_extensions_list(self.extensions)
12095
4387606a1281 Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents: 12057
diff changeset
435
4387606a1281 Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents: 12057
diff changeset
436 # And build the list of output (built) filenames. Note that this
4387606a1281 Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents: 12057
diff changeset
437 # ignores the 'inplace' flag, and assumes everything goes in the
4387606a1281 Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents: 12057
diff changeset
438 # "build" tree.
4387606a1281 Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents: 12057
diff changeset
439 outputs = []
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
440 for ext in self.extensions:
54021
e8209ab49691 fixed #5977: distutils build_ext.get_outputs was not using the inplace option
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53968
diff changeset
441 outputs.append(self.get_ext_fullpath(ext.name))
12095
4387606a1281 Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents: 12057
diff changeset
442 return outputs
4387606a1281 Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents: 12057
diff changeset
443
16281
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
444 def build_extensions(self):
12095
4387606a1281 Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents: 12057
diff changeset
445 # First, sanity-check the 'extensions' list
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14914
diff changeset
446 self.check_extensions_list(self.extensions)
12095
4387606a1281 Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents: 12057
diff changeset
447
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
448 for ext in self.extensions:
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
449 self.build_extension(ext)
16281
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
450
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
451 def build_extension(self, ext):
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
452 sources = ext.sources
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
453 if sources is None or type(sources) not in (ListType, TupleType):
16281
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
454 raise DistutilsSetupError, \
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
455 ("in 'ext_modules' option (extension '%s'), " +
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
456 "'sources' must be present and must be " +
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
457 "a list of source filenames") % ext.name
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
458 sources = list(sources)
12764
c8a9d1766465 Rene Liebscher: check if the extension file (.so or .pyd) is
Greg Ward <gward@python.net>
parents: 12743
diff changeset
459
54021
e8209ab49691 fixed #5977: distutils build_ext.get_outputs was not using the inplace option
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53968
diff changeset
460 ext_path = self.get_ext_fullpath(ext.name)
23792
7dd432e1de26 Add a new definition to Extension objects: depends.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 23777
diff changeset
461 depends = sources + ext.depends
54021
e8209ab49691 fixed #5977: distutils build_ext.get_outputs was not using the inplace option
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53968
diff changeset
462 if not (self.force or newer_group(depends, ext_path, 'newer')):
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 23273
diff changeset
463 log.debug("skipping '%s' extension (up-to-date)", ext.name)
16281
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
464 return
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
465 else:
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 23273
diff changeset
466 log.info("building '%s' extension", ext.name)
11702
7f29339ec3a5 Improved an error message.
Greg Ward <gward@python.net>
parents: 11683
diff changeset
467
16281
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
468 # First, scan the sources for SWIG definition files (.i), run
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
469 # SWIG on 'em to create .c files, and modify the sources list
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
470 # accordingly.
33759
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
471 sources = self.swig_sources(sources, ext)
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
472
16281
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
473 # Next, compile the source code to object files.
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
474
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
475 # XXX not honouring 'define_macros' or 'undef_macros' -- the
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
476 # CCompiler API needs to change to accommodate this, and I
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
477 # want to do one thing at a time!
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
478
16281
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
479 # Two possible sources for extra compiler arguments:
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
480 # - 'extra_compile_args' in Extension object
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
481 # - CFLAGS environment variable (not particularly
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
482 # elegant, but people seem to expect it and I
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
483 # guess it's useful)
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
484 # The environment variable should take precedence, and
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
485 # any sensible compiler will give precedence to later
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
486 # command line args. Hence we combine them in order:
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
487 extra_args = ext.extra_compile_args or []
12800
3aab0c519009 Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents: 12783
diff changeset
488
16281
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
489 macros = ext.define_macros[:]
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
490 for undef in ext.undef_macros:
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
491 macros.append((undef,))
14652
f4f3841a26ed Fixed to respect 'define_macros' and 'undef_macros' on Extension object.
Greg Ward <gward@python.net>
parents: 14612
diff changeset
492
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
493 objects = self.compiler.compile(sources,
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
494 output_dir=self.build_temp,
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
495 macros=macros,
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
496 include_dirs=ext.include_dirs,
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
497 debug=self.debug,
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
498 extra_postargs=extra_args,
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
499 depends=ext.depends)
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
500
21277
f702ff390e4d Visious hackery to solve a build-control problem related to our use of
Fred Drake <fdrake@acm.org>
parents: 21268
diff changeset
501 # XXX -- this is a Vile HACK!
f702ff390e4d Visious hackery to solve a build-control problem related to our use of
Fred Drake <fdrake@acm.org>
parents: 21268
diff changeset
502 #
f702ff390e4d Visious hackery to solve a build-control problem related to our use of
Fred Drake <fdrake@acm.org>
parents: 21268
diff changeset
503 # The setup.py script for Python on Unix needs to be able to
f702ff390e4d Visious hackery to solve a build-control problem related to our use of
Fred Drake <fdrake@acm.org>
parents: 21268
diff changeset
504 # get this list so it can perform all the clean up needed to
f702ff390e4d Visious hackery to solve a build-control problem related to our use of
Fred Drake <fdrake@acm.org>
parents: 21268
diff changeset
505 # avoid keeping object files around when cleaning out a failed
f702ff390e4d Visious hackery to solve a build-control problem related to our use of
Fred Drake <fdrake@acm.org>
parents: 21268
diff changeset
506 # build of an extension module. Since Distutils does not
f702ff390e4d Visious hackery to solve a build-control problem related to our use of
Fred Drake <fdrake@acm.org>
parents: 21268
diff changeset
507 # track dependencies, we have to get rid of intermediates to
f702ff390e4d Visious hackery to solve a build-control problem related to our use of
Fred Drake <fdrake@acm.org>
parents: 21268
diff changeset
508 # ensure all the intermediates will be properly re-built.
f702ff390e4d Visious hackery to solve a build-control problem related to our use of
Fred Drake <fdrake@acm.org>
parents: 21268
diff changeset
509 #
f702ff390e4d Visious hackery to solve a build-control problem related to our use of
Fred Drake <fdrake@acm.org>
parents: 21268
diff changeset
510 self._built_objects = objects[:]
f702ff390e4d Visious hackery to solve a build-control problem related to our use of
Fred Drake <fdrake@acm.org>
parents: 21268
diff changeset
511
16281
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
512 # Now link the object files together into a "shared object" --
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
513 # of course, first we have to figure out all the other things
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
514 # that go into the mix.
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
515 if ext.extra_objects:
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
516 objects.extend(ext.extra_objects)
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
517 extra_args = ext.extra_link_args or []
11736
e19a350994b7 Path from Thomas Heller: resurrect the .def file kludge while preserving the
Greg Ward <gward@python.net>
parents: 11732
diff changeset
518
26036
771b6f521b95 This patch fixes the following bugs:
Gustavo Niemeyer <gustavo@niemeyer.net>
parents: 26018
diff changeset
519 # Detect target language, if not provided
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
520 language = ext.language or self.compiler.detect_language(sources)
26036
771b6f521b95 This patch fixes the following bugs:
Gustavo Niemeyer <gustavo@niemeyer.net>
parents: 26018
diff changeset
521
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
522 self.compiler.link_shared_object(
54021
e8209ab49691 fixed #5977: distutils build_ext.get_outputs was not using the inplace option
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53968
diff changeset
523 objects, ext_path,
16281
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
524 libraries=self.get_libraries(ext),
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
525 library_dirs=ext.library_dirs,
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
526 runtime_library_dirs=ext.runtime_library_dirs,
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
527 extra_postargs=extra_args,
21268
d296e6bb17e5 Whitespace normalization.
Fred Drake <fdrake@acm.org>
parents: 18835
diff changeset
528 export_symbols=self.get_export_symbols(ext),
16281
2abcbe44271a Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents: 16211
diff changeset
529 debug=self.debug,
26036
771b6f521b95 This patch fixes the following bugs:
Gustavo Niemeyer <gustavo@niemeyer.net>
parents: 26018
diff changeset
530 build_temp=self.build_temp,
771b6f521b95 This patch fixes the following bugs:
Gustavo Niemeyer <gustavo@niemeyer.net>
parents: 26018
diff changeset
531 target_lang=language)
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
532
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
533
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
534 def swig_sources (self, sources, extension):
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
535
12996
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
536 """Walk the list of source files in 'sources', looking for SWIG
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
537 interface (.i) files. Run SWIG on all that are found, and
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
538 return a modified 'sources' list with SWIG source files replaced
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
539 by the generated C (or C++) files.
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
540 """
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
541
12996
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
542 new_sources = []
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
543 swig_sources = []
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
544 swig_targets = {}
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
545
13032
1240bc997c8f Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support.
Greg Ward <gward@python.net>
parents: 13014
diff changeset
546 # XXX this drops generated C/C++ files into the source tree, which
12996
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
547 # is fine for developers who want to distribute the generated
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
548 # source -- but there should be an option to put SWIG output in
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
549 # the temp dir.
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
550
13032
1240bc997c8f Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support.
Greg Ward <gward@python.net>
parents: 13014
diff changeset
551 if self.swig_cpp:
33759
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
552 log.warn("--swig-cpp is deprecated - use --swig-opts=-c++")
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
553
41521
7ea5949714ad Bug #1706381: Specifying the SWIG option "-c++" in the setup.py file
Georg Brandl <georg@python.org>
parents: 41149
diff changeset
554 if self.swig_cpp or ('-c++' in self.swig_opts) or \
7ea5949714ad Bug #1706381: Specifying the SWIG option "-c++" in the setup.py file
Georg Brandl <georg@python.org>
parents: 41149
diff changeset
555 ('-c++' in extension.swig_opts):
13032
1240bc997c8f Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support.
Greg Ward <gward@python.net>
parents: 13014
diff changeset
556 target_ext = '.cpp'
1240bc997c8f Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support.
Greg Ward <gward@python.net>
parents: 13014
diff changeset
557 else:
1240bc997c8f Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support.
Greg Ward <gward@python.net>
parents: 13014
diff changeset
558 target_ext = '.c'
1240bc997c8f Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support.
Greg Ward <gward@python.net>
parents: 13014
diff changeset
559
12996
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
560 for source in sources:
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
561 (base, ext) = os.path.splitext(source)
13010
fbacf6d55dc6 Fixed a few silly bugs in my SWIG support code. (Hey, I said it was
Greg Ward <gward@python.net>
parents: 12999
diff changeset
562 if ext == ".i": # SWIG interface file
21760
dbb703eb6b3d SWIGing a source file <name>.i silently overwrites <name>.c if it is
Thomas Heller <theller@ctypes.org>
parents: 21277
diff changeset
563 new_sources.append(base + '_wrap' + target_ext)
13010
fbacf6d55dc6 Fixed a few silly bugs in my SWIG support code. (Hey, I said it was
Greg Ward <gward@python.net>
parents: 12999
diff changeset
564 swig_sources.append(source)
12996
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
565 swig_targets[source] = new_sources[-1]
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
566 else:
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
567 new_sources.append(source)
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
568
13010
fbacf6d55dc6 Fixed a few silly bugs in my SWIG support code. (Hey, I said it was
Greg Ward <gward@python.net>
parents: 12999
diff changeset
569 if not swig_sources:
12996
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
570 return new_sources
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
571
33759
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
572 swig = self.swig or self.find_swig()
21760
dbb703eb6b3d SWIGing a source file <name>.i silently overwrites <name>.c if it is
Thomas Heller <theller@ctypes.org>
parents: 21277
diff changeset
573 swig_cmd = [swig, "-python"]
33759
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
574 swig_cmd.extend(self.swig_opts)
13032
1240bc997c8f Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support.
Greg Ward <gward@python.net>
parents: 13014
diff changeset
575 if self.swig_cpp:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14914
diff changeset
576 swig_cmd.append("-c++")
12996
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
577
33759
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
578 # Do not override commandline arguments
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
579 if not self.swig_opts:
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
580 for o in extension.swig_opts:
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
581 swig_cmd.append(o)
11d01fc650dc Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32736
diff changeset
582
12996
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
583 for source in swig_sources:
13032
1240bc997c8f Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support.
Greg Ward <gward@python.net>
parents: 13014
diff changeset
584 target = swig_targets[source]
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 23273
diff changeset
585 log.info("swigging %s to %s", source, target)
13032
1240bc997c8f Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support.
Greg Ward <gward@python.net>
parents: 13014
diff changeset
586 self.spawn(swig_cmd + ["-o", target, source])
12996
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
587
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
588 return new_sources
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
589
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
590 # swig_sources ()
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
591
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
592 def find_swig (self):
12996
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
593 """Return the name of the SWIG executable. On Unix, this is
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
594 just "swig" -- it should be in the PATH. Tries a bit harder on
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
595 Windows.
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
596 """
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
597
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
598 if os.name == "posix":
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
599 return "swig"
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
600 elif os.name == "nt":
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
601
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
602 # Look for SWIG in its standard installation directory on
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
603 # Windows (or so I presume!). If we find it there, great;
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
604 # if not, act like Unix and assume it's in the PATH.
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
605 for vers in ("1.3", "1.2", "1.1"):
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
606 fn = os.path.join("c:\\swig%s" % vers, "swig.exe")
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14914
diff changeset
607 if os.path.isfile(fn):
12996
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
608 return fn
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
609 else:
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
610 return "swig.exe"
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
611
21851
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
612 elif os.name == "os2":
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
613 # assume swig available in the PATH.
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
614 return "swig.exe"
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
615
12996
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
616 else:
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
617 raise DistutilsPlatformError, \
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
618 ("I don't know how to find (much less run) SWIG "
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
619 "on platform '%s'") % os.name
c75718fbd862 Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents: 12942
diff changeset
620
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
621 # find_swig ()
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
622
12942
a8530d36021c Pulled the MSVC++-specific hackery out to a new method, 'prelink_hook()',
Greg Ward <gward@python.net>
parents: 12869
diff changeset
623 # -- Name generators -----------------------------------------------
a8530d36021c Pulled the MSVC++-specific hackery out to a new method, 'prelink_hook()',
Greg Ward <gward@python.net>
parents: 12869
diff changeset
624 # (extension names, filenames, whatever)
54021
e8209ab49691 fixed #5977: distutils build_ext.get_outputs was not using the inplace option
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53968
diff changeset
625 def get_ext_fullpath(self, ext_name):
e8209ab49691 fixed #5977: distutils build_ext.get_outputs was not using the inplace option
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53968
diff changeset
626 """Returns the path of the filename for a given extension.
12942
a8530d36021c Pulled the MSVC++-specific hackery out to a new method, 'prelink_hook()',
Greg Ward <gward@python.net>
parents: 12869
diff changeset
627
54021
e8209ab49691 fixed #5977: distutils build_ext.get_outputs was not using the inplace option
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53968
diff changeset
628 The file is located in `build_lib` or directly in the package
e8209ab49691 fixed #5977: distutils build_ext.get_outputs was not using the inplace option
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53968
diff changeset
629 (inplace option).
e8209ab49691 fixed #5977: distutils build_ext.get_outputs was not using the inplace option
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53968
diff changeset
630 """
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
631 # makes sure the extension name is only using dots
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
632 all_dots = string.maketrans('/'+os.sep, '..')
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
633 ext_name = ext_name.translate(all_dots)
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
634
54203
883ace7ea446 fixed the 'package' option of build_ext
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54181
diff changeset
635 fullname = self.get_ext_fullname(ext_name)
54977
3dcc8fc4354e Fixed 6365: wrong inplace location for build_ext if the extension had dots
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54203
diff changeset
636 modpath = fullname.split('.')
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
637 filename = self.get_ext_filename(ext_name)
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
638 filename = os.path.split(filename)[-1]
55066
85677a2c7855 Fixed #6403 : package path usage for build_ext
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54977
diff changeset
639
54203
883ace7ea446 fixed the 'package' option of build_ext
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54181
diff changeset
640 if not self.inplace:
883ace7ea446 fixed the 'package' option of build_ext
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54181
diff changeset
641 # no further work needed
55066
85677a2c7855 Fixed #6403 : package path usage for build_ext
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54977
diff changeset
642 # returning :
85677a2c7855 Fixed #6403 : package path usage for build_ext
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54977
diff changeset
643 # build_dir/package/path/filename
85677a2c7855 Fixed #6403 : package path usage for build_ext
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54977
diff changeset
644 filename = os.path.join(*modpath[:-1]+[filename])
54021
e8209ab49691 fixed #5977: distutils build_ext.get_outputs was not using the inplace option
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53968
diff changeset
645 return os.path.join(self.build_lib, filename)
e8209ab49691 fixed #5977: distutils build_ext.get_outputs was not using the inplace option
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53968
diff changeset
646
54203
883ace7ea446 fixed the 'package' option of build_ext
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54181
diff changeset
647 # the inplace option requires to find the package directory
55066
85677a2c7855 Fixed #6403 : package path usage for build_ext
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54977
diff changeset
648 # using the build_py command for that
85677a2c7855 Fixed #6403 : package path usage for build_ext
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54977
diff changeset
649 package = '.'.join(modpath[0:-1])
54203
883ace7ea446 fixed the 'package' option of build_ext
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54181
diff changeset
650 build_py = self.get_finalized_command('build_py')
883ace7ea446 fixed the 'package' option of build_ext
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54181
diff changeset
651 package_dir = os.path.abspath(build_py.get_package_dir(package))
55066
85677a2c7855 Fixed #6403 : package path usage for build_ext
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54977
diff changeset
652
85677a2c7855 Fixed #6403 : package path usage for build_ext
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54977
diff changeset
653 # returning
85677a2c7855 Fixed #6403 : package path usage for build_ext
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54977
diff changeset
654 # package_dir/filename
54203
883ace7ea446 fixed the 'package' option of build_ext
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54181
diff changeset
655 return os.path.join(package_dir, filename)
883ace7ea446 fixed the 'package' option of build_ext
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54181
diff changeset
656
54021
e8209ab49691 fixed #5977: distutils build_ext.get_outputs was not using the inplace option
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53968
diff changeset
657 def get_ext_fullname(self, ext_name):
e8209ab49691 fixed #5977: distutils build_ext.get_outputs was not using the inplace option
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53968
diff changeset
658 """Returns the fullname of a given extension name.
e8209ab49691 fixed #5977: distutils build_ext.get_outputs was not using the inplace option
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53968
diff changeset
659
e8209ab49691 fixed #5977: distutils build_ext.get_outputs was not using the inplace option
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53968
diff changeset
660 Adds the `package.` prefix"""
11886
270a11488c6c Build reorg:
Greg Ward <gward@python.net>
parents: 11817
diff changeset
661 if self.package is None:
270a11488c6c Build reorg:
Greg Ward <gward@python.net>
parents: 11817
diff changeset
662 return ext_name
270a11488c6c Build reorg:
Greg Ward <gward@python.net>
parents: 11817
diff changeset
663 else:
270a11488c6c Build reorg:
Greg Ward <gward@python.net>
parents: 11817
diff changeset
664 return self.package + '.' + ext_name
270a11488c6c Build reorg:
Greg Ward <gward@python.net>
parents: 11817
diff changeset
665
54181
e3bb6b62bd0f Fixed the library extension when distutils build_ext is used inplace
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54029
diff changeset
666 def get_ext_filename(self, ext_name):
17021
f0efdcd24512 Make docstrings raw, since they contain literal backslashes.
Ka-Ping Yee <ping@zesty.ca>
parents: 16637
diff changeset
667 r"""Convert the name of an extension (eg. "foo.bar") into the name
12942
a8530d36021c Pulled the MSVC++-specific hackery out to a new method, 'prelink_hook()',
Greg Ward <gward@python.net>
parents: 12869
diff changeset
668 of the file from which it will be loaded (eg. "foo/bar.so", or
a8530d36021c Pulled the MSVC++-specific hackery out to a new method, 'prelink_hook()',
Greg Ward <gward@python.net>
parents: 12869
diff changeset
669 "foo\bar.pyd").
a8530d36021c Pulled the MSVC++-specific hackery out to a new method, 'prelink_hook()',
Greg Ward <gward@python.net>
parents: 12869
diff changeset
670 """
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
671 from distutils.sysconfig import get_config_var
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
672 ext_path = string.split(ext_name, '.')
21851
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
673 # OS/2 has an 8 character module (extension) limit :-(
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
674 if os.name == "os2":
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
675 ext_path[len(ext_path) - 1] = ext_path[len(ext_path) - 1][:8]
12164
42387ade6afb Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents: 12117
diff changeset
676 # extensions in debug_mode are named 'module_d.pyd' under windows
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
677 so_ext = get_config_var('SO')
12164
42387ade6afb Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents: 12117
diff changeset
678 if os.name == 'nt' and self.debug:
60132
a404e3702f79 #7092: Fix some -3 warnings, and fix Lib/platform.py when the path contains a double-quote.
Florent Xicluna <florent.xicluna@gmail.com>
parents: 59343
diff changeset
679 return os.path.join(*ext_path) + '_d' + so_ext
48260
2be17d368a9c Update distutils so that it triggers no warnings when run under -3.
Brett Cannon <bcannon@gmail.com>
parents: 48228
diff changeset
680 return os.path.join(*ext_path) + so_ext
11199
c52fbc6bd38a Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff changeset
681
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
682 def get_export_symbols (self, ext):
13797
e00d3ce71f89 Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents: 13725
diff changeset
683 """Return the list of symbols that a shared extension has to
e00d3ce71f89 Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents: 13725
diff changeset
684 export. This either uses 'ext.export_symbols' or, if it's not
55216
3dadf3453d05 reverted changes for #6459 (doesn't apply on 2.x)
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 55208
diff changeset
685 provided, "init" + module_name. Only relevant on Windows, where
3dadf3453d05 reverted changes for #6459 (doesn't apply on 2.x)
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 55208
diff changeset
686 the .pyd file (DLL) must export the module "init" function.
13797
e00d3ce71f89 Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents: 13725
diff changeset
687 """
55216
3dadf3453d05 reverted changes for #6459 (doesn't apply on 2.x)
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 55208
diff changeset
688 initfunc_name = "init" + ext.name.split('.')[-1]
13950
370ade88a52a get_export_symbols() changed, adds now module init function if not given
Greg Ward <gward@python.net>
parents: 13797
diff changeset
689 if initfunc_name not in ext.export_symbols:
370ade88a52a get_export_symbols() changed, adds now module init function if not given
Greg Ward <gward@python.net>
parents: 13797
diff changeset
690 ext.export_symbols.append(initfunc_name)
370ade88a52a get_export_symbols() changed, adds now module init function if not given
Greg Ward <gward@python.net>
parents: 13797
diff changeset
691 return ext.export_symbols
13797
e00d3ce71f89 Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents: 13725
diff changeset
692
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
693 def get_libraries (self, ext):
13797
e00d3ce71f89 Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents: 13725
diff changeset
694 """Return the list of libraries to link against when building a
e00d3ce71f89 Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents: 13725
diff changeset
695 shared extension. On most platforms, this is just 'ext.libraries';
21851
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
696 on Windows and OS/2, we add the Python library (eg. python20.dll).
13797
e00d3ce71f89 Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents: 13725
diff changeset
697 """
e00d3ce71f89 Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents: 13725
diff changeset
698 # The python library is always needed on Windows. For MSVC, this
e00d3ce71f89 Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents: 13725
diff changeset
699 # is redundant, since the library is mentioned in a pragma in
18835
2dea40e40d9d Patch #411138: Rename config.h to pyconfig.h. Closes bug #231774.
Martin v. Löwis <martin@v.loewis.de>
parents: 17065
diff changeset
700 # pyconfig.h that MSVC groks. The other Windows compilers all seem
13797
e00d3ce71f89 Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents: 13725
diff changeset
701 # to need it mentioned explicitly, though, so that's what we do.
14914
79cdeeeefafa Removed the implib_dir instance variable because it is unused.
Thomas Heller <theller@ctypes.org>
parents: 14829
diff changeset
702 # Append '_d' to the python import library on debug builds.
23910
921064c26297 Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 23824
diff changeset
703 if sys.platform == "win32":
921064c26297 Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 23824
diff changeset
704 from distutils.msvccompiler import MSVCCompiler
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
705 if not isinstance(self.compiler, MSVCCompiler):
23910
921064c26297 Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 23824
diff changeset
706 template = "python%d%d"
921064c26297 Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 23824
diff changeset
707 if self.debug:
921064c26297 Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 23824
diff changeset
708 template = template + '_d'
921064c26297 Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 23824
diff changeset
709 pythonlib = (template %
921064c26297 Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 23824
diff changeset
710 (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
921064c26297 Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 23824
diff changeset
711 # don't extend ext.libraries, it may be shared with other
921064c26297 Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 23824
diff changeset
712 # extensions, it is a reference to the original list
921064c26297 Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 23824
diff changeset
713 return ext.libraries + [pythonlib]
25976
2d837e2083fa Fixes SF bug#614051: win32 build_ext problem.
Thomas Heller <theller@ctypes.org>
parents: 23910
diff changeset
714 else:
2d837e2083fa Fixes SF bug#614051: win32 build_ext problem.
Thomas Heller <theller@ctypes.org>
parents: 23910
diff changeset
715 return ext.libraries
21851
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
716 elif sys.platform == "os2emx":
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
717 # EMX/GCC requires the python library explicitly, and I
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
718 # believe VACPP does as well (though not confirmed) - AIM Apr01
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
719 template = "python%d%d"
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 32063
diff changeset
720 # debug versions of the main DLL aren't supported, at least
21851
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
721 # not at this time - AIM Apr01
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
722 #if self.debug:
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
723 # template = template + '_d'
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
724 pythonlib = (template %
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
725 (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
726 # don't extend ext.libraries, it may be shared with other
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
727 # extensions, it is a reference to the original list
e0fc286d57a4 OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents: 21760
diff changeset
728 return ext.libraries + [pythonlib]
16211
98b65484ade6 Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents: 15770
diff changeset
729 elif sys.platform[:6] == "cygwin":
98b65484ade6 Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents: 15770
diff changeset
730 template = "python%d.%d"
98b65484ade6 Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents: 15770
diff changeset
731 pythonlib = (template %
98b65484ade6 Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents: 15770
diff changeset
732 (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
98b65484ade6 Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents: 15770
diff changeset
733 # don't extend ext.libraries, it may be shared with other
98b65484ade6 Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents: 15770
diff changeset
734 # extensions, it is a reference to the original list
98b65484ade6 Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents: 15770
diff changeset
735 return ext.libraries + [pythonlib]
23777
bec1b942e0bc Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents: 23668
diff changeset
736 elif sys.platform[:6] == "atheos":
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
737 from distutils import sysconfig
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
738
23777
bec1b942e0bc Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents: 23668
diff changeset
739 template = "python%d.%d"
bec1b942e0bc Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents: 23668
diff changeset
740 pythonlib = (template %
bec1b942e0bc Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents: 23668
diff changeset
741 (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
bec1b942e0bc Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents: 23668
diff changeset
742 # Get SHLIBS from Makefile
bec1b942e0bc Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents: 23668
diff changeset
743 extra = []
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
744 for lib in sysconfig.get_config_var('SHLIBS').split():
23777
bec1b942e0bc Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents: 23668
diff changeset
745 if lib.startswith('-l'):
bec1b942e0bc Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents: 23668
diff changeset
746 extra.append(lib[2:])
bec1b942e0bc Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents: 23668
diff changeset
747 else:
bec1b942e0bc Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents: 23668
diff changeset
748 extra.append(lib)
bec1b942e0bc Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents: 23668
diff changeset
749 # don't extend ext.libraries, it may be shared with other
bec1b942e0bc Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents: 23668
diff changeset
750 # extensions, it is a reference to the original list
bec1b942e0bc Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents: 23668
diff changeset
751 return ext.libraries + [pythonlib, "m"] + extra
38247
5b587190f4c6 Disable linking extensions with -lpython2.5 for darwin. This should fix bug
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 37561
diff changeset
752
5b587190f4c6 Disable linking extensions with -lpython2.5 for darwin. This should fix bug
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 37561
diff changeset
753 elif sys.platform == 'darwin':
5b587190f4c6 Disable linking extensions with -lpython2.5 for darwin. This should fix bug
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 37561
diff changeset
754 # Don't use the default code below
5b587190f4c6 Disable linking extensions with -lpython2.5 for darwin. This should fix bug
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 37561
diff changeset
755 return ext.libraries
64618
e27030e0cced Merged revisions 84680 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 60132
diff changeset
756 elif sys.platform[:3] == 'aix':
e27030e0cced Merged revisions 84680 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 60132
diff changeset
757 # Don't use the default code below
e27030e0cced Merged revisions 84680 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents: 60132
diff changeset
758 return ext.libraries
13797
e00d3ce71f89 Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents: 13725
diff changeset
759 else:
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
760 from distutils import sysconfig
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
761 if sysconfig.get_config_var('Py_ENABLE_SHARED'):
37561
bd375777932d Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents: 33965
diff changeset
762 template = "python%d.%d"
bd375777932d Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents: 33965
diff changeset
763 pythonlib = (template %
bd375777932d Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents: 33965
diff changeset
764 (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
bd375777932d Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents: 33965
diff changeset
765 return ext.libraries + [pythonlib]
bd375777932d Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents: 33965
diff changeset
766 else:
bd375777932d Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents: 33965
diff changeset
767 return ext.libraries
59343
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
768
ad22bc22dddc reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58503
diff changeset
769 # class build_ext