Mercurial > cpython-lru_cache-weakref
annotate Lib/distutils/command/build_ext.py @ 78069:a8aa77458e12 3.2
Add c_size_t and c_ssize_t to the ctypes summary table.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Thu, 12 Jul 2012 20:31:50 +0200 |
| parents | 53df93a9c002 |
| children | 8f91014c8f00 f7163afecb97 |
| 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 |
|
41480
99027c2b3fd2
Remove functions in string module that are also string methods. Also remove:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40893
diff
changeset
|
7 import sys, os, re |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
8 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
|
9 from distutils.errors import * |
|
26206
ff92cc27fd1f
[Bug #550364] Use sysconfig.get_python_version()
Andrew M. Kuchling <amk@amk.ca>
parents:
26036
diff
changeset
|
10 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
|
11 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
|
12 from distutils.extension import Extension |
|
46370
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
13 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
|
14 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
|
15 |
|
51892
4fd80e66b107
Merged revisions 70017 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51881
diff
changeset
|
16 # this keeps compatibility from 2.3 to 2.5 |
|
4fd80e66b107
Merged revisions 70017 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51881
diff
changeset
|
17 if sys.version < "2.6": |
|
4fd80e66b107
Merged revisions 70017 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51881
diff
changeset
|
18 USER_BASE = None |
|
4fd80e66b107
Merged revisions 70017 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51881
diff
changeset
|
19 HAS_USER_SITE = False |
|
4fd80e66b107
Merged revisions 70017 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51881
diff
changeset
|
20 else: |
|
4fd80e66b107
Merged revisions 70017 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51881
diff
changeset
|
21 from site import USER_BASE |
|
4fd80e66b107
Merged revisions 70017 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51881
diff
changeset
|
22 HAS_USER_SITE = True |
|
4fd80e66b107
Merged revisions 70017 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51881
diff
changeset
|
23 |
|
44129
b637349336fd
Merged revisions 59275-59303 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43577
diff
changeset
|
24 if os.name == 'nt': |
|
b637349336fd
Merged revisions 59275-59303 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43577
diff
changeset
|
25 from distutils.msvccompiler import get_build_version |
|
b637349336fd
Merged revisions 59275-59303 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43577
diff
changeset
|
26 MSVC_VERSION = int(get_build_version()) |
|
b637349336fd
Merged revisions 59275-59303 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43577
diff
changeset
|
27 |
| 11300 | 28 # An extension name is just a dot-separated list of Python NAMEs (ie. |
| 29 # the same as a fully-qualified module name). | |
| 30 extension_name_re = re.compile \ | |
| 31 (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
|
32 |
|
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
33 |
|
12999
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12996
diff
changeset
|
34 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
|
35 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
|
36 show_compilers() |
|
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12996
diff
changeset
|
37 |
|
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12996
diff
changeset
|
38 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
39 class build_ext(Command): |
| 21268 | 40 |
|
11683
47f75a17b103
Added 'description' class attribute to every command class (to help the
Greg Ward <gward@python.net>
parents:
11544
diff
changeset
|
41 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
|
42 |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
43 # 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
|
44 # 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
|
45 # 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
|
46 # 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
|
47 # - 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
|
48 # - 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
|
49 # 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
|
50 # Distribution.parse_command_line()) |
|
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
51 # - 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
|
52 # 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
|
53 # 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
|
54 # structure |
|
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
55 # - 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
|
56 # 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
|
57 # 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
|
58 # 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
|
59 # 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
|
60 |
|
14612
1e6c044d8e59
Document the directory separatory for include dir and library dir lists.
Greg Ward <gward@python.net>
parents:
14574
diff
changeset
|
61 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
|
62 user_options = [ |
| 11886 | 63 ('build-lib=', 'b', |
|
11815
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
64 "directory for compiled extension modules"), |
| 11886 | 65 ('build-temp=', 't', |
| 66 "directory for temporary files (build by-products)"), | |
|
46370
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
67 ('plat-name=', 'p', |
|
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
68 "platform name to cross-compile for, if supported " |
|
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
69 "(default: %s)" % get_platform()), |
| 11886 | 70 ('inplace', 'i', |
| 14434 | 71 "ignore build-lib and put compiled extensions into the source " + |
| 11886 | 72 "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
|
73 ('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
|
74 "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
|
75 ('define=', 'D', |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
76 "C preprocessor macros to define"), |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
77 ('undef=', 'U', |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
78 "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
|
79 ('libraries=', 'l', |
|
11815
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
80 "external C libraries to link with"), |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
81 ('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
|
82 "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
|
83 ('rpath=', 'R', |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
84 "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
|
85 ('link-objects=', 'O', |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
86 "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
|
87 ('debug', 'g', |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
88 "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
|
89 ('force', 'f', |
|
12671
a02e6a43ca15
Fix from Lyle Johnson: add the '--compiler' option.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12624
diff
changeset
|
90 "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
|
91 ('compiler=', 'c', |
|
a02e6a43ca15
Fix from Lyle Johnson: add the '--compiler' option.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12624
diff
changeset
|
92 "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
|
93 ('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
|
94 "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
|
95 ('swig-opts=', None, |
|
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
96 "list of SWIG command line options"), |
|
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
97 ('swig=', None, |
|
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
98 "path to the SWIG executable"), |
|
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 |
|
51892
4fd80e66b107
Merged revisions 70017 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51881
diff
changeset
|
101 boolean_options = ['inplace', 'debug', 'force', 'swig-cpp'] |
|
4fd80e66b107
Merged revisions 70017 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51881
diff
changeset
|
102 |
|
4fd80e66b107
Merged revisions 70017 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51881
diff
changeset
|
103 if HAS_USER_SITE: |
|
4fd80e66b107
Merged revisions 70017 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51881
diff
changeset
|
104 user_options.append(('user', None, |
|
4fd80e66b107
Merged revisions 70017 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51881
diff
changeset
|
105 "add user include, library and rpath")) |
|
4fd80e66b107
Merged revisions 70017 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51881
diff
changeset
|
106 boolean_options.append('user') |
|
14829
b1f220f636ed
Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents:
14652
diff
changeset
|
107 |
|
12869
88872791998a
Patch from Rene Liebscher: this adds "--help-foo" options to list the
Greg Ward <gward@python.net>
parents:
12800
diff
changeset
|
108 help_options = [ |
|
88872791998a
Patch from Rene Liebscher: this adds "--help-foo" options to list the
Greg Ward <gward@python.net>
parents:
12800
diff
changeset
|
109 ('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
|
110 "list available compilers", show_compilers), |
|
13797
e00d3ce71f89
Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
111 ] |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
112 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
113 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
|
114 self.extensions = None |
| 11886 | 115 self.build_lib = None |
|
46370
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
116 self.plat_name = None |
| 11886 | 117 self.build_temp = None |
| 118 self.inplace = 0 | |
|
11281
cae4b09273b3
Added support for 'package' option, including where to link the
Greg Ward <gward@python.net>
parents:
11262
diff
changeset
|
119 self.package = None |
|
cae4b09273b3
Added support for 'package' option, including where to link the
Greg Ward <gward@python.net>
parents:
11262
diff
changeset
|
120 |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
121 self.include_dirs = None |
|
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
122 self.define = None |
|
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
123 self.undef = None |
|
12057
42d8d76dae6d
Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents:
12029
diff
changeset
|
124 self.libraries = None |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
125 self.library_dirs = None |
|
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
126 self.rpath = None |
|
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
127 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
|
128 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
|
129 self.force = None |
|
12671
a02e6a43ca15
Fix from Lyle Johnson: add the '--compiler' option.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12624
diff
changeset
|
130 self.compiler = None |
|
33759
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
131 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
|
132 self.swig_cpp = None |
|
33759
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
133 self.swig_opts = None |
|
47063
081c15806e28
Merged revisions 62914-62916,62918-62919,62921-62922,62924-62942,62944-62945,62947-62949 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
46370
diff
changeset
|
134 self.user = None |
| 11340 | 135 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
136 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
|
137 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
|
138 |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
139 self.set_undefined_options('build', |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
140 ('build_lib', 'build_lib'), |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
141 ('build_temp', 'build_temp'), |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
142 ('compiler', 'compiler'), |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
143 ('debug', 'debug'), |
|
46370
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
144 ('force', 'force'), |
|
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
145 ('plat_name', 'plat_name'), |
|
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
146 ) |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
147 |
|
11281
cae4b09273b3
Added support for 'package' option, including where to link the
Greg Ward <gward@python.net>
parents:
11262
diff
changeset
|
148 if self.package is None: |
| 11300 | 149 self.package = self.distribution.ext_package |
| 150 | |
| 151 self.extensions = self.distribution.ext_modules | |
| 21268 | 152 |
|
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
|
153 # 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
|
154 # 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
|
155 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
|
156 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
|
157 if self.include_dirs is None: |
| 11300 | 158 self.include_dirs = self.distribution.include_dirs or [] |
|
43577
ace45b361e87
Patch# 1258 by Christian Heimes: kill basestring.
Guido van Rossum <guido@python.org>
parents:
43026
diff
changeset
|
159 if isinstance(self.include_dirs, str): |
|
41480
99027c2b3fd2
Remove functions in string module that are also string methods. Also remove:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40893
diff
changeset
|
160 self.include_dirs = self.include_dirs.split(os.pathsep) |
| 11340 | 161 |
|
12108
6fd43867aa4f
Put the Python "system" include dir last, rather than first.
Greg Ward <gward@python.net>
parents:
12095
diff
changeset
|
162 # 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
|
163 # any local include dirs take precedence. |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
164 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
|
165 if plat_py_include != py_include: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
166 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
|
167 |
|
74947
53df93a9c002
Fix parsing of build_ext --libraries option (#1326113)
Éric Araujo <merwok@netwok.org>
parents:
71540
diff
changeset
|
168 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
|
169 |
|
12164
42387ade6afb
Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents:
12117
diff
changeset
|
170 # 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
|
171 # 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
|
172 if self.libraries is None: |
|
42387ade6afb
Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents:
12117
diff
changeset
|
173 self.libraries = [] |
|
42387ade6afb
Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents:
12117
diff
changeset
|
174 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
|
175 self.library_dirs = [] |
|
43577
ace45b361e87
Patch# 1258 by Christian Heimes: kill basestring.
Guido van Rossum <guido@python.org>
parents:
43026
diff
changeset
|
176 elif isinstance(self.library_dirs, str): |
|
41480
99027c2b3fd2
Remove functions in string module that are also string methods. Also remove:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40893
diff
changeset
|
177 self.library_dirs = self.library_dirs.split(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
|
178 |
|
12164
42387ade6afb
Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents:
12117
diff
changeset
|
179 if self.rpath is None: |
|
42387ade6afb
Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents:
12117
diff
changeset
|
180 self.rpath = [] |
|
43577
ace45b361e87
Patch# 1258 by Christian Heimes: kill basestring.
Guido van Rossum <guido@python.org>
parents:
43026
diff
changeset
|
181 elif isinstance(self.rpath, str): |
|
41480
99027c2b3fd2
Remove functions in string module that are also string methods. Also remove:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40893
diff
changeset
|
182 self.rpath = self.rpath.split(os.pathsep) |
|
11712
9250e5d3aa31
Tweaked various comments, docstrings, and error messages.
Greg Ward <gward@python.net>
parents:
11702
diff
changeset
|
183 |
|
12164
42387ade6afb
Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents:
12117
diff
changeset
|
184 # 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
|
185 # for Release and Debug builds. |
|
42387ade6afb
Patch (mostly) from Thomas Heller for building on Windows:
Greg Ward <gward@python.net>
parents:
12117
diff
changeset
|
186 # 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
|
187 if os.name == 'nt': |
|
46370
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
188 # the 'libs' directory is for binary installs - we assume that |
|
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
189 # must be the *native* platform. But we don't really support |
|
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
190 # 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
|
191 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
|
192 if self.debug: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
193 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
|
194 else: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
195 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
|
196 |
|
23273
70a089722393
Append the PC specific include 'PC' and library 'PCBuild' directories
Thomas Heller <theller@ctypes.org>
parents:
21851
diff
changeset
|
197 # 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
|
198 # 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
|
199 self.include_dirs.append(os.path.join(sys.exec_prefix, 'PC')) |
|
44129
b637349336fd
Merged revisions 59275-59303 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43577
diff
changeset
|
200 if MSVC_VERSION == 9: |
|
46370
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
201 # Use the .lib files for the correct architecture |
|
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
202 if self.plat_name == 'win32': |
|
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
203 suffix = '' |
|
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
204 else: |
|
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
205 # win-amd64 or win-ia64 |
|
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
206 suffix = self.plat_name[4:] |
|
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
207 new_lib = os.path.join(sys.exec_prefix, 'PCbuild') |
|
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
208 if suffix: |
|
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
209 new_lib = os.path.join(new_lib, suffix) |
|
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
210 self.library_dirs.append(new_lib) |
|
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
211 |
|
44129
b637349336fd
Merged revisions 59275-59303 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43577
diff
changeset
|
212 elif MSVC_VERSION == 8: |
|
b637349336fd
Merged revisions 59275-59303 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43577
diff
changeset
|
213 self.library_dirs.append(os.path.join(sys.exec_prefix, |
|
66936
ff07a06f6d65
Merged revisions 87280 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents:
64617
diff
changeset
|
214 'PC', 'VS8.0')) |
|
48687
f6026a3798d4
Merged revisions 65667 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents:
48575
diff
changeset
|
215 elif MSVC_VERSION == 7: |
|
f6026a3798d4
Merged revisions 65667 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents:
48575
diff
changeset
|
216 self.library_dirs.append(os.path.join(sys.exec_prefix, |
|
f6026a3798d4
Merged revisions 65667 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents:
48575
diff
changeset
|
217 'PC', 'VS7.1')) |
|
44129
b637349336fd
Merged revisions 59275-59303 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43577
diff
changeset
|
218 else: |
|
b637349336fd
Merged revisions 59275-59303 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43577
diff
changeset
|
219 self.library_dirs.append(os.path.join(sys.exec_prefix, |
|
48687
f6026a3798d4
Merged revisions 65667 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents:
48575
diff
changeset
|
220 'PC', 'VC6')) |
|
23273
70a089722393
Append the PC specific include 'PC' and library 'PCBuild' directories
Thomas Heller <theller@ctypes.org>
parents:
21851
diff
changeset
|
221 |
|
32736
c3a096bfbd6b
Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents:
32063
diff
changeset
|
222 # 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
|
223 # 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
|
224 if os.name == 'os2': |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21760
diff
changeset
|
225 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
|
226 |
|
23777
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
227 # 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
|
228 # appended to library_dirs |
|
40893
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40450
diff
changeset
|
229 if sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos': |
|
41554
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41480
diff
changeset
|
230 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
|
231 # 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
|
232 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
|
233 "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
|
234 "config")) |
|
16211
98b65484ade6
Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents:
15770
diff
changeset
|
235 else: |
|
98b65484ade6
Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents:
15770
diff
changeset
|
236 # building python standard extensions |
|
98b65484ade6
Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents:
15770
diff
changeset
|
237 self.library_dirs.append('.') |
|
98b65484ade6
Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents:
15770
diff
changeset
|
238 |
|
51355
fde03e75bc10
Merged revisions 69318 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48687
diff
changeset
|
239 # for extensions under Linux or Solaris with a shared Python library, |
|
40893
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40450
diff
changeset
|
240 # Python's library directory must be appended to library_dirs |
|
51355
fde03e75bc10
Merged revisions 69318 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48687
diff
changeset
|
241 sysconfig.get_config_var('Py_ENABLE_SHARED') |
|
fde03e75bc10
Merged revisions 69318 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48687
diff
changeset
|
242 if ((sys.platform.startswith('linux') or sys.platform.startswith('gnu') |
|
fde03e75bc10
Merged revisions 69318 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48687
diff
changeset
|
243 or sys.platform.startswith('sunos')) |
|
fde03e75bc10
Merged revisions 69318 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48687
diff
changeset
|
244 and sysconfig.get_config_var('Py_ENABLE_SHARED')): |
|
41554
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41480
diff
changeset
|
245 if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")): |
|
40893
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40450
diff
changeset
|
246 # building third party extensions |
|
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40450
diff
changeset
|
247 self.library_dirs.append(sysconfig.get_config_var('LIBDIR')) |
|
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40450
diff
changeset
|
248 else: |
|
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40450
diff
changeset
|
249 # building python standard extensions |
|
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40450
diff
changeset
|
250 self.library_dirs.append('.') |
|
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40450
diff
changeset
|
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 # 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
|
253 # 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
|
254 # 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
|
255 # symbols can be separated with commas. |
| 21268 | 256 |
|
17065
dd04bbfd5a76
Fix bug #233253: the --define and --undef options didn't work, whether
Andrew M. Kuchling <amk@amk.ca>
parents:
17021
diff
changeset
|
257 if self.define: |
|
41480
99027c2b3fd2
Remove functions in string module that are also string methods. Also remove:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40893
diff
changeset
|
258 defines = self.define.split(',') |
|
48575
2fb55ff06275
Remove incorrect usages of map() in distutils.
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47600
diff
changeset
|
259 self.define = [(symbol, '1') for symbol in defines] |
|
17065
dd04bbfd5a76
Fix bug #233253: the --define and --undef options didn't work, whether
Andrew M. Kuchling <amk@amk.ca>
parents:
17021
diff
changeset
|
260 |
|
dd04bbfd5a76
Fix bug #233253: the --define and --undef options didn't work, whether
Andrew M. Kuchling <amk@amk.ca>
parents:
17021
diff
changeset
|
261 # 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
|
262 # 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
|
263 # 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
|
264 if self.undef: |
|
41480
99027c2b3fd2
Remove functions in string module that are also string methods. Also remove:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40893
diff
changeset
|
265 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
|
266 |
|
33759
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
267 if self.swig_opts is None: |
|
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
268 self.swig_opts = [] |
|
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
269 else: |
|
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
270 self.swig_opts = self.swig_opts.split(' ') |
|
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
271 |
|
47063
081c15806e28
Merged revisions 62914-62916,62918-62919,62921-62922,62924-62942,62944-62945,62947-62949 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
46370
diff
changeset
|
272 # Finally add the user include and library directories if requested |
|
081c15806e28
Merged revisions 62914-62916,62918-62919,62921-62922,62924-62942,62944-62945,62947-62949 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
46370
diff
changeset
|
273 if self.user: |
|
081c15806e28
Merged revisions 62914-62916,62918-62919,62921-62922,62924-62942,62944-62945,62947-62949 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
46370
diff
changeset
|
274 user_include = os.path.join(USER_BASE, "include") |
|
081c15806e28
Merged revisions 62914-62916,62918-62919,62921-62922,62924-62942,62944-62945,62947-62949 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
46370
diff
changeset
|
275 user_lib = os.path.join(USER_BASE, "lib") |
|
081c15806e28
Merged revisions 62914-62916,62918-62919,62921-62922,62924-62942,62944-62945,62947-62949 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
46370
diff
changeset
|
276 if os.path.isdir(user_include): |
|
081c15806e28
Merged revisions 62914-62916,62918-62919,62921-62922,62924-62942,62944-62945,62947-62949 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
46370
diff
changeset
|
277 self.include_dirs.append(user_include) |
|
081c15806e28
Merged revisions 62914-62916,62918-62919,62921-62922,62924-62942,62944-62945,62947-62949 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
46370
diff
changeset
|
278 if os.path.isdir(user_lib): |
|
081c15806e28
Merged revisions 62914-62916,62918-62919,62921-62922,62924-62942,62944-62945,62947-62949 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
46370
diff
changeset
|
279 self.library_dirs.append(user_lib) |
|
081c15806e28
Merged revisions 62914-62916,62918-62919,62921-62922,62924-62942,62944-62945,62947-62949 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
46370
diff
changeset
|
280 self.rpath.append(user_lib) |
|
081c15806e28
Merged revisions 62914-62916,62918-62919,62921-62922,62924-62942,62944-62945,62947-62949 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
46370
diff
changeset
|
281 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
282 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
|
283 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
|
284 |
|
12800
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
285 # '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
|
286 # 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
|
287 # distutils.extension) for details. |
| 21268 | 288 # |
|
12800
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
289 # 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
|
290 # 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
|
291 # (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
|
292 # 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
|
293 # 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
|
294 # 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
|
295 # instances as needed. |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
296 |
|
11262
810c25d5041c
Changed to reflect the new "command options" regime -- in particular,
Greg Ward <gward@python.net>
parents:
11246
diff
changeset
|
297 if not self.extensions: |
|
810c25d5041c
Changed to reflect the new "command options" regime -- in particular,
Greg Ward <gward@python.net>
parents:
11246
diff
changeset
|
298 return |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
299 |
|
12057
42d8d76dae6d
Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents:
12029
diff
changeset
|
300 # 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
|
301 # 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
|
302 # linking extensions. |
|
12095
4387606a1281
Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents:
12057
diff
changeset
|
303 if self.distribution.has_c_libraries(): |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
304 build_clib = self.get_finalized_command('build_clib') |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
305 self.libraries.extend(build_clib.get_library_names() or []) |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
306 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
|
307 |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
308 # 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
|
309 # compiling and linking |
|
59743
3d38c0032cea
Fixed #2698 - now reads the compiler option when creating the compiler
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55211
diff
changeset
|
310 self.compiler = new_compiler(compiler=self.compiler, |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
311 verbose=self.verbose, |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
312 dry_run=self.dry_run, |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
313 force=self.force) |
|
54031
2c1d8f2d3839
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54023
diff
changeset
|
314 customize_compiler(self.compiler) |
|
46370
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
315 # If we are cross-compiling, init the compiler now (if we are not |
|
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
316 # cross-compiling, init would not hurt, but people may rely on |
|
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
317 # late initialization of compiler even if they shouldn't...) |
|
2e917b0c8f6e
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45134
diff
changeset
|
318 if os.name == 'nt' and self.plat_name != get_platform(): |
|
54031
2c1d8f2d3839
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54023
diff
changeset
|
319 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
|
320 |
|
42d8d76dae6d
Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents:
12029
diff
changeset
|
321 # 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
|
322 # 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
|
323 # 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
|
324 # 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
|
325 if self.include_dirs is not None: |
|
54031
2c1d8f2d3839
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54023
diff
changeset
|
326 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
|
327 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
|
328 # 'define' option is a list of (name,value) tuples |
|
53970
050742bb60d5
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
52620
diff
changeset
|
329 for (name, value) in self.define: |
|
54031
2c1d8f2d3839
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54023
diff
changeset
|
330 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
|
331 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
|
332 for macro in self.undef: |
|
54031
2c1d8f2d3839
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54023
diff
changeset
|
333 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
|
334 if self.libraries is not None: |
|
54031
2c1d8f2d3839
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54023
diff
changeset
|
335 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
|
336 if self.library_dirs is not None: |
|
54031
2c1d8f2d3839
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54023
diff
changeset
|
337 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
|
338 if self.rpath is not None: |
|
54031
2c1d8f2d3839
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54023
diff
changeset
|
339 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
|
340 if self.link_objects is not None: |
|
54031
2c1d8f2d3839
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54023
diff
changeset
|
341 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
|
342 |
|
12057
42d8d76dae6d
Fixed a bunch of screwed-up logic and inconsistent terminology.
Greg Ward <gward@python.net>
parents:
12029
diff
changeset
|
343 # Now actually compile and link everything. |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
344 self.build_extensions() |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
345 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
346 def check_extensions_list(self, extensions): |
|
11712
9250e5d3aa31
Tweaked various comments, docstrings, and error messages.
Greg Ward <gward@python.net>
parents:
11702
diff
changeset
|
347 """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
|
348 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
|
349 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
|
350 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
|
351 Extension instances here. |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
352 |
|
12800
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
353 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
|
354 just returns otherwise. |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
355 """ |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
356 if not isinstance(extensions, list): |
|
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
357 raise DistutilsSetupError( |
|
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
358 "'ext_modules' option must be a list of Extension instances") |
| 21268 | 359 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
360 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
|
361 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
|
362 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
|
363 # by Extension constructor) |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
364 |
|
53970
050742bb60d5
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
52620
diff
changeset
|
365 if not isinstance(ext, tuple) or len(ext) != 2: |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
366 raise DistutilsSetupError( |
|
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
367 "each element of 'ext_modules' option must be an " |
|
12800
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
368 "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
|
369 |
|
53970
050742bb60d5
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
52620
diff
changeset
|
370 ext_name, build_info = ext |
|
050742bb60d5
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
52620
diff
changeset
|
371 |
|
050742bb60d5
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
52620
diff
changeset
|
372 log.warn(("old-style (ext_name, build_info) tuple found in " |
|
050742bb60d5
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
52620
diff
changeset
|
373 "ext_modules for extension '%s'" |
|
050742bb60d5
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
52620
diff
changeset
|
374 "-- please convert to Extension instance" % ext_name)) |
|
050742bb60d5
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
52620
diff
changeset
|
375 |
|
43577
ace45b361e87
Patch# 1258 by Christian Heimes: kill basestring.
Guido van Rossum <guido@python.org>
parents:
43026
diff
changeset
|
376 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
|
377 extension_name_re.match(ext_name)): |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
378 raise DistutilsSetupError( |
|
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
379 "first element of each tuple in 'ext_modules' " |
|
12800
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
380 "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
|
381 |
|
53970
050742bb60d5
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
52620
diff
changeset
|
382 if not isinstance(build_info, dict): |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
383 raise DistutilsSetupError( |
|
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
384 "second element of each tuple in 'ext_modules' " |
|
12800
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
385 "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
|
386 |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
387 # 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
|
388 # 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
|
389 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
|
390 |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
391 # 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
|
392 # instance attributes. |
|
53970
050742bb60d5
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
52620
diff
changeset
|
393 for key in ('include_dirs', 'library_dirs', 'libraries', |
|
050742bb60d5
Merged revisions 72531 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
52620
diff
changeset
|
394 '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
|
395 'extra_link_args'): |
|
14216
d33179cdc511
In 'check_extensions_list()': when converting old-style 'buildinfo' dict,
Greg Ward <gward@python.net>
parents:
13950
diff
changeset
|
396 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
|
397 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
|
398 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
|
399 |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
400 # 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
|
401 ext.runtime_library_dirs = build_info.get('rpath') |
|
39575
63237fcefd99
Get rid of dict.has_key(). Boy this has a lot of repercussions!
Guido van Rossum <guido@python.org>
parents:
38453
diff
changeset
|
402 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
|
403 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
|
404 "no longer supported") |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
405 |
|
12800
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
406 # 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
|
407 # and 'undef_macros'. |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
408 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
|
409 if macros: |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
410 ext.define_macros = [] |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
411 ext.undef_macros = [] |
|
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
412 for macro in macros: |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
413 if not (isinstance(macro, tuple) and len(macro) in (1, 2)): |
|
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
414 raise DistutilsSetupError( |
|
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
415 "'macros' element of build info dict " |
|
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
416 "must be 1- or 2-tuple") |
|
12800
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
417 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
|
418 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
|
419 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
|
420 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
|
421 |
|
12800
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
422 extensions[i] = ext |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
423 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
424 def get_source_files(self): |
|
13599
3260220aaee4
Typo fix from Bastian Kleineidam
Andrew M. Kuchling <amk@amk.ca>
parents:
13413
diff
changeset
|
425 self.check_extensions_list(self.extensions) |
| 11340 | 426 filenames = [] |
| 427 | |
| 428 # 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
|
429 for ext in self.extensions: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
430 filenames.extend(ext.sources) |
| 11340 | 431 return filenames |
| 432 | |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
433 def get_outputs(self): |
|
12095
4387606a1281
Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents:
12057
diff
changeset
|
434 # 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
|
435 # 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
|
436 # can probably assume that it *isn't*!). |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
437 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
|
438 |
|
4387606a1281
Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents:
12057
diff
changeset
|
439 # 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
|
440 # 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
|
441 # "build" tree. |
|
4387606a1281
Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents:
12057
diff
changeset
|
442 outputs = [] |
|
12800
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
443 for ext in self.extensions: |
|
54023
924dbb7fc6c5
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53970
diff
changeset
|
444 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
|
445 return outputs |
|
4387606a1281
Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents:
12057
diff
changeset
|
446 |
|
16281
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
447 def build_extensions(self): |
|
12095
4387606a1281
Added 'get_outputs()' in prepartion for the 'bdist' command.
Greg Ward <gward@python.net>
parents:
12057
diff
changeset
|
448 # First, sanity-check the 'extensions' list |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
449 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
|
450 |
|
12800
3aab0c519009
Overhauled to expect 'self.extensions' (taken from 'ext_modules' in the
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
451 for ext in self.extensions: |
|
52610
f7b11bf01a12
Merged revisions 70910 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51892
diff
changeset
|
452 try: |
|
f7b11bf01a12
Merged revisions 70910 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51892
diff
changeset
|
453 self.build_extension(ext) |
|
52620
30d874b1c4a7
Merged revisions 70920,70922 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
52610
diff
changeset
|
454 except (CCompilerError, DistutilsError, CompileError) as e: |
|
52610
f7b11bf01a12
Merged revisions 70910 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51892
diff
changeset
|
455 if not ext.optional: |
|
f7b11bf01a12
Merged revisions 70910 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51892
diff
changeset
|
456 raise |
|
f7b11bf01a12
Merged revisions 70910 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51892
diff
changeset
|
457 self.warn('building extension "%s" failed: %s' % |
|
f7b11bf01a12
Merged revisions 70910 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51892
diff
changeset
|
458 (ext.name, e)) |
|
16281
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
459 |
|
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
460 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
|
461 sources = ext.sources |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
462 if sources is None or not isinstance(sources, (list, tuple)): |
|
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
463 raise DistutilsSetupError( |
|
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
464 "in 'ext_modules' option (extension '%s'), " |
|
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
465 "'sources' must be present and must be " |
|
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
466 "a list of source filenames" % 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
|
467 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
|
468 |
|
54023
924dbb7fc6c5
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53970
diff
changeset
|
469 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
|
470 depends = sources + ext.depends |
|
54023
924dbb7fc6c5
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53970
diff
changeset
|
471 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
|
472 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
|
473 return |
|
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
474 else: |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23273
diff
changeset
|
475 log.info("building '%s' extension", ext.name) |
| 11702 | 476 |
|
16281
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
477 # 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
|
478 # 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
|
479 # accordingly. |
|
33759
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
480 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
|
481 |
|
16281
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
482 # 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
|
483 |
|
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
484 # 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
|
485 # 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
|
486 # 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
|
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 # 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
|
489 # - '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
|
490 # - 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
|
491 # 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
|
492 # 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
|
493 # 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
|
494 # 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
|
495 # 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
|
496 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
|
497 |
|
16281
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
498 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
|
499 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
|
500 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
|
501 |
|
54031
2c1d8f2d3839
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54023
diff
changeset
|
502 objects = self.compiler.compile(sources, |
|
54023
924dbb7fc6c5
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53970
diff
changeset
|
503 output_dir=self.build_temp, |
|
924dbb7fc6c5
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53970
diff
changeset
|
504 macros=macros, |
|
924dbb7fc6c5
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53970
diff
changeset
|
505 include_dirs=ext.include_dirs, |
|
924dbb7fc6c5
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53970
diff
changeset
|
506 debug=self.debug, |
|
924dbb7fc6c5
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53970
diff
changeset
|
507 extra_postargs=extra_args, |
|
924dbb7fc6c5
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53970
diff
changeset
|
508 depends=ext.depends) |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
509 |
|
21277
f702ff390e4d
Visious hackery to solve a build-control problem related to our use of
Fred Drake <fdrake@acm.org>
parents:
21268
diff
changeset
|
510 # 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
|
511 # |
|
f702ff390e4d
Visious hackery to solve a build-control problem related to our use of
Fred Drake <fdrake@acm.org>
parents:
21268
diff
changeset
|
512 # 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
|
513 # 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
|
514 # 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
|
515 # 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
|
516 # 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
|
517 # 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
|
518 # |
|
f702ff390e4d
Visious hackery to solve a build-control problem related to our use of
Fred Drake <fdrake@acm.org>
parents:
21268
diff
changeset
|
519 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
|
520 |
|
16281
2abcbe44271a
Added an execution layer to be able to customize per-extension
Marc-André Lemburg <mal@egenix.com>
parents:
16211
diff
changeset
|
521 # 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
|
522 # 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
|
523 # 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
|
524 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
|
525 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
|
526 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
|
527 |
|
26036
771b6f521b95
This patch fixes the following bugs:
Gustavo Niemeyer <gustavo@niemeyer.net>
parents:
26018
diff
changeset
|
528 # Detect target language, if not provided |
|
54031
2c1d8f2d3839
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54023
diff
changeset
|
529 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
|
530 |
|
54031
2c1d8f2d3839
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54023
diff
changeset
|
531 self.compiler.link_shared_object( |
|
54023
924dbb7fc6c5
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53970
diff
changeset
|
532 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
|
533 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
|
534 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
|
535 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
|
536 extra_postargs=extra_args, |
| 21268 | 537 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
|
538 debug=self.debug, |
|
26036
771b6f521b95
This patch fixes the following bugs:
Gustavo Niemeyer <gustavo@niemeyer.net>
parents:
26018
diff
changeset
|
539 build_temp=self.build_temp, |
|
771b6f521b95
This patch fixes the following bugs:
Gustavo Niemeyer <gustavo@niemeyer.net>
parents:
26018
diff
changeset
|
540 target_lang=language) |
|
11199
c52fbc6bd38a
Implements the 'build_ext' command for building C/C++ extension modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
541 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
542 def swig_sources(self, sources, extension): |
|
12996
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
543 """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
|
544 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
|
545 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
|
546 by the generated C (or C++) files. |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
547 """ |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
548 new_sources = [] |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
549 swig_sources = [] |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
550 swig_targets = {} |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
551 |
|
13032
1240bc997c8f
Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support.
Greg Ward <gward@python.net>
parents:
13014
diff
changeset
|
552 # 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
|
553 # 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
|
554 # 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
|
555 # the temp dir. |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
556 |
|
13032
1240bc997c8f
Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support.
Greg Ward <gward@python.net>
parents:
13014
diff
changeset
|
557 if self.swig_cpp: |
|
33759
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
558 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
|
559 |
|
41554
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41480
diff
changeset
|
560 if self.swig_cpp or ('-c++' in self.swig_opts) or \ |
|
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41480
diff
changeset
|
561 ('-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
|
562 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
|
563 else: |
|
1240bc997c8f
Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support.
Greg Ward <gward@python.net>
parents:
13014
diff
changeset
|
564 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
|
565 |
|
12996
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
566 for source in sources: |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
567 (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
|
568 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
|
569 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
|
570 swig_sources.append(source) |
|
12996
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
571 swig_targets[source] = new_sources[-1] |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
572 else: |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
573 new_sources.append(source) |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
574 |
|
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
|
575 if not swig_sources: |
|
12996
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
576 return new_sources |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
577 |
|
33759
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
578 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
|
579 swig_cmd = [swig, "-python"] |
|
33759
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
580 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
|
581 if self.swig_cpp: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14914
diff
changeset
|
582 swig_cmd.append("-c++") |
|
12996
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
583 |
|
33759
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
584 # Do not override commandline arguments |
|
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
585 if not self.swig_opts: |
|
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
586 for o in extension.swig_opts: |
|
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
587 swig_cmd.append(o) |
|
11d01fc650dc
Patch 1046644 - improved distutils support for SWIG.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
588 |
|
12996
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
589 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
|
590 target = swig_targets[source] |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23273
diff
changeset
|
591 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
|
592 self.spawn(swig_cmd + ["-o", target, source]) |
|
12996
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
593 |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
594 return new_sources |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
595 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
596 def find_swig(self): |
|
12996
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
597 """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
|
598 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
|
599 Windows. |
|
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 if os.name == "posix": |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
602 return "swig" |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
603 elif os.name == "nt": |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
604 # Look for SWIG in its standard installation directory on |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
605 # 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
|
606 # 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
|
607 for vers in ("1.3", "1.2", "1.1"): |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
608 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
|
609 if os.path.isfile(fn): |
|
12996
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
610 return fn |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
611 else: |
|
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
612 return "swig.exe" |
|
21851
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21760
diff
changeset
|
613 elif os.name == "os2": |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21760
diff
changeset
|
614 # 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
|
615 return "swig.exe" |
|
12996
c75718fbd862
Experimental, completely untested SWIG support.
Greg Ward <gward@python.net>
parents:
12942
diff
changeset
|
616 else: |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
617 raise DistutilsPlatformError( |
|
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
618 "I don't know how to find (much less run) SWIG " |
|
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
619 "on platform '%s'" % os.name) |
| 21268 | 620 |
|
12942
a8530d36021c
Pulled the MSVC++-specific hackery out to a new method, 'prelink_hook()',
Greg Ward <gward@python.net>
parents:
12869
diff
changeset
|
621 # -- Name generators ----------------------------------------------- |
|
a8530d36021c
Pulled the MSVC++-specific hackery out to a new method, 'prelink_hook()',
Greg Ward <gward@python.net>
parents:
12869
diff
changeset
|
622 # (extension names, filenames, whatever) |
|
54023
924dbb7fc6c5
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53970
diff
changeset
|
623 def get_ext_fullpath(self, ext_name): |
|
924dbb7fc6c5
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53970
diff
changeset
|
624 """Returns the path of the filename for a given extension. |
|
924dbb7fc6c5
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53970
diff
changeset
|
625 |
|
924dbb7fc6c5
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53970
diff
changeset
|
626 The file is located in `build_lib` or directly in the package |
|
924dbb7fc6c5
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53970
diff
changeset
|
627 (inplace option). |
|
924dbb7fc6c5
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53970
diff
changeset
|
628 """ |
|
54205
9394a82d8de1
Merged revisions 72781 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54183
diff
changeset
|
629 fullname = self.get_ext_fullname(ext_name) |
|
54981
514cae62ccda
Merged revisions 73689 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54205
diff
changeset
|
630 modpath = fullname.split('.') |
|
55069
d8c83cc0d3fd
Merged revisions 73792 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54981
diff
changeset
|
631 filename = self.get_ext_filename(modpath[-1]) |
|
d8c83cc0d3fd
Merged revisions 73792 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54981
diff
changeset
|
632 |
|
54205
9394a82d8de1
Merged revisions 72781 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54183
diff
changeset
|
633 if not self.inplace: |
|
9394a82d8de1
Merged revisions 72781 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54183
diff
changeset
|
634 # no further work needed |
|
55069
d8c83cc0d3fd
Merged revisions 73792 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54981
diff
changeset
|
635 # returning : |
|
d8c83cc0d3fd
Merged revisions 73792 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54981
diff
changeset
|
636 # build_dir/package/path/filename |
|
d8c83cc0d3fd
Merged revisions 73792 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54981
diff
changeset
|
637 filename = os.path.join(*modpath[:-1]+[filename]) |
|
54023
924dbb7fc6c5
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53970
diff
changeset
|
638 return os.path.join(self.build_lib, filename) |
|
12942
a8530d36021c
Pulled the MSVC++-specific hackery out to a new method, 'prelink_hook()',
Greg Ward <gward@python.net>
parents:
12869
diff
changeset
|
639 |
|
54205
9394a82d8de1
Merged revisions 72781 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54183
diff
changeset
|
640 # the inplace option requires to find the package directory |
|
55069
d8c83cc0d3fd
Merged revisions 73792 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54981
diff
changeset
|
641 # using the build_py command for that |
|
d8c83cc0d3fd
Merged revisions 73792 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54981
diff
changeset
|
642 package = '.'.join(modpath[0:-1]) |
|
54205
9394a82d8de1
Merged revisions 72781 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54183
diff
changeset
|
643 build_py = self.get_finalized_command('build_py') |
|
9394a82d8de1
Merged revisions 72781 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54183
diff
changeset
|
644 package_dir = os.path.abspath(build_py.get_package_dir(package)) |
|
55069
d8c83cc0d3fd
Merged revisions 73792 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54981
diff
changeset
|
645 |
|
d8c83cc0d3fd
Merged revisions 73792 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54981
diff
changeset
|
646 # returning |
|
d8c83cc0d3fd
Merged revisions 73792 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54981
diff
changeset
|
647 # package_dir/filename |
|
54205
9394a82d8de1
Merged revisions 72781 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54183
diff
changeset
|
648 return os.path.join(package_dir, filename) |
|
9394a82d8de1
Merged revisions 72781 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54183
diff
changeset
|
649 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
650 def get_ext_fullname(self, ext_name): |
|
54023
924dbb7fc6c5
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53970
diff
changeset
|
651 """Returns the fullname of a given extension name. |
|
924dbb7fc6c5
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53970
diff
changeset
|
652 |
|
924dbb7fc6c5
Merged revisions 72585 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53970
diff
changeset
|
653 Adds the `package.` prefix""" |
| 11886 | 654 if self.package is None: |
| 655 return ext_name | |
| 656 else: | |
| 657 return self.package + '.' + ext_name | |
| 658 | |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
659 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
|
660 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
|
661 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
|
662 "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
|
663 """ |
|
14574
b4a37ab329da
Adjust to the new sysconfig regime: use 'get_config_var()' instead
Greg Ward <gward@python.net>
parents:
14434
diff
changeset
|
664 from distutils.sysconfig import get_config_var |
|
41480
99027c2b3fd2
Remove functions in string module that are also string methods. Also remove:
Neal Norwitz <nnorwitz@gmail.com>
parents:
40893
diff
changeset
|
665 ext_path = ext_name.split('.') |
|
21851
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21760
diff
changeset
|
666 # 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
|
667 if os.name == "os2": |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21760
diff
changeset
|
668 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
|
669 # 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
|
670 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
|
671 if os.name == 'nt' and self.debug: |
| 37048 | 672 return os.path.join(*ext_path) + '_d' + so_ext |
| 673 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
|
674 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
675 def get_export_symbols(self, ext): |
|
13797
e00d3ce71f89
Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
676 """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
|
677 export. This either uses 'ext.export_symbols' or, if it's not |
|
47600
b772bee3a10e
Follow-up of PEP 3121:
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47063
diff
changeset
|
678 provided, "PyInit_" + module_name. Only relevant on Windows, where |
|
55211
56ccef3420e7
Merged revisions 73948 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55069
diff
changeset
|
679 the .pyd file (DLL) must export the module "PyInit_" function. |
|
13797
e00d3ce71f89
Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
680 """ |
|
47600
b772bee3a10e
Follow-up of PEP 3121:
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
47063
diff
changeset
|
681 initfunc_name = "PyInit_" + 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
|
682 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
|
683 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
|
684 return ext.export_symbols |
|
13797
e00d3ce71f89
Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
685 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
41558
diff
changeset
|
686 def get_libraries(self, ext): |
|
13797
e00d3ce71f89
Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
687 """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
|
688 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
|
689 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
|
690 """ |
|
e00d3ce71f89
Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
691 # 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
|
692 # 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
|
693 # 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
|
694 # 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
|
695 # 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
|
696 if sys.platform == "win32": |
|
921064c26297
Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23824
diff
changeset
|
697 from distutils.msvccompiler import MSVCCompiler |
|
54031
2c1d8f2d3839
Merged revisions 72593 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
54023
diff
changeset
|
698 if not isinstance(self.compiler, MSVCCompiler): |
|
23910
921064c26297
Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23824
diff
changeset
|
699 template = "python%d%d" |
|
921064c26297
Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23824
diff
changeset
|
700 if self.debug: |
|
921064c26297
Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23824
diff
changeset
|
701 template = template + '_d' |
|
921064c26297
Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23824
diff
changeset
|
702 pythonlib = (template % |
|
921064c26297
Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23824
diff
changeset
|
703 (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) |
|
921064c26297
Only import msvccompiler on win32 platforms.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23824
diff
changeset
|
704 # 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
|
705 # 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
|
706 return ext.libraries + [pythonlib] |
|
25976
2d837e2083fa
Fixes SF bug#614051: win32 build_ext problem.
Thomas Heller <theller@ctypes.org>
parents:
23910
diff
changeset
|
707 else: |
|
2d837e2083fa
Fixes SF bug#614051: win32 build_ext problem.
Thomas Heller <theller@ctypes.org>
parents:
23910
diff
changeset
|
708 return ext.libraries |
|
21851
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21760
diff
changeset
|
709 elif sys.platform == "os2emx": |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21760
diff
changeset
|
710 # 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
|
711 # 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
|
712 template = "python%d%d" |
|
32736
c3a096bfbd6b
Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents:
32063
diff
changeset
|
713 # 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
|
714 # 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
|
715 #if self.debug: |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21760
diff
changeset
|
716 # template = template + '_d' |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21760
diff
changeset
|
717 pythonlib = (template % |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21760
diff
changeset
|
718 (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
|
719 # 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
|
720 # 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
|
721 return ext.libraries + [pythonlib] |
|
16211
98b65484ade6
Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents:
15770
diff
changeset
|
722 elif sys.platform[:6] == "cygwin": |
|
98b65484ade6
Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents:
15770
diff
changeset
|
723 template = "python%d.%d" |
|
98b65484ade6
Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents:
15770
diff
changeset
|
724 pythonlib = (template % |
|
98b65484ade6
Part of patch #102409: special cases for Cygwin:
Andrew M. Kuchling <amk@amk.ca>
parents:
15770
diff
changeset
|
725 (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
|
726 # 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
|
727 # 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
|
728 return ext.libraries + [pythonlib] |
|
23777
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
729 elif sys.platform[:6] == "atheos": |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
730 from distutils import sysconfig |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
731 |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
732 template = "python%d.%d" |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
733 pythonlib = (template % |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
734 (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
735 # Get SHLIBS from Makefile |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
736 extra = [] |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
737 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
|
738 if lib.startswith('-l'): |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
739 extra.append(lib[2:]) |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
740 else: |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
741 extra.append(lib) |
|
bec1b942e0bc
Patch #488073: AtheOS port.
Martin v. Löwis <martin@v.loewis.de>
parents:
23668
diff
changeset
|
742 # 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
|
743 # 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
|
744 return ext.libraries + [pythonlib, "m"] + extra |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
745 elif sys.platform == 'darwin': |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
746 # Don't use the default code below |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
747 return ext.libraries |
|
64617
9f0d69caed3b
Merged revisions 84680 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59743
diff
changeset
|
748 elif sys.platform[:3] == 'aix': |
|
9f0d69caed3b
Merged revisions 84680 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59743
diff
changeset
|
749 # Don't use the default code below |
|
9f0d69caed3b
Merged revisions 84680 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
59743
diff
changeset
|
750 return ext.libraries |
|
13797
e00d3ce71f89
Patch from Rene Liebscher, tweaked by me:
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
751 else: |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
37048
diff
changeset
|
752 from distutils import sysconfig |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
37048
diff
changeset
|
753 if sysconfig.get_config_var('Py_ENABLE_SHARED'): |
|
65389
932f97bfbdc0
First (uncontroversial) part of issue 9807.
Barry Warsaw <barry@python.org>
parents:
64615
diff
changeset
|
754 pythonlib = 'python{}.{}{}'.format( |
|
932f97bfbdc0
First (uncontroversial) part of issue 9807.
Barry Warsaw <barry@python.org>
parents:
64615
diff
changeset
|
755 sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff, |
|
932f97bfbdc0
First (uncontroversial) part of issue 9807.
Barry Warsaw <barry@python.org>
parents:
64615
diff
changeset
|
756 sys.abiflags) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
37048
diff
changeset
|
757 return ext.libraries + [pythonlib] |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
37048
diff
changeset
|
758 else: |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
37048
diff
changeset
|
759 return ext.libraries |
