Mercurial > cpython-lru_cache-weakref
annotate Lib/distutils/sysconfig.py @ 58925:eecf1bef052d 2.6
Merged revisions 78207 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line
#7930: fix stripid
........
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Tue, 16 Feb 2010 23:29:44 +0000 |
| parents | b27d946389e7 |
| children | 621d2e984d18 |
| rev | line source |
|---|---|
|
18696
1c2da78b839b
Minor changes for stylistic cleanliness and consistency.
Fred Drake <fdrake@acm.org>
parents:
17847
diff
changeset
|
1 """Provide access to Python's configuration information. The specific |
|
1c2da78b839b
Minor changes for stylistic cleanliness and consistency.
Fred Drake <fdrake@acm.org>
parents:
17847
diff
changeset
|
2 configuration variables available depend heavily on the platform and |
|
1c2da78b839b
Minor changes for stylistic cleanliness and consistency.
Fred Drake <fdrake@acm.org>
parents:
17847
diff
changeset
|
3 configuration. The values may be retrieved using |
|
1c2da78b839b
Minor changes for stylistic cleanliness and consistency.
Fred Drake <fdrake@acm.org>
parents:
17847
diff
changeset
|
4 get_config_var(name), and the list of variables is available via |
|
1c2da78b839b
Minor changes for stylistic cleanliness and consistency.
Fred Drake <fdrake@acm.org>
parents:
17847
diff
changeset
|
5 get_config_vars().keys(). Additional convenience functions are also |
|
1c2da78b839b
Minor changes for stylistic cleanliness and consistency.
Fred Drake <fdrake@acm.org>
parents:
17847
diff
changeset
|
6 available. |
| 9658 | 7 |
| 8 Written by: Fred L. Drake, Jr. | |
| 9 Email: <fdrake@acm.org> | |
| 10 """ | |
| 11 | |
|
12840
3912fb6c63f6
Added a bunch of new globals in '_init_mac()' -- these will be needed to
Greg Ward <gward@python.net>
parents:
12740
diff
changeset
|
12 __revision__ = "$Id$" |
| 9658 | 13 |
|
9780
4b18f8eaa16b
Another patch from Fred: factored _init_posix into
Greg Ward <gward@python.net>
parents:
9690
diff
changeset
|
14 import os |
|
4b18f8eaa16b
Another patch from Fred: factored _init_posix into
Greg Ward <gward@python.net>
parents:
9690
diff
changeset
|
15 import re |
|
26186
af3964679e2f
Back out part of rev. 1.53, restoring the use of the string module.
Andrew M. Kuchling <amk@amk.ca>
parents:
26048
diff
changeset
|
16 import string |
|
9780
4b18f8eaa16b
Another patch from Fred: factored _init_posix into
Greg Ward <gward@python.net>
parents:
9690
diff
changeset
|
17 import sys |
| 9658 | 18 |
|
37007
1ddf0d81d6c5
Instead of relative imports, use (implicitly) absolute ones.
Guido van Rossum <guido@python.org>
parents:
36987
diff
changeset
|
19 from distutils.errors import DistutilsPlatformError |
|
11953
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
20 |
|
14572
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
21 # These are needed in a couple of spots, so just compute them once. |
|
12315
f1f665e075ca
Better variable names here and there.
Greg Ward <gward@python.net>
parents:
11953
diff
changeset
|
22 PREFIX = os.path.normpath(sys.prefix) |
|
f1f665e075ca
Better variable names here and there.
Greg Ward <gward@python.net>
parents:
11953
diff
changeset
|
23 EXEC_PREFIX = os.path.normpath(sys.exec_prefix) |
| 11689 | 24 |
|
44198
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
40055
diff
changeset
|
25 # Path to the base directory of the project. On Windows the binary may |
|
45913
e0c9b9ef0466
Issue2290: Support x64 Windows builds that live in pcbuild/amd64. Without it, sysutils._python_build() returns the wrong directory, which causes the test_get_config_h_filename method in Lib/distutils/tests/test_sysconfig.py to fail.
Trent Nelson <trent.nelson@snakebite.org>
parents:
45413
diff
changeset
|
26 # live in project/PCBuild9. If we're dealing with an x64 Windows build, |
|
e0c9b9ef0466
Issue2290: Support x64 Windows builds that live in pcbuild/amd64. Without it, sysutils._python_build() returns the wrong directory, which causes the test_get_config_h_filename method in Lib/distutils/tests/test_sysconfig.py to fail.
Trent Nelson <trent.nelson@snakebite.org>
parents:
45413
diff
changeset
|
27 # it'll live in project/PCbuild/amd64. |
|
44198
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
40055
diff
changeset
|
28 project_base = os.path.dirname(os.path.abspath(sys.executable)) |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
40055
diff
changeset
|
29 if os.name == "nt" and "pcbuild" in project_base[-8:].lower(): |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
40055
diff
changeset
|
30 project_base = os.path.abspath(os.path.join(project_base, os.path.pardir)) |
|
44412
901f70db3b34
Added support for new Windows build dirs in PC/ to distutils.sysconfig
Christian Heimes <christian@cheimes.de>
parents:
44308
diff
changeset
|
31 # PC/VS7.1 |
|
901f70db3b34
Added support for new Windows build dirs in PC/ to distutils.sysconfig
Christian Heimes <christian@cheimes.de>
parents:
44308
diff
changeset
|
32 if os.name == "nt" and "\\pc\\v" in project_base[-10:].lower(): |
|
901f70db3b34
Added support for new Windows build dirs in PC/ to distutils.sysconfig
Christian Heimes <christian@cheimes.de>
parents:
44308
diff
changeset
|
33 project_base = os.path.abspath(os.path.join(project_base, os.path.pardir, |
|
901f70db3b34
Added support for new Windows build dirs in PC/ to distutils.sysconfig
Christian Heimes <christian@cheimes.de>
parents:
44308
diff
changeset
|
34 os.path.pardir)) |
|
45913
e0c9b9ef0466
Issue2290: Support x64 Windows builds that live in pcbuild/amd64. Without it, sysutils._python_build() returns the wrong directory, which causes the test_get_config_h_filename method in Lib/distutils/tests/test_sysconfig.py to fail.
Trent Nelson <trent.nelson@snakebite.org>
parents:
45413
diff
changeset
|
35 # PC/AMD64 |
|
e0c9b9ef0466
Issue2290: Support x64 Windows builds that live in pcbuild/amd64. Without it, sysutils._python_build() returns the wrong directory, which causes the test_get_config_h_filename method in Lib/distutils/tests/test_sysconfig.py to fail.
Trent Nelson <trent.nelson@snakebite.org>
parents:
45413
diff
changeset
|
36 if os.name == "nt" and "\\pcbuild\\amd64" in project_base[-14:].lower(): |
|
e0c9b9ef0466
Issue2290: Support x64 Windows builds that live in pcbuild/amd64. Without it, sysutils._python_build() returns the wrong directory, which causes the test_get_config_h_filename method in Lib/distutils/tests/test_sysconfig.py to fail.
Trent Nelson <trent.nelson@snakebite.org>
parents:
45413
diff
changeset
|
37 project_base = os.path.abspath(os.path.join(project_base, os.path.pardir, |
|
e0c9b9ef0466
Issue2290: Support x64 Windows builds that live in pcbuild/amd64. Without it, sysutils._python_build() returns the wrong directory, which causes the test_get_config_h_filename method in Lib/distutils/tests/test_sysconfig.py to fail.
Trent Nelson <trent.nelson@snakebite.org>
parents:
45413
diff
changeset
|
38 os.path.pardir)) |
|
44198
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
40055
diff
changeset
|
39 |
|
23659
5c5fff5de250
When using a Python that has not been installed to build 3rd-party
Fred Drake <fdrake@acm.org>
parents:
21851
diff
changeset
|
40 # python_build: (Boolean) if true, we're either building Python or |
|
5c5fff5de250
When using a Python that has not been installed to build 3rd-party
Fred Drake <fdrake@acm.org>
parents:
21851
diff
changeset
|
41 # building an extension with an un-installed Python, so we use |
|
5c5fff5de250
When using a Python that has not been installed to build 3rd-party
Fred Drake <fdrake@acm.org>
parents:
21851
diff
changeset
|
42 # different (hard-wired) directories. |
| 44308 | 43 # Setup.local is available for Makefile builds including VPATH builds, |
| 44 # Setup.dist is available on Windows | |
|
45168
cfa280424b65
Keep distutils Python 2.1 compatible (or even Python 2.4 in this case).
Marc-André Lemburg <mal@egenix.com>
parents:
44412
diff
changeset
|
45 def _python_build(): |
|
cfa280424b65
Keep distutils Python 2.1 compatible (or even Python 2.4 in this case).
Marc-André Lemburg <mal@egenix.com>
parents:
44412
diff
changeset
|
46 for fn in ("Setup.dist", "Setup.local"): |
|
cfa280424b65
Keep distutils Python 2.1 compatible (or even Python 2.4 in this case).
Marc-André Lemburg <mal@egenix.com>
parents:
44412
diff
changeset
|
47 if os.path.isfile(os.path.join(project_base, "Modules", fn)): |
|
cfa280424b65
Keep distutils Python 2.1 compatible (or even Python 2.4 in this case).
Marc-André Lemburg <mal@egenix.com>
parents:
44412
diff
changeset
|
48 return True |
|
cfa280424b65
Keep distutils Python 2.1 compatible (or even Python 2.4 in this case).
Marc-André Lemburg <mal@egenix.com>
parents:
44412
diff
changeset
|
49 return False |
|
cfa280424b65
Keep distutils Python 2.1 compatible (or even Python 2.4 in this case).
Marc-André Lemburg <mal@egenix.com>
parents:
44412
diff
changeset
|
50 python_build = _python_build() |
| 9658 | 51 |
|
18945
f8fdd5083af3
Miscellaneous minor cleanups.
Fred Drake <fdrake@acm.org>
parents:
18837
diff
changeset
|
52 |
|
34661
9fa768a98c5c
Patch #1046831: Use get_python_version where appropriate in sysconfig.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
34258
diff
changeset
|
53 def get_python_version(): |
|
26205
d33005f8388e
[Bug #550364] Add get_python_version()
Andrew M. Kuchling <amk@amk.ca>
parents:
26186
diff
changeset
|
54 """Return a string containing the major and minor Python version, |
|
d33005f8388e
[Bug #550364] Add get_python_version()
Andrew M. Kuchling <amk@amk.ca>
parents:
26186
diff
changeset
|
55 leaving off the patchlevel. Sample return values could be '1.5' |
|
d33005f8388e
[Bug #550364] Add get_python_version()
Andrew M. Kuchling <amk@amk.ca>
parents:
26186
diff
changeset
|
56 or '2.2'. |
|
d33005f8388e
[Bug #550364] Add get_python_version()
Andrew M. Kuchling <amk@amk.ca>
parents:
26186
diff
changeset
|
57 """ |
|
d33005f8388e
[Bug #550364] Add get_python_version()
Andrew M. Kuchling <amk@amk.ca>
parents:
26186
diff
changeset
|
58 return sys.version[:3] |
|
d33005f8388e
[Bug #550364] Add get_python_version()
Andrew M. Kuchling <amk@amk.ca>
parents:
26186
diff
changeset
|
59 |
|
d33005f8388e
[Bug #550364] Add get_python_version()
Andrew M. Kuchling <amk@amk.ca>
parents:
26186
diff
changeset
|
60 |
|
12316
540f10881a59
Added optional 'prefix' arguments to 'get_python_inc()' and
Greg Ward <gward@python.net>
parents:
12315
diff
changeset
|
61 def get_python_inc(plat_specific=0, prefix=None): |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
62 """Return the directory containing installed Python header files. |
|
11953
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
63 |
|
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
64 If 'plat_specific' is false (the default), this is the path to the |
|
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
65 non-platform-specific header files, i.e. Python.h and so on; |
|
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
66 otherwise, this is the path to platform-specific header files |
|
18835
2dea40e40d9d
Patch #411138: Rename config.h to pyconfig.h. Closes bug #231774.
Martin v. Löwis <martin@v.loewis.de>
parents:
18696
diff
changeset
|
67 (namely pyconfig.h). |
|
11953
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
68 |
|
12316
540f10881a59
Added optional 'prefix' arguments to 'get_python_inc()' and
Greg Ward <gward@python.net>
parents:
12315
diff
changeset
|
69 If 'prefix' is supplied, use it instead of sys.prefix or |
|
540f10881a59
Added optional 'prefix' arguments to 'get_python_inc()' and
Greg Ward <gward@python.net>
parents:
12315
diff
changeset
|
70 sys.exec_prefix -- i.e., ignore 'plat_specific'. |
| 21267 | 71 """ |
|
12316
540f10881a59
Added optional 'prefix' arguments to 'get_python_inc()' and
Greg Ward <gward@python.net>
parents:
12315
diff
changeset
|
72 if prefix is None: |
|
18696
1c2da78b839b
Minor changes for stylistic cleanliness and consistency.
Fred Drake <fdrake@acm.org>
parents:
17847
diff
changeset
|
73 prefix = plat_specific and EXEC_PREFIX or PREFIX |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
74 if os.name == "posix": |
|
15937
d9d0dcb735d7
Patch #103279: sysconfig.py always looks for versions of files in
Andrew M. Kuchling <amk@amk.ca>
parents:
15923
diff
changeset
|
75 if python_build: |
|
23659
5c5fff5de250
When using a Python that has not been installed to build 3rd-party
Fred Drake <fdrake@acm.org>
parents:
21851
diff
changeset
|
76 base = os.path.dirname(os.path.abspath(sys.executable)) |
|
5c5fff5de250
When using a Python that has not been installed to build 3rd-party
Fred Drake <fdrake@acm.org>
parents:
21851
diff
changeset
|
77 if plat_specific: |
|
5c5fff5de250
When using a Python that has not been installed to build 3rd-party
Fred Drake <fdrake@acm.org>
parents:
21851
diff
changeset
|
78 inc_dir = base |
|
5c5fff5de250
When using a Python that has not been installed to build 3rd-party
Fred Drake <fdrake@acm.org>
parents:
21851
diff
changeset
|
79 else: |
|
5c5fff5de250
When using a Python that has not been installed to build 3rd-party
Fred Drake <fdrake@acm.org>
parents:
21851
diff
changeset
|
80 inc_dir = os.path.join(base, "Include") |
|
5c5fff5de250
When using a Python that has not been installed to build 3rd-party
Fred Drake <fdrake@acm.org>
parents:
21851
diff
changeset
|
81 if not os.path.exists(inc_dir): |
|
5c5fff5de250
When using a Python that has not been installed to build 3rd-party
Fred Drake <fdrake@acm.org>
parents:
21851
diff
changeset
|
82 inc_dir = os.path.join(os.path.dirname(base), "Include") |
|
5c5fff5de250
When using a Python that has not been installed to build 3rd-party
Fred Drake <fdrake@acm.org>
parents:
21851
diff
changeset
|
83 return inc_dir |
|
34661
9fa768a98c5c
Patch #1046831: Use get_python_version where appropriate in sysconfig.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
34258
diff
changeset
|
84 return os.path.join(prefix, "include", "python" + get_python_version()) |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
85 elif os.name == "nt": |
|
18945
f8fdd5083af3
Miscellaneous minor cleanups.
Fred Drake <fdrake@acm.org>
parents:
18837
diff
changeset
|
86 return os.path.join(prefix, "include") |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
87 elif os.name == "mac": |
|
24021
fcf2e01c616a
Whitespace normalization (remove tabs)
Neal Norwitz <nnorwitz@gmail.com>
parents:
24007
diff
changeset
|
88 if plat_specific: |
|
30772
897afcacba00
Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents:
27788
diff
changeset
|
89 return os.path.join(prefix, "Mac", "Include") |
|
24021
fcf2e01c616a
Whitespace normalization (remove tabs)
Neal Norwitz <nnorwitz@gmail.com>
parents:
24007
diff
changeset
|
90 else: |
|
30772
897afcacba00
Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents:
27788
diff
changeset
|
91 return os.path.join(prefix, "Include") |
|
21851
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
92 elif os.name == "os2": |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
93 return os.path.join(prefix, "Include") |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
94 else: |
|
18696
1c2da78b839b
Minor changes for stylistic cleanliness and consistency.
Fred Drake <fdrake@acm.org>
parents:
17847
diff
changeset
|
95 raise DistutilsPlatformError( |
|
1c2da78b839b
Minor changes for stylistic cleanliness and consistency.
Fred Drake <fdrake@acm.org>
parents:
17847
diff
changeset
|
96 "I don't know where Python installs its C header files " |
|
1c2da78b839b
Minor changes for stylistic cleanliness and consistency.
Fred Drake <fdrake@acm.org>
parents:
17847
diff
changeset
|
97 "on platform '%s'" % os.name) |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
98 |
|
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
99 |
|
12316
540f10881a59
Added optional 'prefix' arguments to 'get_python_inc()' and
Greg Ward <gward@python.net>
parents:
12315
diff
changeset
|
100 def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
101 """Return the directory containing the Python library (standard or |
|
11953
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
102 site additions). |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
103 |
|
11953
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
104 If 'plat_specific' is true, return the directory containing |
|
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
105 platform-specific modules, i.e. any module from a non-pure-Python |
|
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
106 module distribution; otherwise, return the platform-shared library |
|
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
107 directory. If 'standard_lib' is true, return the directory |
|
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
108 containing standard Python library modules; otherwise, return the |
|
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
109 directory for site-specific modules. |
|
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
110 |
|
12316
540f10881a59
Added optional 'prefix' arguments to 'get_python_inc()' and
Greg Ward <gward@python.net>
parents:
12315
diff
changeset
|
111 If 'prefix' is supplied, use it instead of sys.prefix or |
|
540f10881a59
Added optional 'prefix' arguments to 'get_python_inc()' and
Greg Ward <gward@python.net>
parents:
12315
diff
changeset
|
112 sys.exec_prefix -- i.e., ignore 'plat_specific'. |
|
11953
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
113 """ |
|
12316
540f10881a59
Added optional 'prefix' arguments to 'get_python_inc()' and
Greg Ward <gward@python.net>
parents:
12315
diff
changeset
|
114 if prefix is None: |
|
18696
1c2da78b839b
Minor changes for stylistic cleanliness and consistency.
Fred Drake <fdrake@acm.org>
parents:
17847
diff
changeset
|
115 prefix = plat_specific and EXEC_PREFIX or PREFIX |
|
18945
f8fdd5083af3
Miscellaneous minor cleanups.
Fred Drake <fdrake@acm.org>
parents:
18837
diff
changeset
|
116 |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
117 if os.name == "posix": |
|
12315
f1f665e075ca
Better variable names here and there.
Greg Ward <gward@python.net>
parents:
11953
diff
changeset
|
118 libpython = os.path.join(prefix, |
|
26205
d33005f8388e
[Bug #550364] Add get_python_version()
Andrew M. Kuchling <amk@amk.ca>
parents:
26186
diff
changeset
|
119 "lib", "python" + get_python_version()) |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
120 if standard_lib: |
|
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
121 return libpython |
|
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
122 else: |
|
11953
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
123 return os.path.join(libpython, "site-packages") |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
124 |
|
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
125 elif os.name == "nt": |
|
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
126 if standard_lib: |
|
18945
f8fdd5083af3
Miscellaneous minor cleanups.
Fred Drake <fdrake@acm.org>
parents:
18837
diff
changeset
|
127 return os.path.join(prefix, "Lib") |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
128 else: |
|
34661
9fa768a98c5c
Patch #1046831: Use get_python_version where appropriate in sysconfig.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
34258
diff
changeset
|
129 if get_python_version() < "2.2": |
|
19453
7fb5f15685dd
Patch #449054 to implement PEP 250. The standard install directory for
Greg Ward <gward@python.net>
parents:
18945
diff
changeset
|
130 return prefix |
|
7fb5f15685dd
Patch #449054 to implement PEP 250. The standard install directory for
Greg Ward <gward@python.net>
parents:
18945
diff
changeset
|
131 else: |
|
51505
1307a66a38f8
Merged revisions 69485 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
47473
diff
changeset
|
132 return os.path.join(prefix, "Lib", "site-packages") |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
133 |
|
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
134 elif os.name == "mac": |
| 13811 | 135 if plat_specific: |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
136 if standard_lib: |
|
19681
7de4e6b8d199
On the mac some library paths returned were outdated, some were outright funny.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19453
diff
changeset
|
137 return os.path.join(prefix, "Lib", "lib-dynload") |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
138 else: |
|
19681
7de4e6b8d199
On the mac some library paths returned were outdated, some were outright funny.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19453
diff
changeset
|
139 return os.path.join(prefix, "Lib", "site-packages") |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
140 else: |
|
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
141 if standard_lib: |
|
18945
f8fdd5083af3
Miscellaneous minor cleanups.
Fred Drake <fdrake@acm.org>
parents:
18837
diff
changeset
|
142 return os.path.join(prefix, "Lib") |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
143 else: |
|
19681
7de4e6b8d199
On the mac some library paths returned were outdated, some were outright funny.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19453
diff
changeset
|
144 return os.path.join(prefix, "Lib", "site-packages") |
|
21851
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
145 |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
146 elif os.name == "os2": |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
147 if standard_lib: |
|
51505
1307a66a38f8
Merged revisions 69485 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
47473
diff
changeset
|
148 return os.path.join(prefix, "Lib") |
|
21851
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
149 else: |
|
51505
1307a66a38f8
Merged revisions 69485 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
47473
diff
changeset
|
150 return os.path.join(prefix, "Lib", "site-packages") |
|
21851
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
151 |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
152 else: |
|
18696
1c2da78b839b
Minor changes for stylistic cleanliness and consistency.
Fred Drake <fdrake@acm.org>
parents:
17847
diff
changeset
|
153 raise DistutilsPlatformError( |
|
1c2da78b839b
Minor changes for stylistic cleanliness and consistency.
Fred Drake <fdrake@acm.org>
parents:
17847
diff
changeset
|
154 "I don't know where Python installs its library " |
|
1c2da78b839b
Minor changes for stylistic cleanliness and consistency.
Fred Drake <fdrake@acm.org>
parents:
17847
diff
changeset
|
155 "on platform '%s'" % os.name) |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
156 |
|
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
157 |
|
18696
1c2da78b839b
Minor changes for stylistic cleanliness and consistency.
Fred Drake <fdrake@acm.org>
parents:
17847
diff
changeset
|
158 def customize_compiler(compiler): |
|
18945
f8fdd5083af3
Miscellaneous minor cleanups.
Fred Drake <fdrake@acm.org>
parents:
18837
diff
changeset
|
159 """Do any platform-specific customization of a CCompiler instance. |
|
f8fdd5083af3
Miscellaneous minor cleanups.
Fred Drake <fdrake@acm.org>
parents:
18837
diff
changeset
|
160 |
|
f8fdd5083af3
Miscellaneous minor cleanups.
Fred Drake <fdrake@acm.org>
parents:
18837
diff
changeset
|
161 Mainly needed on Unix, so we can plug in the information that |
|
f8fdd5083af3
Miscellaneous minor cleanups.
Fred Drake <fdrake@acm.org>
parents:
18837
diff
changeset
|
162 varies across Unices and is stored in Python's Makefile. |
|
13009
7b38678b3652
Added the 'customize_compiler()' function, which plugs in the essential
Greg Ward <gward@python.net>
parents:
12840
diff
changeset
|
163 """ |
|
7b38678b3652
Added the 'customize_compiler()' function, which plugs in the essential
Greg Ward <gward@python.net>
parents:
12840
diff
changeset
|
164 if compiler.compiler_type == "unix": |
|
34930
294dabcb379b
Make parse_makefile fallback to environment variables if nothing is
Martin v. Löwis <martin@v.loewis.de>
parents:
34929
diff
changeset
|
165 (cc, cxx, opt, cflags, ccshared, ldshared, so_ext) = \ |
|
34960
80fb2891b33b
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
34930
diff
changeset
|
166 get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', |
|
34929
08e20e9c76fb
Introduced EXTRA_CFLAGS as an environment variable used by the Makefile. Meant
Brett Cannon <bcannon@gmail.com>
parents:
34661
diff
changeset
|
167 'CCSHARED', 'LDSHARED', 'SO') |
|
14572
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
168 |
|
45413
8a187f562959
Removed uses of dict.has_key() from distutils, and uses of
Guido van Rossum <guido@python.org>
parents:
45168
diff
changeset
|
169 if 'CC' in os.environ: |
|
26020
8e3246842773
[Patch #588809] LDFLAGS support for build_ext.py, from Robert Weber
Andrew M. Kuchling <amk@amk.ca>
parents:
24211
diff
changeset
|
170 cc = os.environ['CC'] |
|
45413
8a187f562959
Removed uses of dict.has_key() from distutils, and uses of
Guido van Rossum <guido@python.org>
parents:
45168
diff
changeset
|
171 if 'CXX' in os.environ: |
|
26036
771b6f521b95
This patch fixes the following bugs:
Gustavo Niemeyer <gustavo@niemeyer.net>
parents:
26020
diff
changeset
|
172 cxx = os.environ['CXX'] |
|
45413
8a187f562959
Removed uses of dict.has_key() from distutils, and uses of
Guido van Rossum <guido@python.org>
parents:
45168
diff
changeset
|
173 if 'LDSHARED' in os.environ: |
|
33750
ec993b726605
Patch 983206: distutils obeys LDSHARED env var. Removed the code in
Anthony Baxter <anthonybaxter@gmail.com>
parents:
32736
diff
changeset
|
174 ldshared = os.environ['LDSHARED'] |
|
45413
8a187f562959
Removed uses of dict.has_key() from distutils, and uses of
Guido van Rossum <guido@python.org>
parents:
45168
diff
changeset
|
175 if 'CPP' in os.environ: |
|
26020
8e3246842773
[Patch #588809] LDFLAGS support for build_ext.py, from Robert Weber
Andrew M. Kuchling <amk@amk.ca>
parents:
24211
diff
changeset
|
176 cpp = os.environ['CPP'] |
|
8e3246842773
[Patch #588809] LDFLAGS support for build_ext.py, from Robert Weber
Andrew M. Kuchling <amk@amk.ca>
parents:
24211
diff
changeset
|
177 else: |
|
8e3246842773
[Patch #588809] LDFLAGS support for build_ext.py, from Robert Weber
Andrew M. Kuchling <amk@amk.ca>
parents:
24211
diff
changeset
|
178 cpp = cc + " -E" # not always |
|
45413
8a187f562959
Removed uses of dict.has_key() from distutils, and uses of
Guido van Rossum <guido@python.org>
parents:
45168
diff
changeset
|
179 if 'LDFLAGS' in os.environ: |
|
26020
8e3246842773
[Patch #588809] LDFLAGS support for build_ext.py, from Robert Weber
Andrew M. Kuchling <amk@amk.ca>
parents:
24211
diff
changeset
|
180 ldshared = ldshared + ' ' + os.environ['LDFLAGS'] |
|
45413
8a187f562959
Removed uses of dict.has_key() from distutils, and uses of
Guido van Rossum <guido@python.org>
parents:
45168
diff
changeset
|
181 if 'CFLAGS' in os.environ: |
|
34930
294dabcb379b
Make parse_makefile fallback to environment variables if nothing is
Martin v. Löwis <martin@v.loewis.de>
parents:
34929
diff
changeset
|
182 cflags = opt + ' ' + os.environ['CFLAGS'] |
|
26020
8e3246842773
[Patch #588809] LDFLAGS support for build_ext.py, from Robert Weber
Andrew M. Kuchling <amk@amk.ca>
parents:
24211
diff
changeset
|
183 ldshared = ldshared + ' ' + os.environ['CFLAGS'] |
|
45413
8a187f562959
Removed uses of dict.has_key() from distutils, and uses of
Guido van Rossum <guido@python.org>
parents:
45168
diff
changeset
|
184 if 'CPPFLAGS' in os.environ: |
|
26020
8e3246842773
[Patch #588809] LDFLAGS support for build_ext.py, from Robert Weber
Andrew M. Kuchling <amk@amk.ca>
parents:
24211
diff
changeset
|
185 cpp = cpp + ' ' + os.environ['CPPFLAGS'] |
|
34930
294dabcb379b
Make parse_makefile fallback to environment variables if nothing is
Martin v. Löwis <martin@v.loewis.de>
parents:
34929
diff
changeset
|
186 cflags = cflags + ' ' + os.environ['CPPFLAGS'] |
|
26020
8e3246842773
[Patch #588809] LDFLAGS support for build_ext.py, from Robert Weber
Andrew M. Kuchling <amk@amk.ca>
parents:
24211
diff
changeset
|
187 ldshared = ldshared + ' ' + os.environ['CPPFLAGS'] |
|
8e3246842773
[Patch #588809] LDFLAGS support for build_ext.py, from Robert Weber
Andrew M. Kuchling <amk@amk.ca>
parents:
24211
diff
changeset
|
188 |
|
34930
294dabcb379b
Make parse_makefile fallback to environment variables if nothing is
Martin v. Löwis <martin@v.loewis.de>
parents:
34929
diff
changeset
|
189 cc_cmd = cc + ' ' + cflags |
|
13009
7b38678b3652
Added the 'customize_compiler()' function, which plugs in the essential
Greg Ward <gward@python.net>
parents:
12840
diff
changeset
|
190 compiler.set_executables( |
|
26020
8e3246842773
[Patch #588809] LDFLAGS support for build_ext.py, from Robert Weber
Andrew M. Kuchling <amk@amk.ca>
parents:
24211
diff
changeset
|
191 preprocessor=cpp, |
|
13009
7b38678b3652
Added the 'customize_compiler()' function, which plugs in the essential
Greg Ward <gward@python.net>
parents:
12840
diff
changeset
|
192 compiler=cc_cmd, |
|
14572
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
193 compiler_so=cc_cmd + ' ' + ccshared, |
|
26036
771b6f521b95
This patch fixes the following bugs:
Gustavo Niemeyer <gustavo@niemeyer.net>
parents:
26020
diff
changeset
|
194 compiler_cxx=cxx, |
|
14572
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
195 linker_so=ldshared, |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
196 linker_exe=cc) |
|
13009
7b38678b3652
Added the 'customize_compiler()' function, which plugs in the essential
Greg Ward <gward@python.net>
parents:
12840
diff
changeset
|
197 |
|
14572
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
198 compiler.shared_lib_extension = so_ext |
|
13009
7b38678b3652
Added the 'customize_compiler()' function, which plugs in the essential
Greg Ward <gward@python.net>
parents:
12840
diff
changeset
|
199 |
|
7b38678b3652
Added the 'customize_compiler()' function, which plugs in the essential
Greg Ward <gward@python.net>
parents:
12840
diff
changeset
|
200 |
|
9780
4b18f8eaa16b
Another patch from Fred: factored _init_posix into
Greg Ward <gward@python.net>
parents:
9690
diff
changeset
|
201 def get_config_h_filename(): |
|
18835
2dea40e40d9d
Patch #411138: Rename config.h to pyconfig.h. Closes bug #231774.
Martin v. Löwis <martin@v.loewis.de>
parents:
18696
diff
changeset
|
202 """Return full pathname of installed pyconfig.h file.""" |
|
18945
f8fdd5083af3
Miscellaneous minor cleanups.
Fred Drake <fdrake@acm.org>
parents:
18837
diff
changeset
|
203 if python_build: |
|
44198
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
40055
diff
changeset
|
204 if os.name == "nt": |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
40055
diff
changeset
|
205 inc_dir = os.path.join(project_base, "PC") |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
40055
diff
changeset
|
206 else: |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
40055
diff
changeset
|
207 inc_dir = project_base |
|
18945
f8fdd5083af3
Miscellaneous minor cleanups.
Fred Drake <fdrake@acm.org>
parents:
18837
diff
changeset
|
208 else: |
|
f8fdd5083af3
Miscellaneous minor cleanups.
Fred Drake <fdrake@acm.org>
parents:
18837
diff
changeset
|
209 inc_dir = get_python_inc(plat_specific=1) |
|
34661
9fa768a98c5c
Patch #1046831: Use get_python_version where appropriate in sysconfig.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
34258
diff
changeset
|
210 if get_python_version() < '2.2': |
|
18837
5e0a40ccb9da
Add backwards compatibility.
Marc-André Lemburg <mal@egenix.com>
parents:
18835
diff
changeset
|
211 config_h = 'config.h' |
|
5e0a40ccb9da
Add backwards compatibility.
Marc-André Lemburg <mal@egenix.com>
parents:
18835
diff
changeset
|
212 else: |
|
5e0a40ccb9da
Add backwards compatibility.
Marc-André Lemburg <mal@egenix.com>
parents:
18835
diff
changeset
|
213 # The name of the config.h file changed in 2.2 |
|
5e0a40ccb9da
Add backwards compatibility.
Marc-André Lemburg <mal@egenix.com>
parents:
18835
diff
changeset
|
214 config_h = 'pyconfig.h' |
|
5e0a40ccb9da
Add backwards compatibility.
Marc-André Lemburg <mal@egenix.com>
parents:
18835
diff
changeset
|
215 return os.path.join(inc_dir, config_h) |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
216 |
| 9658 | 217 |
|
9780
4b18f8eaa16b
Another patch from Fred: factored _init_posix into
Greg Ward <gward@python.net>
parents:
9690
diff
changeset
|
218 def get_makefile_filename(): |
| 9783 | 219 """Return full pathname of installed Makefile from the Python build.""" |
|
15937
d9d0dcb735d7
Patch #103279: sysconfig.py always looks for versions of files in
Andrew M. Kuchling <amk@amk.ca>
parents:
15923
diff
changeset
|
220 if python_build: |
|
23659
5c5fff5de250
When using a Python that has not been installed to build 3rd-party
Fred Drake <fdrake@acm.org>
parents:
21851
diff
changeset
|
221 return os.path.join(os.path.dirname(sys.executable), "Makefile") |
|
11953
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
222 lib_dir = get_python_lib(plat_specific=1, standard_lib=1) |
|
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
223 return os.path.join(lib_dir, "config", "Makefile") |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
224 |
| 9658 | 225 |
|
9780
4b18f8eaa16b
Another patch from Fred: factored _init_posix into
Greg Ward <gward@python.net>
parents:
9690
diff
changeset
|
226 def parse_config_h(fp, g=None): |
|
11953
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
227 """Parse a config.h-style file. |
|
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
228 |
|
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
229 A dictionary containing name/value pairs is returned. If an |
|
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
230 optional dictionary is passed in as the second argument, it is |
|
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
231 used instead of a new dictionary. |
| 9783 | 232 """ |
|
9780
4b18f8eaa16b
Another patch from Fred: factored _init_posix into
Greg Ward <gward@python.net>
parents:
9690
diff
changeset
|
233 if g is None: |
|
4b18f8eaa16b
Another patch from Fred: factored _init_posix into
Greg Ward <gward@python.net>
parents:
9690
diff
changeset
|
234 g = {} |
|
37561
bd375777932d
Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents:
37007
diff
changeset
|
235 define_rx = re.compile("#define ([A-Z][A-Za-z0-9_]+) (.*)\n") |
|
bd375777932d
Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents:
37007
diff
changeset
|
236 undef_rx = re.compile("/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/\n") |
|
9780
4b18f8eaa16b
Another patch from Fred: factored _init_posix into
Greg Ward <gward@python.net>
parents:
9690
diff
changeset
|
237 # |
| 9658 | 238 while 1: |
| 239 line = fp.readline() | |
| 240 if not line: | |
| 241 break | |
| 242 m = define_rx.match(line) | |
| 243 if m: | |
| 244 n, v = m.group(1, 2) | |
|
26048
b4a6283b915b
Remove use of string module and reflow a couple of long lines.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
26036
diff
changeset
|
245 try: v = int(v) |
|
9690
31489799c8c6
Applied Fred's patch to fix the bugs that John Skaller noticed.
Greg Ward <gward@python.net>
parents:
9658
diff
changeset
|
246 except ValueError: pass |
|
31489799c8c6
Applied Fred's patch to fix the bugs that John Skaller noticed.
Greg Ward <gward@python.net>
parents:
9658
diff
changeset
|
247 g[n] = v |
| 9658 | 248 else: |
| 249 m = undef_rx.match(line) | |
| 250 if m: | |
| 251 g[m.group(1)] = 0 | |
|
9780
4b18f8eaa16b
Another patch from Fred: factored _init_posix into
Greg Ward <gward@python.net>
parents:
9690
diff
changeset
|
252 return g |
| 9658 | 253 |
|
14651
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
254 |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
255 # Regexes needed for parsing Makefile (and similar syntaxes, |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
256 # like old-style Setup files). |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
257 _variable_rx = re.compile("([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)") |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
258 _findvar1_rx = re.compile(r"\$\(([A-Za-z][A-Za-z0-9_]*)\)") |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
259 _findvar2_rx = re.compile(r"\${([A-Za-z][A-Za-z0-9_]*)}") |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
260 |
|
14571
600515747c51
Fixed so 'parse_makefile()' uses the TextFile class to ensure that
Greg Ward <gward@python.net>
parents:
14321
diff
changeset
|
261 def parse_makefile(fn, g=None): |
|
11953
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
262 """Parse a Makefile-style file. |
|
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
263 |
|
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
264 A dictionary containing name/value pairs is returned. If an |
|
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
265 optional dictionary is passed in as the second argument, it is |
|
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
266 used instead of a new dictionary. |
| 9783 | 267 """ |
|
14571
600515747c51
Fixed so 'parse_makefile()' uses the TextFile class to ensure that
Greg Ward <gward@python.net>
parents:
14321
diff
changeset
|
268 from distutils.text_file import TextFile |
|
14651
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
269 fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1) |
|
14571
600515747c51
Fixed so 'parse_makefile()' uses the TextFile class to ensure that
Greg Ward <gward@python.net>
parents:
14321
diff
changeset
|
270 |
|
9780
4b18f8eaa16b
Another patch from Fred: factored _init_posix into
Greg Ward <gward@python.net>
parents:
9690
diff
changeset
|
271 if g is None: |
|
4b18f8eaa16b
Another patch from Fred: factored _init_posix into
Greg Ward <gward@python.net>
parents:
9690
diff
changeset
|
272 g = {} |
| 9658 | 273 done = {} |
| 274 notdone = {} | |
|
14571
600515747c51
Fixed so 'parse_makefile()' uses the TextFile class to ensure that
Greg Ward <gward@python.net>
parents:
14321
diff
changeset
|
275 |
| 9658 | 276 while 1: |
| 277 line = fp.readline() | |
|
54669
0adf0fa7993b
Merged revisions 73341 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51505
diff
changeset
|
278 if line is None: # eof |
| 9658 | 279 break |
|
14651
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
280 m = _variable_rx.match(line) |
| 9658 | 281 if m: |
| 282 n, v = m.group(1, 2) | |
|
54669
0adf0fa7993b
Merged revisions 73341 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51505
diff
changeset
|
283 v = v.strip() |
|
0adf0fa7993b
Merged revisions 73341 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51505
diff
changeset
|
284 # `$$' is a literal `$' in make |
|
0adf0fa7993b
Merged revisions 73341 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51505
diff
changeset
|
285 tmpv = v.replace('$$', '') |
|
0adf0fa7993b
Merged revisions 73341 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51505
diff
changeset
|
286 |
|
0adf0fa7993b
Merged revisions 73341 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51505
diff
changeset
|
287 if "$" in tmpv: |
| 9658 | 288 notdone[n] = v |
| 289 else: | |
|
54669
0adf0fa7993b
Merged revisions 73341 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51505
diff
changeset
|
290 try: |
|
0adf0fa7993b
Merged revisions 73341 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51505
diff
changeset
|
291 v = int(v) |
|
0adf0fa7993b
Merged revisions 73341 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51505
diff
changeset
|
292 except ValueError: |
|
0adf0fa7993b
Merged revisions 73341 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51505
diff
changeset
|
293 # insert literal `$' |
|
0adf0fa7993b
Merged revisions 73341 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51505
diff
changeset
|
294 done[n] = v.replace('$$', '$') |
|
0adf0fa7993b
Merged revisions 73341 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51505
diff
changeset
|
295 else: |
|
0adf0fa7993b
Merged revisions 73341 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51505
diff
changeset
|
296 done[n] = v |
| 9658 | 297 |
| 298 # do variable interpolation here | |
| 299 while notdone: | |
| 300 for name in notdone.keys(): | |
| 301 value = notdone[name] | |
|
14651
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
302 m = _findvar1_rx.search(value) or _findvar2_rx.search(value) |
| 9658 | 303 if m: |
| 304 n = m.group(1) | |
|
34930
294dabcb379b
Make parse_makefile fallback to environment variables if nothing is
Martin v. Löwis <martin@v.loewis.de>
parents:
34929
diff
changeset
|
305 found = True |
|
45413
8a187f562959
Removed uses of dict.has_key() from distutils, and uses of
Guido van Rossum <guido@python.org>
parents:
45168
diff
changeset
|
306 if n in done: |
|
34930
294dabcb379b
Make parse_makefile fallback to environment variables if nothing is
Martin v. Löwis <martin@v.loewis.de>
parents:
34929
diff
changeset
|
307 item = str(done[n]) |
|
45413
8a187f562959
Removed uses of dict.has_key() from distutils, and uses of
Guido van Rossum <guido@python.org>
parents:
45168
diff
changeset
|
308 elif n in notdone: |
| 9658 | 309 # get it on a subsequent round |
|
34930
294dabcb379b
Make parse_makefile fallback to environment variables if nothing is
Martin v. Löwis <martin@v.loewis.de>
parents:
34929
diff
changeset
|
310 found = False |
|
45413
8a187f562959
Removed uses of dict.has_key() from distutils, and uses of
Guido van Rossum <guido@python.org>
parents:
45168
diff
changeset
|
311 elif n in os.environ: |
|
34930
294dabcb379b
Make parse_makefile fallback to environment variables if nothing is
Martin v. Löwis <martin@v.loewis.de>
parents:
34929
diff
changeset
|
312 # do it like make: fall back to environment |
|
294dabcb379b
Make parse_makefile fallback to environment variables if nothing is
Martin v. Löwis <martin@v.loewis.de>
parents:
34929
diff
changeset
|
313 item = os.environ[n] |
| 9658 | 314 else: |
|
34930
294dabcb379b
Make parse_makefile fallback to environment variables if nothing is
Martin v. Löwis <martin@v.loewis.de>
parents:
34929
diff
changeset
|
315 done[n] = item = "" |
|
294dabcb379b
Make parse_makefile fallback to environment variables if nothing is
Martin v. Löwis <martin@v.loewis.de>
parents:
34929
diff
changeset
|
316 if found: |
| 9658 | 317 after = value[m.end():] |
|
34930
294dabcb379b
Make parse_makefile fallback to environment variables if nothing is
Martin v. Löwis <martin@v.loewis.de>
parents:
34929
diff
changeset
|
318 value = value[:m.start()] + item + after |
| 9658 | 319 if "$" in after: |
| 320 notdone[name] = value | |
| 321 else: | |
|
26048
b4a6283b915b
Remove use of string module and reflow a couple of long lines.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
26036
diff
changeset
|
322 try: value = int(value) |
|
15923
ff6c30e8ca73
Fix bugs with integer-valued variables when parsing Makefiles. Values
Andrew M. Kuchling <amk@amk.ca>
parents:
15818
diff
changeset
|
323 except ValueError: |
|
54669
0adf0fa7993b
Merged revisions 73341 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51505
diff
changeset
|
324 done[name] = value.strip() |
|
15923
ff6c30e8ca73
Fix bugs with integer-valued variables when parsing Makefiles. Values
Andrew M. Kuchling <amk@amk.ca>
parents:
15818
diff
changeset
|
325 else: |
|
ff6c30e8ca73
Fix bugs with integer-valued variables when parsing Makefiles. Values
Andrew M. Kuchling <amk@amk.ca>
parents:
15818
diff
changeset
|
326 done[name] = value |
| 9658 | 327 del notdone[name] |
| 328 else: | |
|
9690
31489799c8c6
Applied Fred's patch to fix the bugs that John Skaller noticed.
Greg Ward <gward@python.net>
parents:
9658
diff
changeset
|
329 # bogus variable reference; just drop it since we can't deal |
| 9658 | 330 del notdone[name] |
| 331 | |
|
14651
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
332 fp.close() |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
333 |
| 9658 | 334 # save the results in the global dictionary |
| 335 g.update(done) | |
|
9780
4b18f8eaa16b
Another patch from Fred: factored _init_posix into
Greg Ward <gward@python.net>
parents:
9690
diff
changeset
|
336 return g |
|
4b18f8eaa16b
Another patch from Fred: factored _init_posix into
Greg Ward <gward@python.net>
parents:
9690
diff
changeset
|
337 |
|
4b18f8eaa16b
Another patch from Fred: factored _init_posix into
Greg Ward <gward@python.net>
parents:
9690
diff
changeset
|
338 |
|
14651
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
339 def expand_makefile_vars(s, vars): |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
340 """Expand Makefile-style variables -- "${foo}" or "$(foo)" -- in |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
341 'string' according to 'vars' (a dictionary mapping variable names to |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
342 values). Variables not present in 'vars' are silently expanded to the |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
343 empty string. The variable values in 'vars' should not contain further |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
344 variable expansions; if 'vars' is the output of 'parse_makefile()', |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
345 you're fine. Returns a variable-expanded version of 's'. |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
346 """ |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
347 |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
348 # This algorithm does multiple expansion, so if vars['foo'] contains |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
349 # "${bar}", it will expand ${foo} to ${bar}, and then expand |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
350 # ${bar}... and so forth. This is fine as long as 'vars' comes from |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
351 # 'parse_makefile()', which takes care of such expansions eagerly, |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
352 # according to make's variable expansion semantics. |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
353 |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
354 while 1: |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
355 m = _findvar1_rx.search(s) or _findvar2_rx.search(s) |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
356 if m: |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
357 (beg, end) = m.span() |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
358 s = s[0:beg] + vars.get(m.group(1)) + s[end:] |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
359 else: |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
360 break |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
361 return s |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
362 |
|
7fc4569d9625
Added 'expand_makefile_vars()' to (duh) expand make-style variables
Greg Ward <gward@python.net>
parents:
14572
diff
changeset
|
363 |
|
14572
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
364 _config_vars = None |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
365 |
|
9780
4b18f8eaa16b
Another patch from Fred: factored _init_posix into
Greg Ward <gward@python.net>
parents:
9690
diff
changeset
|
366 def _init_posix(): |
| 9783 | 367 """Initialize the module as appropriate for POSIX systems.""" |
|
14572
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
368 g = {} |
| 11689 | 369 # load the installed Makefile: |
|
12740
89f42099c5dd
Catch failure to open installed Makefile, and report it as a
Greg Ward <gward@python.net>
parents:
12414
diff
changeset
|
370 try: |
|
89f42099c5dd
Catch failure to open installed Makefile, and report it as a
Greg Ward <gward@python.net>
parents:
12414
diff
changeset
|
371 filename = get_makefile_filename() |
|
14571
600515747c51
Fixed so 'parse_makefile()' uses the TextFile class to ensure that
Greg Ward <gward@python.net>
parents:
14321
diff
changeset
|
372 parse_makefile(filename, g) |
|
12740
89f42099c5dd
Catch failure to open installed Makefile, and report it as a
Greg Ward <gward@python.net>
parents:
12414
diff
changeset
|
373 except IOError, msg: |
|
89f42099c5dd
Catch failure to open installed Makefile, and report it as a
Greg Ward <gward@python.net>
parents:
12414
diff
changeset
|
374 my_msg = "invalid Python installation: unable to open %s" % filename |
|
89f42099c5dd
Catch failure to open installed Makefile, and report it as a
Greg Ward <gward@python.net>
parents:
12414
diff
changeset
|
375 if hasattr(msg, "strerror"): |
|
89f42099c5dd
Catch failure to open installed Makefile, and report it as a
Greg Ward <gward@python.net>
parents:
12414
diff
changeset
|
376 my_msg = my_msg + " (%s)" % msg.strerror |
|
89f42099c5dd
Catch failure to open installed Makefile, and report it as a
Greg Ward <gward@python.net>
parents:
12414
diff
changeset
|
377 |
|
18696
1c2da78b839b
Minor changes for stylistic cleanliness and consistency.
Fred Drake <fdrake@acm.org>
parents:
17847
diff
changeset
|
378 raise DistutilsPlatformError(my_msg) |
|
18945
f8fdd5083af3
Miscellaneous minor cleanups.
Fred Drake <fdrake@acm.org>
parents:
18837
diff
changeset
|
379 |
|
37561
bd375777932d
Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents:
37007
diff
changeset
|
380 # load the installed pyconfig.h: |
|
bd375777932d
Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents:
37007
diff
changeset
|
381 try: |
|
bd375777932d
Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents:
37007
diff
changeset
|
382 filename = get_config_h_filename() |
|
bd375777932d
Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents:
37007
diff
changeset
|
383 parse_config_h(file(filename), g) |
|
bd375777932d
Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents:
37007
diff
changeset
|
384 except IOError, msg: |
|
bd375777932d
Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents:
37007
diff
changeset
|
385 my_msg = "invalid Python installation: unable to open %s" % filename |
|
bd375777932d
Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents:
37007
diff
changeset
|
386 if hasattr(msg, "strerror"): |
|
bd375777932d
Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents:
37007
diff
changeset
|
387 my_msg = my_msg + " (%s)" % msg.strerror |
|
bd375777932d
Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents:
37007
diff
changeset
|
388 |
|
bd375777932d
Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents:
37007
diff
changeset
|
389 raise DistutilsPlatformError(my_msg) |
|
bd375777932d
Patch #1429775: Link Python modules to libpython on linux if
Martin v. Löwis <martin@v.loewis.de>
parents:
37007
diff
changeset
|
390 |
|
32218
fdf75eef6a5c
Partial fix for #887242 (link extensions with dynamic_lookup in stead
Jack Jansen <jack.jansen@cwi.nl>
parents:
30772
diff
changeset
|
391 # On MacOSX we need to check the setting of the environment variable |
|
fdf75eef6a5c
Partial fix for #887242 (link extensions with dynamic_lookup in stead
Jack Jansen <jack.jansen@cwi.nl>
parents:
30772
diff
changeset
|
392 # MACOSX_DEPLOYMENT_TARGET: configure bases some choices on it so |
|
fdf75eef6a5c
Partial fix for #887242 (link extensions with dynamic_lookup in stead
Jack Jansen <jack.jansen@cwi.nl>
parents:
30772
diff
changeset
|
393 # it needs to be compatible. |
|
34258
646195b59205
After discussion on the PythonMac-SIG it was decided that it is better
Jack Jansen <jack.jansen@cwi.nl>
parents:
33750
diff
changeset
|
394 # If it isn't set we set it to the configure-time value |
|
45413
8a187f562959
Removed uses of dict.has_key() from distutils, and uses of
Guido van Rossum <guido@python.org>
parents:
45168
diff
changeset
|
395 if sys.platform == 'darwin' and 'MACOSX_DEPLOYMENT_TARGET' in g: |
|
38040
36c7a4422e30
Patch 1471883: --enable-universalsdk on Mac OS X
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
37801
diff
changeset
|
396 cfg_target = g['MACOSX_DEPLOYMENT_TARGET'] |
|
32218
fdf75eef6a5c
Partial fix for #887242 (link extensions with dynamic_lookup in stead
Jack Jansen <jack.jansen@cwi.nl>
parents:
30772
diff
changeset
|
397 cur_target = os.getenv('MACOSX_DEPLOYMENT_TARGET', '') |
|
34258
646195b59205
After discussion on the PythonMac-SIG it was decided that it is better
Jack Jansen <jack.jansen@cwi.nl>
parents:
33750
diff
changeset
|
398 if cur_target == '': |
|
646195b59205
After discussion on the PythonMac-SIG it was decided that it is better
Jack Jansen <jack.jansen@cwi.nl>
parents:
33750
diff
changeset
|
399 cur_target = cfg_target |
|
646195b59205
After discussion on the PythonMac-SIG it was decided that it is better
Jack Jansen <jack.jansen@cwi.nl>
parents:
33750
diff
changeset
|
400 os.putenv('MACOSX_DEPLOYMENT_TARGET', cfg_target) |
|
37801
4d82093e2e19
disutils checks if MACOSX_DEPLOYMENT_TARGET is consistent with the value at
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
37788
diff
changeset
|
401 elif map(int, cfg_target.split('.')) > map(int, cur_target.split('.')): |
|
32218
fdf75eef6a5c
Partial fix for #887242 (link extensions with dynamic_lookup in stead
Jack Jansen <jack.jansen@cwi.nl>
parents:
30772
diff
changeset
|
402 my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: now "%s" but "%s" during configure' |
|
fdf75eef6a5c
Partial fix for #887242 (link extensions with dynamic_lookup in stead
Jack Jansen <jack.jansen@cwi.nl>
parents:
30772
diff
changeset
|
403 % (cur_target, cfg_target)) |
|
fdf75eef6a5c
Partial fix for #887242 (link extensions with dynamic_lookup in stead
Jack Jansen <jack.jansen@cwi.nl>
parents:
30772
diff
changeset
|
404 raise DistutilsPlatformError(my_msg) |
|
32736
c3a096bfbd6b
Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents:
32218
diff
changeset
|
405 |
|
13034
f1e40abbedb3
Fixed LDSHARED for AIX, based on a patch by Rene Liebscher.
Greg Ward <gward@python.net>
parents:
13009
diff
changeset
|
406 # On AIX, there are wrong paths to the linker scripts in the Makefile |
|
f1e40abbedb3
Fixed LDSHARED for AIX, based on a patch by Rene Liebscher.
Greg Ward <gward@python.net>
parents:
13009
diff
changeset
|
407 # -- these paths are relative to the Python source, but when installed |
|
f1e40abbedb3
Fixed LDSHARED for AIX, based on a patch by Rene Liebscher.
Greg Ward <gward@python.net>
parents:
13009
diff
changeset
|
408 # the scripts are in another directory. |
|
16621
c958678720fd
Linking just got simpiler on AIX and BeOS (closes SF patch #103679).
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
16224
diff
changeset
|
409 if python_build: |
| 16841 | 410 g['LDSHARED'] = g['BLDSHARED'] |
| 21267 | 411 |
|
34661
9fa768a98c5c
Patch #1046831: Use get_python_version where appropriate in sysconfig.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
34258
diff
changeset
|
412 elif get_python_version() < '2.1': |
|
19724
ba9aabcd89e3
[Bug #404274] Restore some special-case code for AIX and BeOS under 1.5.2.
Andrew M. Kuchling <amk@amk.ca>
parents:
19681
diff
changeset
|
413 # The following two branches are for 1.5.2 compatibility. |
|
ba9aabcd89e3
[Bug #404274] Restore some special-case code for AIX and BeOS under 1.5.2.
Andrew M. Kuchling <amk@amk.ca>
parents:
19681
diff
changeset
|
414 if sys.platform == 'aix4': # what about AIX 3.x ? |
|
ba9aabcd89e3
[Bug #404274] Restore some special-case code for AIX and BeOS under 1.5.2.
Andrew M. Kuchling <amk@amk.ca>
parents:
19681
diff
changeset
|
415 # Linker script is in the config directory, not in Modules as the |
|
ba9aabcd89e3
[Bug #404274] Restore some special-case code for AIX and BeOS under 1.5.2.
Andrew M. Kuchling <amk@amk.ca>
parents:
19681
diff
changeset
|
416 # Makefile says. |
|
ba9aabcd89e3
[Bug #404274] Restore some special-case code for AIX and BeOS under 1.5.2.
Andrew M. Kuchling <amk@amk.ca>
parents:
19681
diff
changeset
|
417 python_lib = get_python_lib(standard_lib=1) |
|
ba9aabcd89e3
[Bug #404274] Restore some special-case code for AIX and BeOS under 1.5.2.
Andrew M. Kuchling <amk@amk.ca>
parents:
19681
diff
changeset
|
418 ld_so_aix = os.path.join(python_lib, 'config', 'ld_so_aix') |
|
ba9aabcd89e3
[Bug #404274] Restore some special-case code for AIX and BeOS under 1.5.2.
Andrew M. Kuchling <amk@amk.ca>
parents:
19681
diff
changeset
|
419 python_exp = os.path.join(python_lib, 'config', 'python.exp') |
|
14572
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
420 |
|
19724
ba9aabcd89e3
[Bug #404274] Restore some special-case code for AIX and BeOS under 1.5.2.
Andrew M. Kuchling <amk@amk.ca>
parents:
19681
diff
changeset
|
421 g['LDSHARED'] = "%s %s -bI:%s" % (ld_so_aix, g['CC'], python_exp) |
|
ba9aabcd89e3
[Bug #404274] Restore some special-case code for AIX and BeOS under 1.5.2.
Andrew M. Kuchling <amk@amk.ca>
parents:
19681
diff
changeset
|
422 |
|
ba9aabcd89e3
[Bug #404274] Restore some special-case code for AIX and BeOS under 1.5.2.
Andrew M. Kuchling <amk@amk.ca>
parents:
19681
diff
changeset
|
423 elif sys.platform == 'beos': |
|
ba9aabcd89e3
[Bug #404274] Restore some special-case code for AIX and BeOS under 1.5.2.
Andrew M. Kuchling <amk@amk.ca>
parents:
19681
diff
changeset
|
424 # Linker script is in the config directory. In the Makefile it is |
|
ba9aabcd89e3
[Bug #404274] Restore some special-case code for AIX and BeOS under 1.5.2.
Andrew M. Kuchling <amk@amk.ca>
parents:
19681
diff
changeset
|
425 # relative to the srcdir, which after installation no longer makes |
|
ba9aabcd89e3
[Bug #404274] Restore some special-case code for AIX and BeOS under 1.5.2.
Andrew M. Kuchling <amk@amk.ca>
parents:
19681
diff
changeset
|
426 # sense. |
|
ba9aabcd89e3
[Bug #404274] Restore some special-case code for AIX and BeOS under 1.5.2.
Andrew M. Kuchling <amk@amk.ca>
parents:
19681
diff
changeset
|
427 python_lib = get_python_lib(standard_lib=1) |
|
26186
af3964679e2f
Back out part of rev. 1.53, restoring the use of the string module.
Andrew M. Kuchling <amk@amk.ca>
parents:
26048
diff
changeset
|
428 linkerscript_path = string.split(g['LDSHARED'])[0] |
|
af3964679e2f
Back out part of rev. 1.53, restoring the use of the string module.
Andrew M. Kuchling <amk@amk.ca>
parents:
26048
diff
changeset
|
429 linkerscript_name = os.path.basename(linkerscript_path) |
|
26048
b4a6283b915b
Remove use of string module and reflow a couple of long lines.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
26036
diff
changeset
|
430 linkerscript = os.path.join(python_lib, 'config', |
|
b4a6283b915b
Remove use of string module and reflow a couple of long lines.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
26036
diff
changeset
|
431 linkerscript_name) |
| 21267 | 432 |
|
19724
ba9aabcd89e3
[Bug #404274] Restore some special-case code for AIX and BeOS under 1.5.2.
Andrew M. Kuchling <amk@amk.ca>
parents:
19681
diff
changeset
|
433 # XXX this isn't the right place to do this: adding the Python |
|
ba9aabcd89e3
[Bug #404274] Restore some special-case code for AIX and BeOS under 1.5.2.
Andrew M. Kuchling <amk@amk.ca>
parents:
19681
diff
changeset
|
434 # library to the link, if needed, should be in the "build_ext" |
|
ba9aabcd89e3
[Bug #404274] Restore some special-case code for AIX and BeOS under 1.5.2.
Andrew M. Kuchling <amk@amk.ca>
parents:
19681
diff
changeset
|
435 # command. (It's also needed for non-MS compilers on Windows, and |
|
ba9aabcd89e3
[Bug #404274] Restore some special-case code for AIX and BeOS under 1.5.2.
Andrew M. Kuchling <amk@amk.ca>
parents:
19681
diff
changeset
|
436 # it's taken care of for them by the 'build_ext.get_libraries()' |
|
ba9aabcd89e3
[Bug #404274] Restore some special-case code for AIX and BeOS under 1.5.2.
Andrew M. Kuchling <amk@amk.ca>
parents:
19681
diff
changeset
|
437 # method.) |
|
ba9aabcd89e3
[Bug #404274] Restore some special-case code for AIX and BeOS under 1.5.2.
Andrew M. Kuchling <amk@amk.ca>
parents:
19681
diff
changeset
|
438 g['LDSHARED'] = ("%s -L%s/lib -lpython%s" % |
|
34661
9fa768a98c5c
Patch #1046831: Use get_python_version where appropriate in sysconfig.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
34258
diff
changeset
|
439 (linkerscript, PREFIX, get_python_version())) |
| 21267 | 440 |
|
14572
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
441 global _config_vars |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
442 _config_vars = g |
|
14321
ada4ec4cffd5
Rene Liebscher: hack '_init_posix()' to handle the BeOS linker script.
Greg Ward <gward@python.net>
parents:
13811
diff
changeset
|
443 |
| 9658 | 444 |
|
10926
f9c03b3d0f14
Now handles NT, through '_init_nt()' function (courtesy of
Greg Ward <gward@python.net>
parents:
9842
diff
changeset
|
445 def _init_nt(): |
|
f9c03b3d0f14
Now handles NT, through '_init_nt()' function (courtesy of
Greg Ward <gward@python.net>
parents:
9842
diff
changeset
|
446 """Initialize the module as appropriate for NT""" |
|
14572
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
447 g = {} |
|
10926
f9c03b3d0f14
Now handles NT, through '_init_nt()' function (courtesy of
Greg Ward <gward@python.net>
parents:
9842
diff
changeset
|
448 # set basic install directories |
|
11953
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
449 g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1) |
|
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
450 g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1) |
|
10926
f9c03b3d0f14
Now handles NT, through '_init_nt()' function (courtesy of
Greg Ward <gward@python.net>
parents:
9842
diff
changeset
|
451 |
|
11251
2f07bc56e97e
Patch from Perry Stoll: tweaks to Windows support.
Greg Ward <gward@python.net>
parents:
10926
diff
changeset
|
452 # XXX hmmm.. a normal install puts include files here |
|
11953
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
453 g['INCLUDEPY'] = get_python_inc(plat_specific=0) |
|
11251
2f07bc56e97e
Patch from Perry Stoll: tweaks to Windows support.
Greg Ward <gward@python.net>
parents:
10926
diff
changeset
|
454 |
|
11721
eb381ff17a31
get_config_h_filename(): Support NT as well as Posix systems.
Fred Drake <fdrake@acm.org>
parents:
11689
diff
changeset
|
455 g['SO'] = '.pyd' |
|
13804
c77f8873da84
Rene Liebscher: deleted unneeded hard-coded assignments of CC, RANLIB, etc.
Greg Ward <gward@python.net>
parents:
13035
diff
changeset
|
456 g['EXE'] = ".exe" |
|
44198
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
40055
diff
changeset
|
457 g['VERSION'] = get_python_version().replace(".", "") |
|
a53ef778590e
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Christian Heimes <christian@cheimes.de>
parents:
40055
diff
changeset
|
458 g['BINDIR'] = os.path.dirname(os.path.abspath(sys.executable)) |
|
14572
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
459 |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
460 global _config_vars |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
461 _config_vars = g |
|
9780
4b18f8eaa16b
Another patch from Fred: factored _init_posix into
Greg Ward <gward@python.net>
parents:
9690
diff
changeset
|
462 |
|
11721
eb381ff17a31
get_config_h_filename(): Support NT as well as Posix systems.
Fred Drake <fdrake@acm.org>
parents:
11689
diff
changeset
|
463 |
|
11935
c94572a50995
Patch from Corran Webster <cwebster@nevada.edu>: add '_init_mac()'.
Greg Ward <gward@python.net>
parents:
11721
diff
changeset
|
464 def _init_mac(): |
|
c94572a50995
Patch from Corran Webster <cwebster@nevada.edu>: add '_init_mac()'.
Greg Ward <gward@python.net>
parents:
11721
diff
changeset
|
465 """Initialize the module as appropriate for Macintosh systems""" |
|
14572
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
466 g = {} |
|
11935
c94572a50995
Patch from Corran Webster <cwebster@nevada.edu>: add '_init_mac()'.
Greg Ward <gward@python.net>
parents:
11721
diff
changeset
|
467 # set basic install directories |
|
11953
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
468 g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1) |
|
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
469 g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1) |
|
11935
c94572a50995
Patch from Corran Webster <cwebster@nevada.edu>: add '_init_mac()'.
Greg Ward <gward@python.net>
parents:
11721
diff
changeset
|
470 |
|
c94572a50995
Patch from Corran Webster <cwebster@nevada.edu>: add '_init_mac()'.
Greg Ward <gward@python.net>
parents:
11721
diff
changeset
|
471 # XXX hmmm.. a normal install puts include files here |
|
11953
f9db3654a1fd
There are a few places which can raise DistutilsPlatformError; make
Fred Drake <fdrake@acm.org>
parents:
11952
diff
changeset
|
472 g['INCLUDEPY'] = get_python_inc(plat_specific=0) |
|
11935
c94572a50995
Patch from Corran Webster <cwebster@nevada.edu>: add '_init_mac()'.
Greg Ward <gward@python.net>
parents:
11721
diff
changeset
|
473 |
|
17846
9ff35f7661bd
Made distutils understand the MacPython Carbon runtime model. Distutils will build for the runtime model you are currently using for the interpreter.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16841
diff
changeset
|
474 import MacOS |
|
9ff35f7661bd
Made distutils understand the MacPython Carbon runtime model. Distutils will build for the runtime model you are currently using for the interpreter.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16841
diff
changeset
|
475 if not hasattr(MacOS, 'runtimemodel'): |
|
17847
7f4554a1cae2
Fixed botched indent in _init_mac() code. (It may never be executed,
Guido van Rossum <guido@python.org>
parents:
17846
diff
changeset
|
476 g['SO'] = '.ppc.slb' |
|
17846
9ff35f7661bd
Made distutils understand the MacPython Carbon runtime model. Distutils will build for the runtime model you are currently using for the interpreter.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16841
diff
changeset
|
477 else: |
|
9ff35f7661bd
Made distutils understand the MacPython Carbon runtime model. Distutils will build for the runtime model you are currently using for the interpreter.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16841
diff
changeset
|
478 g['SO'] = '.%s.slb' % MacOS.runtimemodel |
|
11952
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
479 |
|
e10515e7d356
Added Joe Van Andel's 'get_python_inc()', adapted by me to supply
Greg Ward <gward@python.net>
parents:
11935
diff
changeset
|
480 # XXX are these used anywhere? |
|
12315
f1f665e075ca
Better variable names here and there.
Greg Ward <gward@python.net>
parents:
11953
diff
changeset
|
481 g['install_lib'] = os.path.join(EXEC_PREFIX, "Lib") |
|
f1f665e075ca
Better variable names here and there.
Greg Ward <gward@python.net>
parents:
11953
diff
changeset
|
482 g['install_platlib'] = os.path.join(EXEC_PREFIX, "Mac", "Lib") |
|
11935
c94572a50995
Patch from Corran Webster <cwebster@nevada.edu>: add '_init_mac()'.
Greg Ward <gward@python.net>
parents:
11721
diff
changeset
|
483 |
|
24007
00e578f78caa
Fixed various MacPython-specific issues found by attempting to use the standard core setup.py for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
23671
diff
changeset
|
484 # These are used by the extension module build |
|
00e578f78caa
Fixed various MacPython-specific issues found by attempting to use the standard core setup.py for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
23671
diff
changeset
|
485 g['srcdir'] = ':' |
|
14572
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
486 global _config_vars |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
487 _config_vars = g |
|
9780
4b18f8eaa16b
Another patch from Fred: factored _init_posix into
Greg Ward <gward@python.net>
parents:
9690
diff
changeset
|
488 |
|
11721
eb381ff17a31
get_config_h_filename(): Support NT as well as Posix systems.
Fred Drake <fdrake@acm.org>
parents:
11689
diff
changeset
|
489 |
|
21851
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
490 def _init_os2(): |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
491 """Initialize the module as appropriate for OS/2""" |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
492 g = {} |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
493 # set basic install directories |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
494 g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1) |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
495 g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1) |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
496 |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
497 # XXX hmmm.. a normal install puts include files here |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
498 g['INCLUDEPY'] = get_python_inc(plat_specific=0) |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
499 |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
500 g['SO'] = '.pyd' |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
501 g['EXE'] = ".exe" |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
502 |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
503 global _config_vars |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
504 _config_vars = g |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
505 |
|
e0fc286d57a4
OS/2 patches by Andrew I MacIntyre for distutils.
Marc-André Lemburg <mal@egenix.com>
parents:
21267
diff
changeset
|
506 |
|
14572
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
507 def get_config_vars(*args): |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
508 """With no arguments, return a dictionary of all configuration |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
509 variables relevant for the current platform. Generally this includes |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
510 everything needed to build extensions and install both pure modules and |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
511 extensions. On Unix, this means every variable defined in Python's |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
512 installed Makefile; on Windows and Mac OS it's a much smaller set. |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
513 |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
514 With arguments, return a list of values that result from looking up |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
515 each argument in the configuration variable dictionary. |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
516 """ |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
517 global _config_vars |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
518 if _config_vars is None: |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
519 func = globals().get("_init_" + os.name) |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
520 if func: |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
521 func() |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
522 else: |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
523 _config_vars = {} |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
524 |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
525 # Normalized versions of prefix and exec_prefix are handy to have; |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
526 # in fact, these are the standard versions used most places in the |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
527 # Distutils. |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
528 _config_vars['prefix'] = PREFIX |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
529 _config_vars['exec_prefix'] = EXEC_PREFIX |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
530 |
| 38248 | 531 if sys.platform == 'darwin': |
| 532 kernel_version = os.uname()[2] # Kernel version (8.4.3) | |
| 533 major_version = int(kernel_version.split('.')[0]) | |
| 534 | |
| 535 if major_version < 8: | |
| 536 # On Mac OS X before 10.4, check if -arch and -isysroot | |
| 537 # are in CFLAGS or LDFLAGS and remove them if they are. | |
| 538 # This is needed when building extensions on a 10.3 system | |
| 539 # using a universal build of python. | |
|
57637
b27d946389e7
Merged revisions 76738 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
56187
diff
changeset
|
540 for key in ('LDFLAGS', 'BASECFLAGS', 'LDSHARED', |
|
40055
83965977f34a
MacOSX: distutils changes the values of BASECFLAGS and LDFLAGS when using a
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38944
diff
changeset
|
541 # a number of derived variables. These need to be |
|
83965977f34a
MacOSX: distutils changes the values of BASECFLAGS and LDFLAGS when using a
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38944
diff
changeset
|
542 # patched up as well. |
|
83965977f34a
MacOSX: distutils changes the values of BASECFLAGS and LDFLAGS when using a
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38944
diff
changeset
|
543 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'): |
| 38248 | 544 flags = _config_vars[key] |
| 545 flags = re.sub('-arch\s+\w+\s', ' ', flags) | |
|
38944
0602771b8b49
MacOSX: fix rather dumb buglet that made it impossible to create extensions on
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38248
diff
changeset
|
546 flags = re.sub('-isysroot [^ \t]*', ' ', flags) |
| 38248 | 547 _config_vars[key] = flags |
| 548 | |
|
47473
c34e34057714
MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
45913
diff
changeset
|
549 else: |
|
c34e34057714
MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
45913
diff
changeset
|
550 |
|
c34e34057714
MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
45913
diff
changeset
|
551 # Allow the user to override the architecture flags using |
|
c34e34057714
MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
45913
diff
changeset
|
552 # an environment variable. |
|
c34e34057714
MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
45913
diff
changeset
|
553 # NOTE: This name was introduced by Apple in OSX 10.5 and |
|
c34e34057714
MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
45913
diff
changeset
|
554 # is used by several scripting languages distributed with |
|
c34e34057714
MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
45913
diff
changeset
|
555 # that OS release. |
|
c34e34057714
MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
45913
diff
changeset
|
556 |
|
c34e34057714
MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
45913
diff
changeset
|
557 if 'ARCHFLAGS' in os.environ: |
|
c34e34057714
MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
45913
diff
changeset
|
558 arch = os.environ['ARCHFLAGS'] |
|
57637
b27d946389e7
Merged revisions 76738 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
56187
diff
changeset
|
559 for key in ('LDFLAGS', 'BASECFLAGS', 'LDSHARED', |
|
47473
c34e34057714
MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
45913
diff
changeset
|
560 # a number of derived variables. These need to be |
|
c34e34057714
MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
45913
diff
changeset
|
561 # patched up as well. |
|
c34e34057714
MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
45913
diff
changeset
|
562 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'): |
|
c34e34057714
MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
45913
diff
changeset
|
563 |
|
c34e34057714
MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
45913
diff
changeset
|
564 flags = _config_vars[key] |
|
c34e34057714
MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
45913
diff
changeset
|
565 flags = re.sub('-arch\s+\w+\s', ' ', flags) |
|
c34e34057714
MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
45913
diff
changeset
|
566 flags = flags + ' ' + arch |
|
c34e34057714
MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
45913
diff
changeset
|
567 _config_vars[key] = flags |
|
c34e34057714
MacOS X: Enable 4-way universal builds
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
45913
diff
changeset
|
568 |
|
56187
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
569 # If we're on OSX 10.5 or later and the user tries to |
|
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
570 # compiles an extension using an SDK that is not present |
|
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
571 # on the current machine it is better to not use an SDK |
|
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
572 # than to fail. |
|
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
573 # |
|
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
574 # The major usecase for this is users using a Python.org |
|
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
575 # binary installer on OSX 10.6: that installer uses |
|
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
576 # the 10.4u SDK, but that SDK is not installed by default |
|
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
577 # when you install Xcode. |
|
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
578 # |
|
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
579 m = re.search('-isysroot\s+(\S+)', _config_vars['CFLAGS']) |
|
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
580 if m is not None: |
|
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
581 sdk = m.group(1) |
|
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
582 if not os.path.exists(sdk): |
|
57637
b27d946389e7
Merged revisions 76738 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
56187
diff
changeset
|
583 for key in ('LDFLAGS', 'BASECFLAGS', 'LDSHARED', |
|
56187
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
584 # a number of derived variables. These need to be |
|
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
585 # patched up as well. |
|
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
586 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'): |
|
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
587 |
|
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
588 flags = _config_vars[key] |
|
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
589 flags = re.sub('-isysroot\s+\S+(\s|$)', ' ', flags) |
|
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
590 _config_vars[key] = flags |
|
4aa7de66137f
Merged revisions 75022 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
54669
diff
changeset
|
591 |
|
14572
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
592 if args: |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
593 vals = [] |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
594 for name in args: |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
595 vals.append(_config_vars.get(name)) |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
596 return vals |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
597 else: |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
598 return _config_vars |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
599 |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
600 def get_config_var(name): |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
601 """Return the value of a single variable using the dictionary |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
602 returned by 'get_config_vars()'. Equivalent to |
|
18945
f8fdd5083af3
Miscellaneous minor cleanups.
Fred Drake <fdrake@acm.org>
parents:
18837
diff
changeset
|
603 get_config_vars().get(name) |
|
14572
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
604 """ |
|
25b7ac05689e
Changed from eager parsing of Makefile (at import time) to lazy: only do
Greg Ward <gward@python.net>
parents:
14571
diff
changeset
|
605 return get_config_vars().get(name) |
