Mercurial > cpython-lru_cache-weakref
annotate Lib/distutils/command/build_ext.py @ 80661:94de77bd0b4b 2.7
Issue #16194: document imp.load_dynamic problems
when read several extension modules from the same binary object file.
| author | Andrew Svetlov <andrew.svetlov@gmail.com> |
|---|---|
| date | Thu, 29 Nov 2012 19:51:28 +0200 |
| parents | 96f5718bf005 |
| children | 28e6c23c8ae6 |
| 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 |
|
33965
893d46576737
Update compatibility comments to 2.1, corresponding to PEP 291 1.13.
Martin v. Löwis <martin@v.loewis.de>
parents:
33759
diff
changeset
|
7 # This module should be kept compatible with Python 2.1. |
|
26285
42bfc98d295b
Add comment to Distutil files about requiring 1.5.2 compatibility, as
Andrew M. Kuchling <amk@amk.ca>
parents:
26210
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 |
|
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
11 import sys, os, string, re |
|
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
12 from types import * |
|
46788
f3f6a895a555
Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents:
46331
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 |
|
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
15 from distutils.errors import * |
|
26206
ff92cc27fd1f
[Bug #550364] Use sysconfig.get_python_version()
Andrew M. Kuchling <amk@amk.ca>
parents:
26036
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 |
|
46331
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
45413
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 | 26 # An extension name is just a dot-separated list of Python NAMEs (ie. |
| 27 # the same as a fully-qualified module name). | |
| 28 extension_name_re = re.compile \ | |
| 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 |
|
11813
eaeda4621f7d
Renamed all command classes so they're exactly the same as the name of the
Greg Ward <gward@python.net>
parents:
11736
diff
changeset
|
37 class build_ext (Command): |
| 21268 | 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 | 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 | 63 ('build-temp=', 't', |
| 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 | 68 ('inplace', 'i', |
| 14434 | 69 "ignore build-lib and put compiled extensions into the source " + |
| 11886 | 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"), |
|
46788
f3f6a895a555
Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents:
46331
diff
changeset
|
97 ('user', None, |
|
f3f6a895a555
Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents:
46331
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 |
|
46788
f3f6a895a555
Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents:
46331
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 |
|
11817
476eaa38e2d6
Renamed 'set_default_options()' to 'initialize_options()', and
Greg Ward <gward@python.net>
parents:
11815
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 | 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 | 112 self.build_temp = None |
| 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 | 130 |
|
53969
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
131 def finalize_options(self): |
|
11683
47f75a17b103
Added 'description' class attribute to every command class (to help the
Greg Ward <gward@python.net>
parents:
11544
diff
changeset
|
132 from distutils import sysconfig |
|
47f75a17b103
Added 'description' class attribute to every command class (to help the
Greg Ward <gward@python.net>
parents:
11544
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 | 144 self.package = self.distribution.ext_package |
| 145 | |
| 146 self.extensions = self.distribution.ext_modules | |
| 21268 | 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. |
|
4c51a966d2a3
Use 'get_python_inc()' to figure out the Python include directories
Greg Ward <gward@python.net>
parents:
12314
diff
changeset
|
150 py_include = sysconfig.get_python_inc() |
|
4c51a966d2a3
Use 'get_python_inc()' to figure out the Python include directories
Greg Ward <gward@python.net>
parents:
12314
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 | 153 self.include_dirs = self.distribution.include_dirs or [] |
|
53969
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
154 if isinstance(self.include_dirs, str): |
|
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
155 self.include_dirs = self.include_dirs.split(os.pathsep) |
| 11340 | 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 |
|
74950
96f5718bf005
Fix parsing of build_ext --libraries option (#1326113)
Éric Araujo <merwok@netwok.org>
parents:
68256
diff
changeset
|
163 self.ensure_string_list('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
|
164 |
|
12164
42387ade6afb
Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents:
12117
diff
changeset
|
165 # 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
|
166 # 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
|
167 if self.libraries is None: |
|
42387ade6afb
Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents:
12117
diff
changeset
|
168 self.libraries = [] |
|
42387ade6afb
Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents:
12117
diff
changeset
|
169 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
|
170 self.library_dirs = [] |
|
15770
18a6e6d9b4f8
Check in patch #102971: if library_dirs is a string, split it using
Andrew M. Kuchling <amk@amk.ca>
parents:
14948
diff
changeset
|
171 elif type(self.library_dirs) is StringType: |
|
18a6e6d9b4f8
Check in patch #102971: if library_dirs is a string, split it using
Andrew M. Kuchling <amk@amk.ca>
parents:
14948
diff
changeset
|
172 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
|
173 |
|
12164
42387ade6afb
Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents:
12117
diff
changeset
|
174 if self.rpath is None: |
|
42387ade6afb
Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents:
12117
diff
changeset
|
175 self.rpath = [] |
|
16637
59f4f6960101
Split the rpath argument into multiple paths, turning it into a list.
Andrew M. Kuchling <amk@amk.ca>
parents:
16281
diff
changeset
|
176 elif type(self.rpath) is StringType: |
|
59f4f6960101
Split the rpath argument into multiple paths, turning it into a list.
Andrew M. Kuchling <amk@amk.ca>
parents:
16281
diff
changeset
|
177 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
|
178 |
|
12164
42387ade6afb
Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents:
12117
diff
changeset
|
179 # 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
|
180 # for Release and Debug builds. |
|
42387ade6afb
Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents:
12117
diff
changeset
|
181 # 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
|
182 if os.name == 'nt': |
|
46331
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
45413
diff
changeset
|
183 # 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
|
184 # 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
|
185 # 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
|
186 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
|
187 if self.debug: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
188 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
|
189 else: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
190 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
|
191 |
|
23273
70a089722393
Append the PC specific include 'PC' and library 'PCBuild' directories
Thomas Heller <theller@ctypes.org>
parents:
21851
diff
changeset
|
192 # 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
|
193 # 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
|
194 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
|
195 if MSVC_VERSION == 9: |
|
46331
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
45413
diff
changeset
|
196 # 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
|
197 if self.plat_name == 'win32': |
|
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
45413
diff
changeset
|
198 suffix = '' |
|
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
45413
diff
changeset
|
199 else: |
|
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
45413
diff
changeset
|
200 # win-amd64 or win-ia64 |
|
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
45413
diff
changeset
|
201 suffix = self.plat_name[4:] |
|
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
45413
diff
changeset
|
202 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
|
203 if suffix: |
|
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
45413
diff
changeset
|
204 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
|
205 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
|
206 |
|
44117
ead0d47b012b
Applied my patch #1455 with some extra fixes for VS 2005
Christian Heimes <christian@cheimes.de>
parents:
41521
diff
changeset
|
207 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
|
208 self.library_dirs.append(os.path.join(sys.exec_prefix, |
|
66937
3b5cc6638f3d
Merged revisions 87280 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents:
64618
diff
changeset
|
209 'PC', 'VS8.0')) |
|
48228
0600fce67835
Fixed test_distutils error (test_build_ext) on VC6.
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents:
46788
diff
changeset
|
210 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
|
211 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
|
212 '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
|
213 else: |
|
ead0d47b012b
Applied my patch #1455 with some extra fixes for VS 2005
Christian Heimes <christian@cheimes.de>
parents:
41521
diff
changeset
|
214 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
|
215 'PC', 'VC6')) |
|
23273
70a089722393
Append the PC specific include 'PC' and library 'PCBuild' directories
Thomas Heller <theller@ctypes.org>
parents:
21851
diff
changeset
|
216 |
|
32736
c3a096bfbd6b
Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents:
32063
diff
changeset
|
217 # 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
|
218 # 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
|
219 if os.name == 'os2': |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21760
diff
changeset
|
220 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
|
221 |
|
23777
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
222 # 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
|
223 # 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
|
224 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
|
225 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
|
226 # 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
|
227 self.library_dirs.append(os.path.join(sys.prefix, "lib", |
|
26206
ff92cc27fd1f
[Bug #550364] Use sysconfig.get_python_version()
Andrew M. Kuchling <amk@amk.ca>
parents:
26036
diff
changeset
|
228 "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
|
229 "config")) |
|
16211
98b65484ade6
Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents:
15770
diff
changeset
|
230 else: |
|
98b65484ade6
Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents:
15770
diff
changeset
|
231 # building python standard extensions |
|
98b65484ade6
Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents:
15770
diff
changeset
|
232 self.library_dirs.append('.') |
|
98b65484ade6
Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents:
15770
diff
changeset
|
233 |
|
51353
ef3c6d9b4fec
Merged revisions 69316 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48260
diff
changeset
|
234 # 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
|
235 # Python's library directory must be appended to library_dirs |
|
51353
ef3c6d9b4fec
Merged revisions 69316 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48260
diff
changeset
|
236 sysconfig.get_config_var('Py_ENABLE_SHARED') |
|
ef3c6d9b4fec
Merged revisions 69316 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48260
diff
changeset
|
237 if ((sys.platform.startswith('linux') or sys.platform.startswith('gnu') |
|
ef3c6d9b4fec
Merged revisions 69316 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48260
diff
changeset
|
238 or sys.platform.startswith('sunos')) |
|
ef3c6d9b4fec
Merged revisions 69316 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48260
diff
changeset
|
239 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
|
240 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
|
241 # building third party extensions |
|
4d9156464673
Bug #1600860: Search for shared python library in LIBDIR, not
Martin v. Löwis <martin@v.loewis.de>
parents:
40420
diff
changeset
|
242 self.library_dirs.append(sysconfig.get_config_var('LIBDIR')) |
|
4d9156464673
Bug #1600860: Search for shared python library in LIBDIR, not
Martin v. Löwis <martin@v.loewis.de>
parents:
40420
diff
changeset
|
243 else: |
|
4d9156464673
Bug #1600860: Search for shared python library in LIBDIR, not
Martin v. Löwis <martin@v.loewis.de>
parents:
40420
diff
changeset
|
244 # 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
|
245 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
|
246 |
|
17065
dd04bbfd5a76
Fix bug #233253: the --define and --undef options didn't work, whether
Andrew M. Kuchling <amk@amk.ca>
parents:
17021
diff
changeset
|
247 # 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
|
248 # 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
|
249 # 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
|
250 # symbols can be separated with commas. |
| 21268 | 251 |
|
17065
dd04bbfd5a76
Fix bug #233253: the --define and --undef options didn't work, whether
Andrew M. Kuchling <amk@amk.ca>
parents:
17021
diff
changeset
|
252 if self.define: |
|
53969
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
253 defines = self.define.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
|
254 self.define = map(lambda symbol: (symbol, '1'), defines) |
|
dd04bbfd5a76
Fix bug #233253: the --define and --undef options didn't work, whether
Andrew M. Kuchling <amk@amk.ca>
parents:
17021
diff
changeset
|
255 |
|
dd04bbfd5a76
Fix bug #233253: the --define and --undef options didn't work, whether
Andrew M. Kuchling <amk@amk.ca>
parents:
17021
diff
changeset
|
256 # 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
|
257 # 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
|
258 # 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
|
259 if self.undef: |
|
53969
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
260 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
|
261 |
|
33759
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
262 if self.swig_opts is None: |
|
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
263 self.swig_opts = [] |
|
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
264 else: |
|
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
265 self.swig_opts = self.swig_opts.split(' ') |
|
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
266 |
|
46788
f3f6a895a555
Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents:
46331
diff
changeset
|
267 # 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
|
268 if self.user: |
|
f3f6a895a555
Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents:
46331
diff
changeset
|
269 user_include = os.path.join(USER_BASE, "include") |
|
f3f6a895a555
Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents:
46331
diff
changeset
|
270 user_lib = os.path.join(USER_BASE, "lib") |
|
f3f6a895a555
Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents:
46331
diff
changeset
|
271 if os.path.isdir(user_include): |
|
f3f6a895a555
Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents:
46331
diff
changeset
|
272 self.include_dirs.append(user_include) |
|
f3f6a895a555
Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents:
46331
diff
changeset
|
273 if os.path.isdir(user_lib): |
|
f3f6a895a555
Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents:
46331
diff
changeset
|
274 self.library_dirs.append(user_lib) |
|
f3f6a895a555
Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents:
46331
diff
changeset
|
275 self.rpath.append(user_lib) |
|
f3f6a895a555
Add --user option to build_ext
Christian Heimes <christian@cheimes.de>
parents:
46331
diff
changeset
|
276 |
|
53969
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
277 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
|
278 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
|
279 |
|
12800
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
280 # '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
|
281 # 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
|
282 # distutils.extension) for details. |
| 21268 | 283 # |
|
12800
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
284 # 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
|
285 # 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
|
286 # (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
|
287 # 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
|
288 # 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
|
289 # 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
|
290 # instances as needed. |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
291 |
|
11262
810c25d5041c
Changed to reflect the new "command options" regime -- in particular,
Greg Ward <gward@python.net>
parents:
11246
diff
changeset
|
292 if not self.extensions: |
|
810c25d5041c
Changed to reflect the new "command options" regime -- in particular,
Greg Ward <gward@python.net>
parents:
11246
diff
changeset
|
293 return |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
294 |
|
12057
42d8d76dae6d
Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents:
12029
diff
changeset
|
295 # 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
|
296 # 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
|
297 # linking extensions. |
|
12095
4387606a1281
Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents:
12057
diff
changeset
|
298 if self.distribution.has_c_libraries(): |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
299 build_clib = self.get_finalized_command('build_clib') |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
300 self.libraries.extend(build_clib.get_library_names() or []) |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
301 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
|
302 |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
303 # 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
|
304 # compiling and linking |
|
56403
a4a324c2a00c
#7068: Fixed the partial renaming that occured in r72594
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56391
diff
changeset
|
305 self.compiler = new_compiler(compiler=self.compiler, |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
306 verbose=self.verbose, |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
307 dry_run=self.dry_run, |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
308 force=self.force) |
|
54030
735ed178dfae
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54022
diff
changeset
|
309 customize_compiler(self.compiler) |
|
46331
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
45413
diff
changeset
|
310 # 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
|
311 # 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
|
312 # 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
|
313 if os.name == 'nt' and self.plat_name != get_platform(): |
|
54030
735ed178dfae
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54022
diff
changeset
|
314 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
|
315 |
|
42d8d76dae6d
Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents:
12029
diff
changeset
|
316 # 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
|
317 # 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
|
318 # 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
|
319 # 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
|
320 if self.include_dirs is not None: |
|
54030
735ed178dfae
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54022
diff
changeset
|
321 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
|
322 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
|
323 # 'define' option is a list of (name,value) tuples |
|
53969
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
324 for (name, value) in self.define: |
|
54030
735ed178dfae
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54022
diff
changeset
|
325 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
|
326 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
|
327 for macro in self.undef: |
|
54030
735ed178dfae
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54022
diff
changeset
|
328 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
|
329 if self.libraries is not None: |
|
54030
735ed178dfae
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54022
diff
changeset
|
330 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
|
331 if self.library_dirs is not None: |
|
54030
735ed178dfae
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54022
diff
changeset
|
332 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
|
333 if self.rpath is not None: |
|
54030
735ed178dfae
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54022
diff
changeset
|
334 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
|
335 if self.link_objects is not None: |
|
54030
735ed178dfae
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54022
diff
changeset
|
336 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
|
337 |
|
12057
42d8d76dae6d
Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents:
12029
diff
changeset
|
338 # Now actually compile and link everything. |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
339 self.build_extensions() |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
340 |
|
53969
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
341 def check_extensions_list(self, extensions): |
|
11712
9250e5d3aa31
Tweaked various comments, docstrings, and error messages.
Greg Ward <gward@python.net>
parents:
11702
diff
changeset
|
342 """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
|
343 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
|
344 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
|
345 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
|
346 Extension instances here. |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
347 |
|
12800
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
348 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
|
349 just returns otherwise. |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
350 """ |
|
53969
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
351 if not isinstance(extensions, list): |
|
12407
01cff9fe2d45
Cleaned up/simplified error-handling:
Greg Ward <gward@python.net>
parents:
12402
diff
changeset
|
352 raise DistutilsSetupError, \ |
|
12800
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
353 "'ext_modules' option must be a list of Extension instances" |
| 21268 | 354 |
|
53969
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
355 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
|
356 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
|
357 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
|
358 # by Extension constructor) |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
359 |
|
53969
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
360 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
|
361 raise DistutilsSetupError, \ |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
362 ("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
|
363 "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
|
364 |
|
53969
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
365 ext_name, build_info = ext |
|
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
366 |
|
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
367 log.warn(("old-style (ext_name, build_info) tuple found in " |
|
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
368 "ext_modules for extension '%s'" |
|
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
369 "-- please convert to Extension instance" % ext_name)) |
|
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
370 |
|
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
371 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
|
372 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
|
373 raise DistutilsSetupError, \ |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
374 ("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
|
375 "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
|
376 |
|
53969
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
377 if not isinstance(build_info, dict): |
|
12407
01cff9fe2d45
Cleaned up/simplified error-handling:
Greg Ward <gward@python.net>
parents:
12402
diff
changeset
|
378 raise DistutilsSetupError, \ |
|
12800
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
379 ("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
|
380 "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
|
381 |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
382 # 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
|
383 # 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
|
384 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
|
385 |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
386 # 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
|
387 # instance attributes. |
|
53969
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
388 for key in ('include_dirs', 'library_dirs', 'libraries', |
|
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
389 '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
|
390 'extra_link_args'): |
|
14216
d33179cdc511
In 'check_extensions_list()': when converting old-style 'buildinfo' dict,
Greg Ward <gward@python.net>
parents:
13950
diff
changeset
|
391 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
|
392 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
|
393 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
|
394 |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
395 # 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
|
396 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
|
397 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
|
398 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
|
399 "no longer supported") |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
400 |
|
12800
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
401 # 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
|
402 # and 'undef_macros'. |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
403 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
|
404 if macros: |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
405 ext.define_macros = [] |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
406 ext.undef_macros = [] |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
407 for macro in macros: |
|
53969
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
408 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
|
409 raise DistutilsSetupError, \ |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
410 ("'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
|
411 "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
|
412 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
|
413 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
|
414 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
|
415 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
|
416 |
|
12800
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
417 extensions[i] = ext |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
418 |
|
53969
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
419 def get_source_files(self): |
|
13599
3260220aaee4
Typo fix from Bastian Kleineidam
Andrew M. Kuchling <amk@amk.ca>
parents:
13413
diff
changeset
|
420 self.check_extensions_list(self.extensions) |
| 11340 | 421 filenames = [] |
| 422 | |
| 423 # 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
|
424 for ext in self.extensions: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
425 filenames.extend(ext.sources) |
| 11340 | 426 |
| 427 return filenames | |
| 428 | |
|
53969
35e9803a2f4e
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51353
diff
changeset
|
429 def get_outputs(self): |
|
12095
4387606a1281
Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents:
12057
diff
changeset
|
430 # 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
|
431 # 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
|
432 # can probably assume that it *isn't*!). |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
433 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
|
434 |
|
4387606a1281
Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents:
12057
diff
changeset
|
435 # 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
|
436 # 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
|
437 # "build" tree. |
|
4387606a1281
Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents:
12057
diff
changeset
|
438 outputs = [] |
|
12800
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
439 for ext in self.extensions: |
|
54022
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
440 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
|
441 return outputs |
|
4387606a1281
Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents:
12057
diff
changeset
|
442 |
|
16281
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
443 def build_extensions(self): |
|
12095
4387606a1281
Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents:
12057
diff
changeset
|
444 # First, sanity-check the 'extensions' list |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
445 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
|
446 |
|
12800
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
447 for ext in self.extensions: |
|
16281
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
448 self.build_extension(ext) |
|
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
449 |
|
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
450 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
|
451 sources = ext.sources |
|
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
452 if sources is None or type(sources) not in (ListType, TupleType): |
|
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
453 raise DistutilsSetupError, \ |
|
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
454 ("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
|
455 "'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
|
456 "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
|
457 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
|
458 |
|
54022
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
459 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
|
460 depends = sources + ext.depends |
|
54022
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
461 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
|
462 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
|
463 return |
|
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
464 else: |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23273
diff
changeset
|
465 log.info("building '%s' extension", ext.name) |
| 11702 | 466 |
|
16281
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
467 # 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
|
468 # 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
|
469 # accordingly. |
|
33759
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
470 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
|
471 |
|
16281
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
472 # 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
|
473 |
|
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
474 # 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
|
475 # 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
|
476 # 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
|
477 |
|
16281
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
478 # 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
|
479 # - '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
|
480 # - 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
|
481 # 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
|
482 # 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
|
483 # 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
|
484 # 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
|
485 # 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
|
486 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
|
487 |
|
16281
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
488 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
|
489 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
|
490 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
|
491 |
|
54030
735ed178dfae
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54022
diff
changeset
|
492 objects = self.compiler.compile(sources, |
|
54022
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
493 output_dir=self.build_temp, |
|
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
494 macros=macros, |
|
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
495 include_dirs=ext.include_dirs, |
|
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
496 debug=self.debug, |
|
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
497 extra_postargs=extra_args, |
|
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
498 depends=ext.depends) |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
499 |
|
21277
f702ff390e4d
Visious hackery to solve a build-control problem related to our use of
Fred Drake <fdrake@acm.org>
parents:
21268
diff
changeset
|
500 # 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
|
501 # |
|
f702ff390e4d
Visious hackery to solve a build-control problem related to our use of
Fred Drake <fdrake@acm.org>
parents:
21268
diff
changeset
|
502 # 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
|
503 # 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
|
504 # 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
|
505 # 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
|
506 # 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
|
507 # 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
|
508 # |
|
f702ff390e4d
Visious hackery to solve a build-control problem related to our use of
Fred Drake <fdrake@acm.org>
parents:
21268
diff
changeset
|
509 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
|
510 |
|
16281
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
511 # 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
|
512 # 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
|
513 # 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
|
514 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
|
515 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
|
516 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
|
517 |
|
26036
771b6f521b95
This patch fixes the following bugs:
Gustavo Niemeyer <gustavo@niemeyer.net>
parents:
26018
diff
changeset
|
518 # Detect target language, if not provided |
|
54030
735ed178dfae
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54022
diff
changeset
|
519 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
|
520 |
|
54030
735ed178dfae
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54022
diff
changeset
|
521 self.compiler.link_shared_object( |
|
54022
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
522 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
|
523 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
|
524 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
|
525 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
|
526 extra_postargs=extra_args, |
| 21268 | 527 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
|
528 debug=self.debug, |
|
26036
771b6f521b95
This patch fixes the following bugs:
Gustavo Niemeyer <gustavo@niemeyer.net>
parents:
26018
diff
changeset
|
529 build_temp=self.build_temp, |
|
771b6f521b95
This patch fixes the following bugs:
Gustavo Niemeyer <gustavo@niemeyer.net>
parents:
26018
diff
changeset
|
530 target_lang=language) |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
531 |
|
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
532 |
|
33759
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
533 def swig_sources (self, sources, extension): |
|
12996
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
534 |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
535 """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
|
536 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
|
537 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
|
538 by the generated C (or C++) files. |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
539 """ |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
540 |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
541 new_sources = [] |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
542 swig_sources = [] |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
543 swig_targets = {} |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
544 |
|
13032
1240bc997c8f
Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support.
Greg Ward <gward@python.net>
parents:
13014
diff
changeset
|
545 # 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
|
546 # 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
|
547 # 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
|
548 # the temp dir. |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
549 |
|
13032
1240bc997c8f
Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support.
Greg Ward <gward@python.net>
parents:
13014
diff
changeset
|
550 if self.swig_cpp: |
|
33759
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
551 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
|
552 |
|
41521
7ea5949714ad
Bug #1706381: Specifying the SWIG option "-c++" in the setup.py file
Georg Brandl <georg@python.org>
parents:
41149
diff
changeset
|
553 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
|
554 ('-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
|
555 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
|
556 else: |
|
1240bc997c8f
Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support.
Greg Ward <gward@python.net>
parents:
13014
diff
changeset
|
557 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
|
558 |
|
12996
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
559 for source in sources: |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
560 (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
|
561 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
|
562 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
|
563 swig_sources.append(source) |
|
12996
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
564 swig_targets[source] = new_sources[-1] |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
565 else: |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
566 new_sources.append(source) |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
567 |
|
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
|
568 if not swig_sources: |
|
12996
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
569 return new_sources |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
570 |
|
33759
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
571 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
|
572 swig_cmd = [swig, "-python"] |
|
33759
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
573 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
|
574 if self.swig_cpp: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
575 swig_cmd.append("-c++") |
|
12996
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
576 |
|
33759
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
577 # Do not override commandline arguments |
|
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
578 if not self.swig_opts: |
|
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
579 for o in extension.swig_opts: |
|
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
580 swig_cmd.append(o) |
|
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
581 |
|
12996
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
582 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
|
583 target = swig_targets[source] |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23273
diff
changeset
|
584 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
|
585 self.spawn(swig_cmd + ["-o", target, source]) |
|
12996
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
586 |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
587 return new_sources |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
588 |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
589 # swig_sources () |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
590 |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
591 def find_swig (self): |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
592 """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
|
593 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
|
594 Windows. |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
595 """ |
|
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 if os.name == "posix": |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
598 return "swig" |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
599 elif os.name == "nt": |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
600 |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
601 # Look for SWIG in its standard installation directory on |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
602 # 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
|
603 # 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
|
604 for vers in ("1.3", "1.2", "1.1"): |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
605 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
|
606 if os.path.isfile(fn): |
|
12996
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
607 return fn |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
608 else: |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
609 return "swig.exe" |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
610 |
|
21851
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21760
diff
changeset
|
611 elif os.name == "os2": |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21760
diff
changeset
|
612 # 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
|
613 return "swig.exe" |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21760
diff
changeset
|
614 |
|
12996
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
615 else: |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
616 raise DistutilsPlatformError, \ |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
617 ("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
|
618 "on platform '%s'") % os.name |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
619 |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
620 # find_swig () |
| 21268 | 621 |
|
12942
a8530d36021c
Pulled the MSVC++-specific hackery out to a new method, 'prelink_hook()',
Greg Ward <gward@python.net>
parents:
12869
diff
changeset
|
622 # -- Name generators ----------------------------------------------- |
|
a8530d36021c
Pulled the MSVC++-specific hackery out to a new method, 'prelink_hook()',
Greg Ward <gward@python.net>
parents:
12869
diff
changeset
|
623 # (extension names, filenames, whatever) |
|
54022
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
624 def get_ext_fullpath(self, ext_name): |
|
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
625 """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
|
626 |
|
54022
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
627 The file is located in `build_lib` or directly in the package |
|
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
628 (inplace option). |
|
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
629 """ |
|
56506
2a7583718d25
complementary fix for #7115
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56501
diff
changeset
|
630 # makes sure the extension name is only using dots |
|
2a7583718d25
complementary fix for #7115
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56501
diff
changeset
|
631 all_dots = string.maketrans('/'+os.sep, '..') |
|
2a7583718d25
complementary fix for #7115
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56501
diff
changeset
|
632 ext_name = ext_name.translate(all_dots) |
|
2a7583718d25
complementary fix for #7115
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56501
diff
changeset
|
633 |
|
54204
2901b13fbd7e
Merged revisions 72781 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54182
diff
changeset
|
634 fullname = self.get_ext_fullname(ext_name) |
|
55067
eeeb35f28812
Merged revisions 73790 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54204
diff
changeset
|
635 modpath = fullname.split('.') |
|
56391
29c0196b1bdd
Fixed #7064: making sure get_ext_filename is called as Setuptools is assuming so it doesn't break it
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55899
diff
changeset
|
636 filename = self.get_ext_filename(ext_name) |
|
29c0196b1bdd
Fixed #7064: making sure get_ext_filename is called as Setuptools is assuming so it doesn't break it
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55899
diff
changeset
|
637 filename = os.path.split(filename)[-1] |
|
55067
eeeb35f28812
Merged revisions 73790 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54204
diff
changeset
|
638 |
|
54204
2901b13fbd7e
Merged revisions 72781 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54182
diff
changeset
|
639 if not self.inplace: |
|
2901b13fbd7e
Merged revisions 72781 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54182
diff
changeset
|
640 # no further work needed |
|
55067
eeeb35f28812
Merged revisions 73790 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54204
diff
changeset
|
641 # returning : |
|
eeeb35f28812
Merged revisions 73790 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54204
diff
changeset
|
642 # build_dir/package/path/filename |
|
eeeb35f28812
Merged revisions 73790 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54204
diff
changeset
|
643 filename = os.path.join(*modpath[:-1]+[filename]) |
|
54022
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
644 return os.path.join(self.build_lib, filename) |
|
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
645 |
|
54204
2901b13fbd7e
Merged revisions 72781 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54182
diff
changeset
|
646 # the inplace option requires to find the package directory |
|
55067
eeeb35f28812
Merged revisions 73790 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54204
diff
changeset
|
647 # using the build_py command for that |
|
eeeb35f28812
Merged revisions 73790 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54204
diff
changeset
|
648 package = '.'.join(modpath[0:-1]) |
|
54204
2901b13fbd7e
Merged revisions 72781 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54182
diff
changeset
|
649 build_py = self.get_finalized_command('build_py') |
|
2901b13fbd7e
Merged revisions 72781 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54182
diff
changeset
|
650 package_dir = os.path.abspath(build_py.get_package_dir(package)) |
|
55067
eeeb35f28812
Merged revisions 73790 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54204
diff
changeset
|
651 |
|
eeeb35f28812
Merged revisions 73790 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54204
diff
changeset
|
652 # returning |
|
eeeb35f28812
Merged revisions 73790 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54204
diff
changeset
|
653 # package_dir/filename |
|
54204
2901b13fbd7e
Merged revisions 72781 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54182
diff
changeset
|
654 return os.path.join(package_dir, filename) |
|
2901b13fbd7e
Merged revisions 72781 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54182
diff
changeset
|
655 |
|
54022
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
656 def get_ext_fullname(self, ext_name): |
|
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
657 """Returns the fullname of a given extension name. |
|
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
658 |
|
15a8f4f2bc84
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53969
diff
changeset
|
659 Adds the `package.` prefix""" |
| 11886 | 660 if self.package is None: |
| 661 return ext_name | |
| 662 else: | |
| 663 return self.package + '.' + ext_name | |
| 664 | |
|
54182
d473fba4ec67
Merged revisions 72758 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54030
diff
changeset
|
665 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
|
666 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
|
667 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
|
668 "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
|
669 """ |
|
14574
b4a37ab329da
Adjust to the new sysconfig regime: use 'get_config_var()' instead
Greg Ward <gward@python.net>
parents:
14434
diff
changeset
|
670 from distutils.sysconfig import get_config_var |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
671 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
|
672 # 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
|
673 if os.name == "os2": |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21760
diff
changeset
|
674 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
|
675 # extensions in debug_mode are named 'module_d.pyd' under windows |
|
14574
b4a37ab329da
Adjust to the new sysconfig regime: use 'get_config_var()' instead
Greg Ward <gward@python.net>
parents:
14434
diff
changeset
|
676 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
|
677 if os.name == 'nt' and self.debug: |
|
63579
ac29f70c61db
Merged revisions 79558 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
56506
diff
changeset
|
678 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
|
679 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
|
680 |
|
13797
e00d3ce71f89
Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
681 def get_export_symbols (self, ext): |
|
e00d3ce71f89
Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
682 """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
|
683 export. This either uses 'ext.export_symbols' or, if it's not |
|
55217
93b48ab90ead
Merged revisions 73954 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55209
diff
changeset
|
684 provided, "init" + module_name. Only relevant on Windows, where |
|
93b48ab90ead
Merged revisions 73954 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55209
diff
changeset
|
685 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
|
686 """ |
|
55217
93b48ab90ead
Merged revisions 73954 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55209
diff
changeset
|
687 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
|
688 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
|
689 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
|
690 return ext.export_symbols |
|
13797
e00d3ce71f89
Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
691 |
|
e00d3ce71f89
Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
692 def get_libraries (self, ext): |
|
e00d3ce71f89
Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
693 """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
|
694 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
|
695 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
|
696 """ |
|
e00d3ce71f89
Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
697 # 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
|
698 # 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
|
699 # 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
|
700 # 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
|
701 # 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
|
702 if sys.platform == "win32": |
|
921064c26297
Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23824
diff
changeset
|
703 from distutils.msvccompiler import MSVCCompiler |
|
54030
735ed178dfae
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54022
diff
changeset
|
704 if not isinstance(self.compiler, MSVCCompiler): |
|
23910
921064c26297
Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23824
diff
changeset
|
705 template = "python%d%d" |
|
921064c26297
Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23824
diff
changeset
|
706 if self.debug: |
|
921064c26297
Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23824
diff
changeset
|
707 template = template + '_d' |
|
921064c26297
Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23824
diff
changeset
|
708 pythonlib = (template % |
|
921064c26297
Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23824
diff
changeset
|
709 (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) |
|
921064c26297
Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23824
diff
changeset
|
710 # 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
|
711 # 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
|
712 return ext.libraries + [pythonlib] |
|
25976
2d837e2083fa
Fixes SF bug#614051: win32 build_ext problem.
Thomas Heller <theller@ctypes.org>
parents:
23910
diff
changeset
|
713 else: |
|
2d837e2083fa
Fixes SF bug#614051: win32 build_ext problem.
Thomas Heller <theller@ctypes.org>
parents:
23910
diff
changeset
|
714 return ext.libraries |
|
21851
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21760
diff
changeset
|
715 elif sys.platform == "os2emx": |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21760
diff
changeset
|
716 # 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
|
717 # 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
|
718 template = "python%d%d" |
|
32736
c3a096bfbd6b
Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents:
32063
diff
changeset
|
719 # 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
|
720 # 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
|
721 #if self.debug: |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21760
diff
changeset
|
722 # template = template + '_d' |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21760
diff
changeset
|
723 pythonlib = (template % |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21760
diff
changeset
|
724 (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
|
725 # 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
|
726 # 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
|
727 return ext.libraries + [pythonlib] |
|
16211
98b65484ade6
Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents:
15770
diff
changeset
|
728 elif sys.platform[:6] == "cygwin": |
|
98b65484ade6
Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents:
15770
diff
changeset
|
729 template = "python%d.%d" |
|
98b65484ade6
Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents:
15770
diff
changeset
|
730 pythonlib = (template % |
|
98b65484ade6
Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents:
15770
diff
changeset
|
731 (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
|
732 # 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
|
733 # 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
|
734 return ext.libraries + [pythonlib] |
|
23777
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
735 elif sys.platform[:6] == "atheos": |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
736 from distutils import sysconfig |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
737 |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
738 template = "python%d.%d" |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
739 pythonlib = (template % |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
740 (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
741 # Get SHLIBS from Makefile |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
742 extra = [] |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
743 for lib in sysconfig.get_config_var('SHLIBS').split(): |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
744 if lib.startswith('-l'): |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
745 extra.append(lib[2:]) |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
746 else: |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
747 extra.append(lib) |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
748 # 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
|
749 # 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
|
750 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
|
751 |
|
5b587190f4c6
Disable linking extensions with -lpython2.5 for darwin. This should fix bug
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
37561
diff
changeset
|
752 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
|
753 # 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
|
754 return ext.libraries |
|
64618
e27030e0cced
Merged revisions 84680 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60132
diff
changeset
|
755 elif sys.platform[:3] == 'aix': |
|
e27030e0cced
Merged revisions 84680 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60132
diff
changeset
|
756 # Don't use the default code below |
|
e27030e0cced
Merged revisions 84680 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60132
diff
changeset
|
757 return ext.libraries |
|
13797
e00d3ce71f89
Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
758 else: |
|
37561
bd375777932d
Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents:
33965
diff
changeset
|
759 from distutils import sysconfig |
|
bd375777932d
Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents:
33965
diff
changeset
|
760 if sysconfig.get_config_var('Py_ENABLE_SHARED'): |
|
bd375777932d
Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents:
33965
diff
changeset
|
761 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
|
762 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
|
763 (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
|
764 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
|
765 else: |
|
bd375777932d
Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents:
33965
diff
changeset
|
766 return ext.libraries |
|
13797
e00d3ce71f89
Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
767 |
|
12743
e878a647e06e
Normalized all the end-of-class lines.
Greg Ward <gward@python.net>
parents:
12692
diff
changeset
|
768 # class build_ext |
