2001-07-18 15:39:56 -03:00
|
|
|
"""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.
|
1998-12-18 19:46:33 -04:00
|
|
|
|
|
|
|
Written by: Fred L. Drake, Jr.
|
|
|
|
Email: <fdrake@acm.org>
|
|
|
|
"""
|
|
|
|
|
2000-06-02 21:44:30 -03:00
|
|
|
__revision__ = "$Id$"
|
1998-12-18 19:46:33 -04:00
|
|
|
|
2010-03-04 20:16:02 -04:00
|
|
|
import os
|
1999-01-06 10:46:06 -04:00
|
|
|
import re
|
2010-03-04 20:16:02 -04:00
|
|
|
import string
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from distutils.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))
|
|
|
|
|
2013-01-31 18:52:03 -04:00
|
|
|
# set for cross builds
|
|
|
|
if "_PYTHON_PROJECT_BASE" in os.environ:
|
|
|
|
# this is the build directory, at least for posix
|
|
|
|
project_base = os.path.normpath(os.environ["_PYTHON_PROJECT_BASE"])
|
|
|
|
|
2010-03-04 20:16:02 -04:00
|
|
|
# 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()
|
2010-01-23 05:23:15 -04:00
|
|
|
|
|
|
|
|
2010-03-04 20:16:02 -04:00
|
|
|
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]
|
2010-01-23 05:23:15 -04:00
|
|
|
|
2002-11-13 21:43:00 -04:00
|
|
|
|
2000-04-09 22:17:49 -03:00
|
|
|
def get_python_inc(plat_specific=0, prefix=None):
|
2010-03-04 20:16:02 -04:00
|
|
|
"""Return the directory containing installed Python header files.
|
2000-03-09 11:54:52 -04:00
|
|
|
|
|
|
|
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
|
2001-07-26 10:41:06 -03:00
|
|
|
(namely pyconfig.h).
|
2000-03-09 11:54:52 -04:00
|
|
|
|
2000-04-09 22:17:49 -03:00
|
|
|
If 'prefix' is supplied, use it instead of sys.prefix or
|
|
|
|
sys.exec_prefix -- i.e., ignore 'plat_specific'.
|
2001-12-06 16:51:35 -04:00
|
|
|
"""
|
2010-03-04 20:16:02 -04:00
|
|
|
if prefix is None:
|
|
|
|
prefix = plat_specific and EXEC_PREFIX or PREFIX
|
2010-04-30 09:15:12 -03:00
|
|
|
|
2010-03-04 20:16:02 -04:00
|
|
|
if os.name == "posix":
|
|
|
|
if python_build:
|
2010-04-30 09:15:12 -03:00
|
|
|
buildir = os.path.dirname(sys.executable)
|
2010-03-04 20:16:02 -04:00
|
|
|
if plat_specific:
|
2010-04-30 09:15:12 -03:00
|
|
|
# python.h is located in the buildir
|
|
|
|
inc_dir = buildir
|
2010-03-04 20:16:02 -04:00
|
|
|
else:
|
2010-04-30 09:15:12 -03:00
|
|
|
# the source dir is relative to the buildir
|
|
|
|
srcdir = os.path.abspath(os.path.join(buildir,
|
|
|
|
get_config_var('srcdir')))
|
|
|
|
# Include is located in the srcdir
|
|
|
|
inc_dir = os.path.join(srcdir, "Include")
|
2010-03-04 20:16:02 -04:00
|
|
|
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 == "os2":
|
|
|
|
return os.path.join(prefix, "Include")
|
2000-03-08 23:16:05 -04:00
|
|
|
else:
|
2010-03-04 20:16:02 -04:00
|
|
|
raise DistutilsPlatformError(
|
|
|
|
"I don't know where Python installs its C header files "
|
|
|
|
"on platform '%s'" % os.name)
|
2000-03-08 23:16:05 -04:00
|
|
|
|
|
|
|
|
2010-03-04 20:16:02 -04:00
|
|
|
def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
|
|
|
|
"""Return the directory containing the Python library (standard or
|
2000-03-09 11:54:52 -04:00
|
|
|
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.
|
2000-03-08 23:16:05 -04:00
|
|
|
|
2000-04-09 22:17:49 -03:00
|
|
|
If 'prefix' is supplied, use it instead of sys.prefix or
|
|
|
|
sys.exec_prefix -- i.e., ignore 'plat_specific'.
|
2000-03-09 11:54:52 -04:00
|
|
|
"""
|
2010-03-04 20:16:02 -04:00
|
|
|
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
|
2000-03-08 23:16:05 -04:00
|
|
|
else:
|
2010-03-04 20:16:02 -04:00
|
|
|
return os.path.join(libpython, "site-packages")
|
2000-03-08 23:16:05 -04:00
|
|
|
|
2010-03-04 20:16:02 -04:00
|
|
|
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 == "os2":
|
|
|
|
if standard_lib:
|
|
|
|
return os.path.join(prefix, "Lib")
|
|
|
|
else:
|
|
|
|
return os.path.join(prefix, "Lib", "site-packages")
|
|
|
|
|
2000-03-08 23:16:05 -04:00
|
|
|
else:
|
2010-03-04 20:16:02 -04:00
|
|
|
raise DistutilsPlatformError(
|
|
|
|
"I don't know where Python installs its library "
|
|
|
|
"on platform '%s'" % os.name)
|
|
|
|
|
2013-01-31 05:24:55 -04:00
|
|
|
|
2010-03-04 20:16:02 -04:00
|
|
|
|
|
|
|
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":
|
2013-01-31 05:24:55 -04:00
|
|
|
if sys.platform == "darwin":
|
|
|
|
# Perform first-time customization of compiler-related
|
|
|
|
# config vars on OS X now that we know we need a compiler.
|
|
|
|
# This is primarily to support Pythons from binary
|
|
|
|
# installers. The kind and paths to build tools on
|
|
|
|
# the user system may vary significantly from the system
|
|
|
|
# that Python itself was built on. Also the user OS
|
|
|
|
# version and build tools may not support the same set
|
|
|
|
# of CPU architectures for universal builds.
|
|
|
|
global _config_vars
|
|
|
|
if not _config_vars.get('CUSTOMIZED_OSX_COMPILER', ''):
|
|
|
|
import _osx_support
|
|
|
|
_osx_support.customize_compiler(_config_vars)
|
|
|
|
_config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
|
|
|
|
|
2012-02-11 15:40:24 -04:00
|
|
|
(cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \
|
2010-03-04 20:16:02 -04:00
|
|
|
get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
|
2012-02-11 15:40:24 -04:00
|
|
|
'CCSHARED', 'LDSHARED', 'SO', 'AR',
|
|
|
|
'ARFLAGS')
|
2010-03-04 20:16:02 -04:00
|
|
|
|
2012-02-10 07:59:06 -04:00
|
|
|
newcc = None
|
2010-03-04 20:16:02 -04:00
|
|
|
if 'CC' in os.environ:
|
2013-01-31 05:24:55 -04:00
|
|
|
cc = os.environ['CC']
|
2010-03-04 20:16:02 -04:00
|
|
|
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']
|
2012-02-11 15:40:24 -04:00
|
|
|
if 'AR' in os.environ:
|
|
|
|
ar = os.environ['AR']
|
|
|
|
if 'ARFLAGS' in os.environ:
|
|
|
|
archiver = ar + ' ' + os.environ['ARFLAGS']
|
|
|
|
else:
|
|
|
|
archiver = ar + ' ' + ar_flags
|
2010-03-04 20:16:02 -04:00
|
|
|
|
|
|
|
cc_cmd = cc + ' ' + cflags
|
|
|
|
compiler.set_executables(
|
|
|
|
preprocessor=cpp,
|
|
|
|
compiler=cc_cmd,
|
|
|
|
compiler_so=cc_cmd + ' ' + ccshared,
|
|
|
|
compiler_cxx=cxx,
|
|
|
|
linker_so=ldshared,
|
2012-02-11 15:40:24 -04:00
|
|
|
linker_exe=cc,
|
|
|
|
archiver=archiver)
|
2010-03-04 20:16:02 -04:00
|
|
|
|
|
|
|
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")
|
2007-12-06 09:15:13 -04:00
|
|
|
else:
|
2010-03-04 20:16:02 -04:00
|
|
|
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)
|
|
|
|
|
1998-12-18 19:46:33 -04:00
|
|
|
|
1999-01-06 10:46:06 -04:00
|
|
|
def get_makefile_filename():
|
2010-03-04 20:16:02 -04:00
|
|
|
"""Return full pathname of installed Makefile from the Python build."""
|
|
|
|
if python_build:
|
2013-01-31 18:52:03 -04:00
|
|
|
return os.path.join(project_base, "Makefile")
|
2010-03-04 20:16:02 -04:00
|
|
|
lib_dir = get_python_lib(plat_specific=1, standard_lib=1)
|
|
|
|
return os.path.join(lib_dir, "config", "Makefile")
|
|
|
|
|
1998-12-18 19:46:33 -04:00
|
|
|
|
2010-03-04 20:16:02 -04:00
|
|
|
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.
|
1999-01-06 12:28:34 -04:00
|
|
|
"""
|
2010-03-04 20:16:02 -04:00
|
|
|
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 1:
|
|
|
|
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
|
|
|
|
|
2000-09-16 21:53:02 -03:00
|
|
|
|
|
|
|
# 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_]*)}")
|
|
|
|
|
2000-09-14 21:03:13 -03:00
|
|
|
def parse_makefile(fn, g=None):
|
2010-03-04 20:16:02 -04:00
|
|
|
"""Parse a Makefile-style file.
|
2000-03-09 11:54:52 -04:00
|
|
|
|
|
|
|
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.
|
1999-01-06 12:28:34 -04:00
|
|
|
"""
|
2010-03-04 20:16:02 -04:00
|
|
|
from distutils.text_file import TextFile
|
|
|
|
fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1)
|
1998-12-18 19:46:33 -04:00
|
|
|
|
2010-03-04 20:16:02 -04:00
|
|
|
if g is None:
|
|
|
|
g = {}
|
|
|
|
done = {}
|
|
|
|
notdone = {}
|
2010-01-23 05:23:15 -04:00
|
|
|
|
2010-03-04 20:16:02 -04:00
|
|
|
while 1:
|
|
|
|
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()
|
|
|
|
# `$$' is a literal `$' in make
|
|
|
|
tmpv = v.replace('$$', '')
|
|
|
|
|
|
|
|
if "$" in tmpv:
|
|
|
|
notdone[n] = v
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
v = int(v)
|
|
|
|
except ValueError:
|
|
|
|
# insert literal `$'
|
|
|
|
done[n] = v.replace('$$', '$')
|
|
|
|
else:
|
|
|
|
done[n] = v
|
|
|
|
|
|
|
|
# do variable interpolation here
|
|
|
|
while notdone:
|
|
|
|
for name in notdone.keys():
|
|
|
|
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()
|
|
|
|
|
2010-10-10 06:54:59 -03:00
|
|
|
# strip spurious spaces
|
|
|
|
for k, v in done.items():
|
|
|
|
if isinstance(v, str):
|
|
|
|
done[k] = v.strip()
|
|
|
|
|
2010-03-04 20:16:02 -04:00
|
|
|
# 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
|
2000-09-16 21:53:02 -03:00
|
|
|
'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 1:
|
|
|
|
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
|
2010-03-04 20:16:02 -04:00
|
|
|
|
|
|
|
|
|
|
|
_config_vars = None
|
|
|
|
|
|
|
|
def _init_posix():
|
|
|
|
"""Initialize the module as appropriate for POSIX systems."""
|
2013-04-08 16:20:09 -03:00
|
|
|
# _sysconfigdata is generated at build time, see the sysconfig module
|
|
|
|
from _sysconfigdata import build_time_vars
|
2010-03-04 20:16:02 -04:00
|
|
|
global _config_vars
|
2013-04-08 16:20:09 -03:00
|
|
|
_config_vars = {}
|
|
|
|
_config_vars.update(build_time_vars)
|
2010-03-04 20:16:02 -04:00
|
|
|
|
|
|
|
|
|
|
|
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_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
|
|
|
|
|
2013-01-31 05:24:55 -04:00
|
|
|
# OS X platforms require special customization to handle
|
|
|
|
# multi-architecture, multi-os-version installers
|
2010-03-04 20:16:02 -04:00
|
|
|
if sys.platform == 'darwin':
|
2013-01-31 05:24:55 -04:00
|
|
|
import _osx_support
|
|
|
|
_osx_support.customize_config_vars(_config_vars)
|
2010-03-04 20:16:02 -04:00
|
|
|
|
|
|
|
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)
|