mirror of
https://github.com/python/cpython.git
synced 2025-07-19 17:25:54 +00:00

svn+ssh://pythondev@svn.python.org/python/trunk ........ r61538 | steven.bethard | 2008-03-18 20:03:50 +0100 (Di, 18 Mär 2008) | 1 line cell_compare needs to return -2 instead of NULL. ........ r61539 | steven.bethard | 2008-03-18 20:04:32 +0100 (Di, 18 Mär 2008) | 1 line _have_soundcard() is a bad check for winsound.Beep, since you can have a soundcard but have the beep driver disabled. This revision basically disables the beep tests by wrapping them in a try/except. The Right Way To Do It is to come up with a _have_enabled_beep_driver() and use that. ........ r61540 | gregory.p.smith | 2008-03-18 20:05:32 +0100 (Di, 18 Mär 2008) | 8 lines Fix chown on 64-bit linux. It needed to take a long (64-bit on 64bit linux) as uid and gid input to accept values >=2**31 as valid while still accepting negative numbers to pass -1 to chown for "no change". Fixes issue1747858. This should be backported to release25-maint. ........ r61556 | steven.bethard | 2008-03-18 20:59:14 +0100 (Di, 18 Mär 2008) | 1 line Fix test_atexit so that it still passes when -3 is supplied. (It was catching the warning messages on stdio from using the reload() function.) ........ r61559 | neal.norwitz | 2008-03-18 21:30:38 +0100 (Di, 18 Mär 2008) | 1 line Import the test properly. This is especially important for py3k. ........ r61560 | gregory.p.smith | 2008-03-18 21:40:01 +0100 (Di, 18 Mär 2008) | 2 lines news entry for the chown fix ........ r61563 | brett.cannon | 2008-03-18 22:12:42 +0100 (Di, 18 Mär 2008) | 2 lines Ignore BIG5HKSCS-2004.TXT which is downloaded as part of a test. ........ r61565 | steven.bethard | 2008-03-18 22:30:13 +0100 (Di, 18 Mär 2008) | 1 line Have regrtest skip test_py3kwarn when the -3 flag is missing. ........ r61571 | gregory.p.smith | 2008-03-18 23:27:41 +0100 (Di, 18 Mär 2008) | 4 lines Add a test to make sure zlib.crc32 and binascii.crc32 return the same thing. Fix a buglet in binascii.crc32, the second optional argument could previously have a signedness mismatch with the C variable its going into. ........ r61575 | raymond.hettinger | 2008-03-19 00:22:29 +0100 (Mi, 19 Mär 2008) | 1 line Speed-up isinstance() for one easy case. ........ r61576 | raymond.hettinger | 2008-03-19 00:33:08 +0100 (Mi, 19 Mär 2008) | 1 line Issue: 2354: Add 3K warning for the cmp argument to list.sort() and sorted(). ........ r61580 | andrew.kuchling | 2008-03-19 02:05:35 +0100 (Mi, 19 Mär 2008) | 1 line Add Jeff Rush ........ r61581 | gregory.p.smith | 2008-03-19 02:38:35 +0100 (Mi, 19 Mär 2008) | 3 lines Mention that crc32 and adler32 are available in a different module (zlib). Some people look for them in hashlib. ........ r61582 | gregory.p.smith | 2008-03-19 02:46:10 +0100 (Mi, 19 Mär 2008) | 3 lines Use zlib's crc32 routine instead of binascii when available. zlib's is faster when compiled properly optimized and about the same speed otherwise. ........ r61586 | david.wolever | 2008-03-19 03:26:57 +0100 (Mi, 19 Mär 2008) | 1 line Added my name to ACKS ........ r61591 | gregory.p.smith | 2008-03-19 04:14:41 +0100 (Mi, 19 Mär 2008) | 5 lines Fix the struct module DeprecationWarnings that zipfile was triggering by removing all use of signed struct values. test_zipfile and test_zipfile64 pass. no more warnings. ........ r61593 | raymond.hettinger | 2008-03-19 04:56:59 +0100 (Mi, 19 Mär 2008) | 1 line Fix compiler warning. ........ r61595 | martin.v.loewis | 2008-03-19 05:39:13 +0100 (Mi, 19 Mär 2008) | 2 lines Issue #2400: Allow relative imports to "import *". ........ r61605 | martin.v.loewis | 2008-03-19 07:00:28 +0100 (Mi, 19 Mär 2008) | 2 lines Import relimport using a relative import. ........ r61606 | trent.nelson | 2008-03-19 07:28:24 +0100 (Mi, 19 Mär 2008) | 1 line 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. ........ r61613 | trent.nelson | 2008-03-19 08:45:19 +0100 (Mi, 19 Mär 2008) | 3 lines Refine the Visual Studio 2008 build solution in order to improve how we deal with external components, as well as fixing outstanding issues with Windows x64 build support. Introduce two new .vcproj files, _bsddb44.vcproj and sqlite3.vcproj, which replace the previous pre-link event scripts for _bsddb and _sqlite3 respectively. The new project files inherit from our property files as if they were any other Python module. This has numerous benefits. First, the components get built with exactly the same compiler flags and settings as the rest of Python. Second, it makes it much easier to debug problems in the external components when they're part of the build system. Third, they'll benefit from profile guided optimisation in the release builds, just like the rest of Python core. I've also introduced a slightly new pattern for managing externals in subversion. New components get checked in as <name>-<version>.x, where <version> matches the exact vendor version string. After the initial import of the external component, the .x is tagged as .0 (i.e. tcl-8.4.18.x -> tcl-8.4.18.0). Some components may not need any tweaking, whereas there are others that might (tcl/tk fall into this bucket). In that case, the relevant modifications are made to the .x branch, which will be subsequently tagged as .1 (and then n+1 going forward) when they build successfully and all tests pass. Buildbots will be converted to rely on these explicit tags only, which makes it easy for us to switch them over to a new version as and when required. (Simple change to external(-amd64).bat: if we've bumped tcl to 8.4.18.1, change the .bat to rmdir 8.4.18.0 if it exists and check out a new .1 copy.) ........ r61614 | trent.nelson | 2008-03-19 08:56:39 +0100 (Mi, 19 Mär 2008) | 1 line Remove extraneous apostrophe and semi-colon from AdditionalIncludeDirectories. ........ r61615 | georg.brandl | 2008-03-19 08:56:40 +0100 (Mi, 19 Mär 2008) | 2 lines Remove footnote from versionchanged as it upsets LaTeX. ........ r61616 | georg.brandl | 2008-03-19 08:57:57 +0100 (Mi, 19 Mär 2008) | 2 lines Another one. ........ r61618 | trent.nelson | 2008-03-19 09:06:03 +0100 (Mi, 19 Mär 2008) | 1 line Fix the tcl-8.4.18.1 path and make sure we cd into the right directory when building tcl/tk. ........ r61621 | trent.nelson | 2008-03-19 10:23:08 +0100 (Mi, 19 Mär 2008) | 1 line Lets have another try at getting the Windows buildbots in a consistent state before rebuilding using the new process. ........ r61622 | eric.smith | 2008-03-19 13:09:55 +0100 (Mi, 19 Mär 2008) | 2 lines Use test.test_support.captured_stdout instead of a custom contextmanager. Thanks Nick Coghlan. ........ r61623 | eric.smith | 2008-03-19 13:15:10 +0100 (Mi, 19 Mär 2008) | 1 line Trivial typo. ........ r61625 | thomas.heller | 2008-03-19 17:10:57 +0100 (Mi, 19 Mär 2008) | 2 lines Checkout sqlite-source when it is not there. ........ r61627 | brett.cannon | 2008-03-19 17:50:13 +0100 (Mi, 19 Mär 2008) | 5 lines test_nis would fail if test.test_support.verbose was true but NIS was not set up on the machine. Closes issue2411. Thanks Michael Bishop. ........ r61631 | brett.cannon | 2008-03-19 18:37:43 +0100 (Mi, 19 Mär 2008) | 2 lines Use sys.py3kwarning instead of trying to trigger a Py3k-related warning. ........ r61632 | raymond.hettinger | 2008-03-19 18:45:19 +0100 (Mi, 19 Mär 2008) | 1 line Issue 2354: Fix-up compare warning. Patch contributed by Jeff Balogh. ........ r61633 | raymond.hettinger | 2008-03-19 18:58:59 +0100 (Mi, 19 Mär 2008) | 1 line The filter() function does support a None argument in Py3.0. ........ r61634 | raymond.hettinger | 2008-03-19 19:01:58 +0100 (Mi, 19 Mär 2008) | 1 line Remove itertools warnings I had added before the 2-to-3 handled the migration. ........
532 lines
19 KiB
Python
532 lines
19 KiB
Python
"""Provide access to Python's configuration information. The specific
|
|
configuration variables available depend heavily on the platform and
|
|
configuration. The values may be retrieved using
|
|
get_config_var(name), and the list of variables is available via
|
|
get_config_vars().keys(). Additional convenience functions are also
|
|
available.
|
|
|
|
Written by: Fred L. Drake, Jr.
|
|
Email: <fdrake@acm.org>
|
|
"""
|
|
|
|
__revision__ = "$Id$"
|
|
|
|
import io
|
|
import os
|
|
import re
|
|
import sys
|
|
|
|
from .errors import DistutilsPlatformError
|
|
|
|
# These are needed in a couple of spots, so just compute them once.
|
|
PREFIX = os.path.normpath(sys.prefix)
|
|
EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
|
|
|
|
# Path to the base directory of the project. On Windows the binary may
|
|
# live in project/PCBuild9. If we're dealing with an x64 Windows build,
|
|
# it'll live in project/PCbuild/amd64.
|
|
project_base = os.path.dirname(os.path.abspath(sys.executable))
|
|
if os.name == "nt" and "pcbuild" in project_base[-8:].lower():
|
|
project_base = os.path.abspath(os.path.join(project_base, os.path.pardir))
|
|
# PC/VS7.1
|
|
if os.name == "nt" and "\\pc\\v" in project_base[-10:].lower():
|
|
project_base = os.path.abspath(os.path.join(project_base, os.path.pardir,
|
|
os.path.pardir))
|
|
# PC/AMD64
|
|
if os.name == "nt" and "\\pcbuild\\amd64" in project_base[-14:].lower():
|
|
project_base = os.path.abspath(os.path.join(project_base, os.path.pardir,
|
|
os.path.pardir))
|
|
|
|
# python_build: (Boolean) if true, we're either building Python or
|
|
# building an extension with an un-installed Python, so we use
|
|
# different (hard-wired) directories.
|
|
# Setup.local is available for Makefile builds including VPATH builds,
|
|
# Setup.dist is available on Windows
|
|
def _python_build():
|
|
for fn in ("Setup.dist", "Setup.local"):
|
|
if os.path.isfile(os.path.join(project_base, "Modules", fn)):
|
|
return True
|
|
return False
|
|
python_build = _python_build()
|
|
|
|
def get_python_version():
|
|
"""Return a string containing the major and minor Python version,
|
|
leaving off the patchlevel. Sample return values could be '1.5'
|
|
or '2.2'.
|
|
"""
|
|
return sys.version[:3]
|
|
|
|
|
|
def get_python_inc(plat_specific=0, prefix=None):
|
|
"""Return the directory containing installed Python header files.
|
|
|
|
If 'plat_specific' is false (the default), this is the path to the
|
|
non-platform-specific header files, i.e. Python.h and so on;
|
|
otherwise, this is the path to platform-specific header files
|
|
(namely pyconfig.h).
|
|
|
|
If 'prefix' is supplied, use it instead of sys.prefix or
|
|
sys.exec_prefix -- i.e., ignore 'plat_specific'.
|
|
"""
|
|
if prefix is None:
|
|
prefix = plat_specific and EXEC_PREFIX or PREFIX
|
|
if os.name == "posix":
|
|
if python_build:
|
|
base = os.path.dirname(os.path.abspath(sys.executable))
|
|
if plat_specific:
|
|
inc_dir = base
|
|
else:
|
|
inc_dir = os.path.join(base, "Include")
|
|
if not os.path.exists(inc_dir):
|
|
inc_dir = os.path.join(os.path.dirname(base), "Include")
|
|
return inc_dir
|
|
return os.path.join(prefix, "include", "python" + get_python_version())
|
|
elif os.name == "nt":
|
|
return os.path.join(prefix, "include")
|
|
elif os.name == "mac":
|
|
if plat_specific:
|
|
return os.path.join(prefix, "Mac", "Include")
|
|
else:
|
|
return os.path.join(prefix, "Include")
|
|
elif os.name == "os2":
|
|
return os.path.join(prefix, "Include")
|
|
else:
|
|
raise DistutilsPlatformError(
|
|
"I don't know where Python installs its C header files "
|
|
"on platform '%s'" % os.name)
|
|
|
|
|
|
def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
|
|
"""Return the directory containing the Python library (standard or
|
|
site additions).
|
|
|
|
If 'plat_specific' is true, return the directory containing
|
|
platform-specific modules, i.e. any module from a non-pure-Python
|
|
module distribution; otherwise, return the platform-shared library
|
|
directory. If 'standard_lib' is true, return the directory
|
|
containing standard Python library modules; otherwise, return the
|
|
directory for site-specific modules.
|
|
|
|
If 'prefix' is supplied, use it instead of sys.prefix or
|
|
sys.exec_prefix -- i.e., ignore 'plat_specific'.
|
|
"""
|
|
if prefix is None:
|
|
prefix = plat_specific and EXEC_PREFIX or PREFIX
|
|
|
|
if os.name == "posix":
|
|
libpython = os.path.join(prefix,
|
|
"lib", "python" + get_python_version())
|
|
if standard_lib:
|
|
return libpython
|
|
else:
|
|
return os.path.join(libpython, "site-packages")
|
|
elif os.name == "nt":
|
|
if standard_lib:
|
|
return os.path.join(prefix, "Lib")
|
|
else:
|
|
if get_python_version() < "2.2":
|
|
return prefix
|
|
else:
|
|
return os.path.join(PREFIX, "Lib", "site-packages")
|
|
elif os.name == "mac":
|
|
if plat_specific:
|
|
if standard_lib:
|
|
return os.path.join(prefix, "Lib", "lib-dynload")
|
|
else:
|
|
return os.path.join(prefix, "Lib", "site-packages")
|
|
else:
|
|
if standard_lib:
|
|
return os.path.join(prefix, "Lib")
|
|
else:
|
|
return os.path.join(prefix, "Lib", "site-packages")
|
|
elif os.name == "os2":
|
|
if standard_lib:
|
|
return os.path.join(PREFIX, "Lib")
|
|
else:
|
|
return os.path.join(PREFIX, "Lib", "site-packages")
|
|
else:
|
|
raise DistutilsPlatformError(
|
|
"I don't know where Python installs its library "
|
|
"on platform '%s'" % os.name)
|
|
|
|
|
|
def customize_compiler(compiler):
|
|
"""Do any platform-specific customization of a CCompiler instance.
|
|
|
|
Mainly needed on Unix, so we can plug in the information that
|
|
varies across Unices and is stored in Python's Makefile.
|
|
"""
|
|
if compiler.compiler_type == "unix":
|
|
(cc, cxx, opt, cflags, ccshared, ldshared, so_ext) = \
|
|
get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
|
|
'CCSHARED', 'LDSHARED', 'SO')
|
|
|
|
if 'CC' in os.environ:
|
|
cc = os.environ['CC']
|
|
if 'CXX' in os.environ:
|
|
cxx = os.environ['CXX']
|
|
if 'LDSHARED' in os.environ:
|
|
ldshared = os.environ['LDSHARED']
|
|
if 'CPP' in os.environ:
|
|
cpp = os.environ['CPP']
|
|
else:
|
|
cpp = cc + " -E" # not always
|
|
if 'LDFLAGS' in os.environ:
|
|
ldshared = ldshared + ' ' + os.environ['LDFLAGS']
|
|
if 'CFLAGS' in os.environ:
|
|
cflags = opt + ' ' + os.environ['CFLAGS']
|
|
ldshared = ldshared + ' ' + os.environ['CFLAGS']
|
|
if 'CPPFLAGS' in os.environ:
|
|
cpp = cpp + ' ' + os.environ['CPPFLAGS']
|
|
cflags = cflags + ' ' + os.environ['CPPFLAGS']
|
|
ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
|
|
|
|
cc_cmd = cc + ' ' + cflags
|
|
compiler.set_executables(
|
|
preprocessor=cpp,
|
|
compiler=cc_cmd,
|
|
compiler_so=cc_cmd + ' ' + ccshared,
|
|
compiler_cxx=cxx,
|
|
linker_so=ldshared,
|
|
linker_exe=cc)
|
|
|
|
compiler.shared_lib_extension = so_ext
|
|
|
|
|
|
def get_config_h_filename():
|
|
"""Return full pathname of installed pyconfig.h file."""
|
|
if python_build:
|
|
if os.name == "nt":
|
|
inc_dir = os.path.join(project_base, "PC")
|
|
else:
|
|
inc_dir = project_base
|
|
else:
|
|
inc_dir = get_python_inc(plat_specific=1)
|
|
if get_python_version() < '2.2':
|
|
config_h = 'config.h'
|
|
else:
|
|
# The name of the config.h file changed in 2.2
|
|
config_h = 'pyconfig.h'
|
|
return os.path.join(inc_dir, config_h)
|
|
|
|
|
|
def get_makefile_filename():
|
|
"""Return full pathname of installed Makefile from the Python build."""
|
|
if python_build:
|
|
return os.path.join(os.path.dirname(sys.executable), "Makefile")
|
|
lib_dir = get_python_lib(plat_specific=1, standard_lib=1)
|
|
return os.path.join(lib_dir, "config", "Makefile")
|
|
|
|
|
|
def parse_config_h(fp, g=None):
|
|
"""Parse a config.h-style file.
|
|
|
|
A dictionary containing name/value pairs is returned. If an
|
|
optional dictionary is passed in as the second argument, it is
|
|
used instead of a new dictionary.
|
|
"""
|
|
if g is None:
|
|
g = {}
|
|
define_rx = re.compile("#define ([A-Z][A-Za-z0-9_]+) (.*)\n")
|
|
undef_rx = re.compile("/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/\n")
|
|
#
|
|
while True:
|
|
line = fp.readline()
|
|
if not line:
|
|
break
|
|
m = define_rx.match(line)
|
|
if m:
|
|
n, v = m.group(1, 2)
|
|
try: v = int(v)
|
|
except ValueError: pass
|
|
g[n] = v
|
|
else:
|
|
m = undef_rx.match(line)
|
|
if m:
|
|
g[m.group(1)] = 0
|
|
return g
|
|
|
|
|
|
# Regexes needed for parsing Makefile (and similar syntaxes,
|
|
# like old-style Setup files).
|
|
_variable_rx = re.compile("([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)")
|
|
_findvar1_rx = re.compile(r"\$\(([A-Za-z][A-Za-z0-9_]*)\)")
|
|
_findvar2_rx = re.compile(r"\${([A-Za-z][A-Za-z0-9_]*)}")
|
|
|
|
def parse_makefile(fn, g=None):
|
|
"""Parse a Makefile-style file.
|
|
|
|
A dictionary containing name/value pairs is returned. If an
|
|
optional dictionary is passed in as the second argument, it is
|
|
used instead of a new dictionary.
|
|
"""
|
|
from distutils.text_file import TextFile
|
|
fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1)
|
|
|
|
if g is None:
|
|
g = {}
|
|
done = {}
|
|
notdone = {}
|
|
|
|
while True:
|
|
line = fp.readline()
|
|
if line is None: # eof
|
|
break
|
|
m = _variable_rx.match(line)
|
|
if m:
|
|
n, v = m.group(1, 2)
|
|
v = v.strip()
|
|
if "$" in v:
|
|
notdone[n] = v
|
|
else:
|
|
try: v = int(v)
|
|
except ValueError: pass
|
|
done[n] = v
|
|
|
|
# do variable interpolation here
|
|
while notdone:
|
|
for name in list(notdone):
|
|
value = notdone[name]
|
|
m = _findvar1_rx.search(value) or _findvar2_rx.search(value)
|
|
if m:
|
|
n = m.group(1)
|
|
found = True
|
|
if n in done:
|
|
item = str(done[n])
|
|
elif n in notdone:
|
|
# get it on a subsequent round
|
|
found = False
|
|
elif n in os.environ:
|
|
# do it like make: fall back to environment
|
|
item = os.environ[n]
|
|
else:
|
|
done[n] = item = ""
|
|
if found:
|
|
after = value[m.end():]
|
|
value = value[:m.start()] + item + after
|
|
if "$" in after:
|
|
notdone[name] = value
|
|
else:
|
|
try: value = int(value)
|
|
except ValueError:
|
|
done[name] = value.strip()
|
|
else:
|
|
done[name] = value
|
|
del notdone[name]
|
|
else:
|
|
# bogus variable reference; just drop it since we can't deal
|
|
del notdone[name]
|
|
|
|
fp.close()
|
|
|
|
# save the results in the global dictionary
|
|
g.update(done)
|
|
return g
|
|
|
|
|
|
def expand_makefile_vars(s, vars):
|
|
"""Expand Makefile-style variables -- "${foo}" or "$(foo)" -- in
|
|
'string' according to 'vars' (a dictionary mapping variable names to
|
|
values). Variables not present in 'vars' are silently expanded to the
|
|
empty string. The variable values in 'vars' should not contain further
|
|
variable expansions; if 'vars' is the output of 'parse_makefile()',
|
|
you're fine. Returns a variable-expanded version of 's'.
|
|
"""
|
|
|
|
# This algorithm does multiple expansion, so if vars['foo'] contains
|
|
# "${bar}", it will expand ${foo} to ${bar}, and then expand
|
|
# ${bar}... and so forth. This is fine as long as 'vars' comes from
|
|
# 'parse_makefile()', which takes care of such expansions eagerly,
|
|
# according to make's variable expansion semantics.
|
|
|
|
while True:
|
|
m = _findvar1_rx.search(s) or _findvar2_rx.search(s)
|
|
if m:
|
|
(beg, end) = m.span()
|
|
s = s[0:beg] + vars.get(m.group(1)) + s[end:]
|
|
else:
|
|
break
|
|
return s
|
|
|
|
|
|
_config_vars = None
|
|
|
|
def _init_posix():
|
|
"""Initialize the module as appropriate for POSIX systems."""
|
|
g = {}
|
|
# load the installed Makefile:
|
|
try:
|
|
filename = get_makefile_filename()
|
|
parse_makefile(filename, g)
|
|
except IOError as msg:
|
|
my_msg = "invalid Python installation: unable to open %s" % filename
|
|
if hasattr(msg, "strerror"):
|
|
my_msg = my_msg + " (%s)" % msg.strerror
|
|
|
|
raise DistutilsPlatformError(my_msg)
|
|
|
|
# load the installed pyconfig.h:
|
|
try:
|
|
filename = get_config_h_filename()
|
|
parse_config_h(io.open(filename), g)
|
|
except IOError as msg:
|
|
my_msg = "invalid Python installation: unable to open %s" % filename
|
|
if hasattr(msg, "strerror"):
|
|
my_msg = my_msg + " (%s)" % msg.strerror
|
|
|
|
raise DistutilsPlatformError(my_msg)
|
|
|
|
# On MacOSX we need to check the setting of the environment variable
|
|
# MACOSX_DEPLOYMENT_TARGET: configure bases some choices on it so
|
|
# it needs to be compatible.
|
|
# If it isn't set we set it to the configure-time value
|
|
if sys.platform == 'darwin' and 'MACOSX_DEPLOYMENT_TARGET' in g:
|
|
cfg_target = g['MACOSX_DEPLOYMENT_TARGET']
|
|
cur_target = os.getenv('MACOSX_DEPLOYMENT_TARGET', '')
|
|
if cur_target == '':
|
|
cur_target = cfg_target
|
|
os.putenv('MACOSX_DEPLOYMENT_TARGET', cfg_target)
|
|
elif [int(x) for x in cfg_target.split('.')] > [int(x) for x in cur_target.split('.')]:
|
|
my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: now "%s" but "%s" during configure'
|
|
% (cur_target, cfg_target))
|
|
raise DistutilsPlatformError(my_msg)
|
|
|
|
# On AIX, there are wrong paths to the linker scripts in the Makefile
|
|
# -- these paths are relative to the Python source, but when installed
|
|
# the scripts are in another directory.
|
|
if python_build:
|
|
g['LDSHARED'] = g['BLDSHARED']
|
|
|
|
elif get_python_version() < '2.1':
|
|
# The following two branches are for 1.5.2 compatibility.
|
|
if sys.platform == 'aix4': # what about AIX 3.x ?
|
|
# Linker script is in the config directory, not in Modules as the
|
|
# Makefile says.
|
|
python_lib = get_python_lib(standard_lib=1)
|
|
ld_so_aix = os.path.join(python_lib, 'config', 'ld_so_aix')
|
|
python_exp = os.path.join(python_lib, 'config', 'python.exp')
|
|
|
|
g['LDSHARED'] = "%s %s -bI:%s" % (ld_so_aix, g['CC'], python_exp)
|
|
|
|
global _config_vars
|
|
_config_vars = g
|
|
|
|
|
|
def _init_nt():
|
|
"""Initialize the module as appropriate for NT"""
|
|
g = {}
|
|
# set basic install directories
|
|
g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1)
|
|
g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1)
|
|
|
|
# XXX hmmm.. a normal install puts include files here
|
|
g['INCLUDEPY'] = get_python_inc(plat_specific=0)
|
|
|
|
g['SO'] = '.pyd'
|
|
g['EXE'] = ".exe"
|
|
g['VERSION'] = get_python_version().replace(".", "")
|
|
g['BINDIR'] = os.path.dirname(os.path.abspath(sys.executable))
|
|
|
|
global _config_vars
|
|
_config_vars = g
|
|
|
|
|
|
def _init_mac():
|
|
"""Initialize the module as appropriate for Macintosh systems"""
|
|
g = {}
|
|
# set basic install directories
|
|
g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1)
|
|
g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1)
|
|
|
|
# XXX hmmm.. a normal install puts include files here
|
|
g['INCLUDEPY'] = get_python_inc(plat_specific=0)
|
|
|
|
import MacOS
|
|
if not hasattr(MacOS, 'runtimemodel'):
|
|
g['SO'] = '.ppc.slb'
|
|
else:
|
|
g['SO'] = '.%s.slb' % MacOS.runtimemodel
|
|
|
|
# XXX are these used anywhere?
|
|
g['install_lib'] = os.path.join(EXEC_PREFIX, "Lib")
|
|
g['install_platlib'] = os.path.join(EXEC_PREFIX, "Mac", "Lib")
|
|
|
|
# These are used by the extension module build
|
|
g['srcdir'] = ':'
|
|
global _config_vars
|
|
_config_vars = g
|
|
|
|
|
|
def _init_os2():
|
|
"""Initialize the module as appropriate for OS/2"""
|
|
g = {}
|
|
# set basic install directories
|
|
g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1)
|
|
g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1)
|
|
|
|
# XXX hmmm.. a normal install puts include files here
|
|
g['INCLUDEPY'] = get_python_inc(plat_specific=0)
|
|
|
|
g['SO'] = '.pyd'
|
|
g['EXE'] = ".exe"
|
|
|
|
global _config_vars
|
|
_config_vars = g
|
|
|
|
|
|
def get_config_vars(*args):
|
|
"""With no arguments, return a dictionary of all configuration
|
|
variables relevant for the current platform. Generally this includes
|
|
everything needed to build extensions and install both pure modules and
|
|
extensions. On Unix, this means every variable defined in Python's
|
|
installed Makefile; on Windows and Mac OS it's a much smaller set.
|
|
|
|
With arguments, return a list of values that result from looking up
|
|
each argument in the configuration variable dictionary.
|
|
"""
|
|
global _config_vars
|
|
if _config_vars is None:
|
|
func = globals().get("_init_" + os.name)
|
|
if func:
|
|
func()
|
|
else:
|
|
_config_vars = {}
|
|
|
|
# Normalized versions of prefix and exec_prefix are handy to have;
|
|
# in fact, these are the standard versions used most places in the
|
|
# Distutils.
|
|
_config_vars['prefix'] = PREFIX
|
|
_config_vars['exec_prefix'] = EXEC_PREFIX
|
|
|
|
if sys.platform == 'darwin':
|
|
kernel_version = os.uname()[2] # Kernel version (8.4.3)
|
|
major_version = int(kernel_version.split('.')[0])
|
|
|
|
if major_version < 8:
|
|
# On Mac OS X before 10.4, check if -arch and -isysroot
|
|
# are in CFLAGS or LDFLAGS and remove them if they are.
|
|
# This is needed when building extensions on a 10.3 system
|
|
# using a universal build of python.
|
|
for key in ('LDFLAGS', 'BASECFLAGS',
|
|
# a number of derived variables. These need to be
|
|
# patched up as well.
|
|
'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):
|
|
flags = _config_vars[key]
|
|
flags = re.sub('-arch\s+\w+\s', ' ', flags)
|
|
flags = re.sub('-isysroot [^ \t]*', ' ', flags)
|
|
_config_vars[key] = flags
|
|
|
|
if args:
|
|
vals = []
|
|
for name in args:
|
|
vals.append(_config_vars.get(name))
|
|
return vals
|
|
else:
|
|
return _config_vars
|
|
|
|
def get_config_var(name):
|
|
"""Return the value of a single variable using the dictionary
|
|
returned by 'get_config_vars()'. Equivalent to
|
|
get_config_vars().get(name)
|
|
"""
|
|
return get_config_vars().get(name)
|