2001-07-18 18:39:56 +00: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 23:46:33 +00:00
|
|
|
|
|
|
|
|
Written by: Fred L. Drake, Jr.
|
|
|
|
|
Email: <fdrake@acm.org>
|
2010-01-29 11:41:03 +00:00
|
|
|
|
|
|
|
|
**This module has been moved out of Distutils and will be removed from
|
2010-02-02 23:16:13 +00:00
|
|
|
Python in the next version (3.3)**
|
1998-12-18 23:46:33 +00:00
|
|
|
"""
|
|
|
|
|
|
2000-06-03 00:44:30 +00:00
|
|
|
__revision__ = "$Id$"
|
1998-12-18 23:46:33 +00:00
|
|
|
|
2007-05-25 18:39:29 +00:00
|
|
|
import io
|
1999-01-06 14:46:06 +00:00
|
|
|
import os
|
|
|
|
|
import re
|
2010-01-29 11:41:03 +00:00
|
|
|
from warnings import warn
|
1998-12-18 23:46:33 +00:00
|
|
|
|
2010-01-29 11:41:03 +00:00
|
|
|
from distutils.errors import DistutilsPlatformError
|
2000-02-02 00:05:14 +00:00
|
|
|
|
2010-01-29 11:41:03 +00:00
|
|
|
# importing sysconfig from Lib
|
|
|
|
|
# to avoid this module to shadow it
|
|
|
|
|
_sysconfig = __import__('sysconfig')
|
2000-03-09 15:54:52 +00:00
|
|
|
|
2010-01-29 11:46:31 +00:00
|
|
|
# names defined here to keep backward compatibility
|
|
|
|
|
# for APIs that were relocated
|
|
|
|
|
get_python_version = _sysconfig.get_python_version
|
|
|
|
|
get_config_h_filename = _sysconfig.get_config_h_filename
|
|
|
|
|
parse_config_h = _sysconfig.parse_config_h
|
|
|
|
|
get_config_vars = _sysconfig.get_config_vars
|
|
|
|
|
get_config_var = _sysconfig.get_config_var
|
|
|
|
|
from distutils.ccompiler import customize_compiler
|
|
|
|
|
|
2010-01-29 11:41:03 +00:00
|
|
|
_DEPRECATION_MSG = ("distutils.sysconfig.%s is deprecated. "
|
|
|
|
|
"Use the APIs provided by the sysconfig module instead")
|
|
|
|
|
|
|
|
|
|
def _get_project_base():
|
|
|
|
|
return _sysconfig._PROJECT_BASE
|
|
|
|
|
|
|
|
|
|
project_base = _get_project_base()
|
|
|
|
|
|
|
|
|
|
class _DeprecatedBool(int):
|
|
|
|
|
def __nonzero__(self):
|
|
|
|
|
warn(_DEPRECATION_MSG % 'get_python_version', DeprecationWarning)
|
|
|
|
|
return super(_DeprecatedBool, self).__nonzero__()
|
Merged revisions 59376-59406 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59377 | georg.brandl | 2007-12-06 01:24:23 +0100 (Thu, 06 Dec 2007) | 2 lines
Add another GHOP student to ACKS.
........
r59378 | raymond.hettinger | 2007-12-06 01:56:53 +0100 (Thu, 06 Dec 2007) | 5 lines
Fix Issue 1045.
Factor-out common calling code by simplifying the length_hint API.
Speed-up the function by caching the PyObject_String for the attribute lookup.
........
r59380 | georg.brandl | 2007-12-06 02:52:24 +0100 (Thu, 06 Dec 2007) | 2 lines
Diverse markup fixes.
........
r59383 | georg.brandl | 2007-12-06 10:45:39 +0100 (Thu, 06 Dec 2007) | 2 lines
Better re.split examples.
........
r59386 | christian.heimes | 2007-12-06 14:15:13 +0100 (Thu, 06 Dec 2007) | 2 lines
Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Added several small unit tests for sysconfig.
........
r59387 | christian.heimes | 2007-12-06 14:30:11 +0100 (Thu, 06 Dec 2007) | 1 line
Silence more warnings, _CRT_NONSTDC_NO_DEPRECATE is already defined in pyconfig.h but several projects don't include it.
........
r59389 | christian.heimes | 2007-12-06 14:55:01 +0100 (Thu, 06 Dec 2007) | 1 line
Disabled one test that is failing on Unix
........
r59399 | christian.heimes | 2007-12-06 22:13:06 +0100 (Thu, 06 Dec 2007) | 8 lines
Several Windows related cleanups:
* Removed a #define from pyconfig.h. The macro was already defined a few lines higher.
* Fixed path to tix in the build_tkinter.py script
* Changed make_buildinfo.c to use versions of unlink and strcat which are considered safe by Windows (as suggested by MvL).
* Removed two defines from pyproject.vsprops that are no longer required. Both are defined in pyconfig.h and make_buildinfo.c doesn't use the unsafe versions any more (as suggested by MvL).
* Added some more information about PGO and the property files to PCbuild9/readme.txt.
Are you fine with the changes, Martin?
........
r59400 | raymond.hettinger | 2007-12-07 02:53:01 +0100 (Fri, 07 Dec 2007) | 4 lines
Don't have the docs berate themselves. Keep a professional tone.
If a todo is needed, put it in the tracker.
........
r59402 | georg.brandl | 2007-12-07 10:07:10 +0100 (Fri, 07 Dec 2007) | 3 lines
Increase unit test coverage of SimpleXMLRPCServer.
Written for GHOP by Turkay Eren.
........
r59406 | georg.brandl | 2007-12-07 16:16:57 +0100 (Fri, 07 Dec 2007) | 2 lines
Update to windows doc from Robert.
........
2007-12-08 15:33:56 +00:00
|
|
|
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60568 | christian.heimes | 2008-02-04 19:48:38 +0100 (Mon, 04 Feb 2008) | 1 line
Increase debugging to investige failing tests on some build bots
........
r60570 | christian.heimes | 2008-02-04 20:30:05 +0100 (Mon, 04 Feb 2008) | 1 line
Small adjustments for test compact freelist test. It's no passing on Windows as well.
........
r60573 | amaury.forgeotdarc | 2008-02-04 21:53:14 +0100 (Mon, 04 Feb 2008) | 2 lines
Correct quotes in NEWS file
........
r60575 | amaury.forgeotdarc | 2008-02-04 22:45:05 +0100 (Mon, 04 Feb 2008) | 13 lines
#1750076: Debugger did not step on every iteration of a while statement.
The mapping between bytecode offsets and source lines (lnotab) did not contain
an entry for the beginning of the loop.
Now it does, and the lnotab can be a bit larger:
in particular, several statements on the same line generate several entries.
However, this does not bother the settrace function, which will trigger only
one 'line' event.
The lnotab seems to be exactly the same as with python2.4.
........
r60584 | amaury.forgeotdarc | 2008-02-05 01:26:21 +0100 (Tue, 05 Feb 2008) | 3 lines
Change r60575 broke test_compile:
there is no need to emit co_lnotab item when both offsets are zeros.
........
r60587 | skip.montanaro | 2008-02-05 03:32:16 +0100 (Tue, 05 Feb 2008) | 1 line
sync with most recent version from python-mode sf project
........
r60588 | lars.gustaebel | 2008-02-05 12:51:40 +0100 (Tue, 05 Feb 2008) | 5 lines
Issue #2004: Use mode 0700 for temporary directories and default
permissions for missing directories.
(will backport to 2.5)
........
r60590 | georg.brandl | 2008-02-05 13:01:24 +0100 (Tue, 05 Feb 2008) | 2 lines
Convert external links to internal links. Fixes #2010.
........
r60592 | marc-andre.lemburg | 2008-02-05 15:50:40 +0100 (Tue, 05 Feb 2008) | 3 lines
Keep distutils Python 2.1 compatible (or even Python 2.4 in this case).
........
r60593 | andrew.kuchling | 2008-02-05 17:06:57 +0100 (Tue, 05 Feb 2008) | 5 lines
Update PEP URL.
(This code is duplicated between pydoc and DocXMLRPCServer; maybe it
should be refactored as a GHOP project.)
2.5.2 backport candidate.
........
r60596 | guido.van.rossum | 2008-02-05 18:32:15 +0100 (Tue, 05 Feb 2008) | 2 lines
In the experimental 'Scanner' feature, the group count was set wrong.
........
r60602 | facundo.batista | 2008-02-05 20:03:32 +0100 (Tue, 05 Feb 2008) | 3 lines
Issue 1951. Converts wave test cases to unittest.
........
r60603 | georg.brandl | 2008-02-05 20:07:10 +0100 (Tue, 05 Feb 2008) | 2 lines
Actually run the test.
........
r60604 | skip.montanaro | 2008-02-05 20:24:30 +0100 (Tue, 05 Feb 2008) | 2 lines
correct object name
........
r60605 | georg.brandl | 2008-02-05 20:58:17 +0100 (Tue, 05 Feb 2008) | 7 lines
* Use the same code to profile for test_profile and test_cprofile.
* Convert both to unittest.
* Use the same unit testing code.
* Include the expected output in both test files.
* Make it possible to regenerate the expected output by running
the file as a script with an '-r' argument.
........
r60613 | raymond.hettinger | 2008-02-06 02:49:00 +0100 (Wed, 06 Feb 2008) | 1 line
Sync-up with Py3k work.
........
r60614 | christian.heimes | 2008-02-06 13:44:34 +0100 (Wed, 06 Feb 2008) | 1 line
Limit free list of method and builtin function objects to 256 entries each.
........
r60616 | christian.heimes | 2008-02-06 14:33:44 +0100 (Wed, 06 Feb 2008) | 7 lines
Unified naming convention for free lists and their limits. All free lists
in Object/ are named ``free_list``, the counter ``numfree`` and the upper
limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block.
The chances should make it easier to adjust Python for platforms with
less memory, e.g. mobile phones.
........
2008-02-06 14:31:34 +00:00
|
|
|
def _python_build():
|
2010-01-29 11:41:03 +00:00
|
|
|
return _DeprecatedBool(_sysconfig.is_python_build())
|
|
|
|
|
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60568-60598,60600-60616 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60568 | christian.heimes | 2008-02-04 19:48:38 +0100 (Mon, 04 Feb 2008) | 1 line
Increase debugging to investige failing tests on some build bots
........
r60570 | christian.heimes | 2008-02-04 20:30:05 +0100 (Mon, 04 Feb 2008) | 1 line
Small adjustments for test compact freelist test. It's no passing on Windows as well.
........
r60573 | amaury.forgeotdarc | 2008-02-04 21:53:14 +0100 (Mon, 04 Feb 2008) | 2 lines
Correct quotes in NEWS file
........
r60575 | amaury.forgeotdarc | 2008-02-04 22:45:05 +0100 (Mon, 04 Feb 2008) | 13 lines
#1750076: Debugger did not step on every iteration of a while statement.
The mapping between bytecode offsets and source lines (lnotab) did not contain
an entry for the beginning of the loop.
Now it does, and the lnotab can be a bit larger:
in particular, several statements on the same line generate several entries.
However, this does not bother the settrace function, which will trigger only
one 'line' event.
The lnotab seems to be exactly the same as with python2.4.
........
r60584 | amaury.forgeotdarc | 2008-02-05 01:26:21 +0100 (Tue, 05 Feb 2008) | 3 lines
Change r60575 broke test_compile:
there is no need to emit co_lnotab item when both offsets are zeros.
........
r60587 | skip.montanaro | 2008-02-05 03:32:16 +0100 (Tue, 05 Feb 2008) | 1 line
sync with most recent version from python-mode sf project
........
r60588 | lars.gustaebel | 2008-02-05 12:51:40 +0100 (Tue, 05 Feb 2008) | 5 lines
Issue #2004: Use mode 0700 for temporary directories and default
permissions for missing directories.
(will backport to 2.5)
........
r60590 | georg.brandl | 2008-02-05 13:01:24 +0100 (Tue, 05 Feb 2008) | 2 lines
Convert external links to internal links. Fixes #2010.
........
r60592 | marc-andre.lemburg | 2008-02-05 15:50:40 +0100 (Tue, 05 Feb 2008) | 3 lines
Keep distutils Python 2.1 compatible (or even Python 2.4 in this case).
........
r60593 | andrew.kuchling | 2008-02-05 17:06:57 +0100 (Tue, 05 Feb 2008) | 5 lines
Update PEP URL.
(This code is duplicated between pydoc and DocXMLRPCServer; maybe it
should be refactored as a GHOP project.)
2.5.2 backport candidate.
........
r60596 | guido.van.rossum | 2008-02-05 18:32:15 +0100 (Tue, 05 Feb 2008) | 2 lines
In the experimental 'Scanner' feature, the group count was set wrong.
........
r60602 | facundo.batista | 2008-02-05 20:03:32 +0100 (Tue, 05 Feb 2008) | 3 lines
Issue 1951. Converts wave test cases to unittest.
........
r60603 | georg.brandl | 2008-02-05 20:07:10 +0100 (Tue, 05 Feb 2008) | 2 lines
Actually run the test.
........
r60604 | skip.montanaro | 2008-02-05 20:24:30 +0100 (Tue, 05 Feb 2008) | 2 lines
correct object name
........
r60605 | georg.brandl | 2008-02-05 20:58:17 +0100 (Tue, 05 Feb 2008) | 7 lines
* Use the same code to profile for test_profile and test_cprofile.
* Convert both to unittest.
* Use the same unit testing code.
* Include the expected output in both test files.
* Make it possible to regenerate the expected output by running
the file as a script with an '-r' argument.
........
r60613 | raymond.hettinger | 2008-02-06 02:49:00 +0100 (Wed, 06 Feb 2008) | 1 line
Sync-up with Py3k work.
........
r60614 | christian.heimes | 2008-02-06 13:44:34 +0100 (Wed, 06 Feb 2008) | 1 line
Limit free list of method and builtin function objects to 256 entries each.
........
r60616 | christian.heimes | 2008-02-06 14:33:44 +0100 (Wed, 06 Feb 2008) | 7 lines
Unified naming convention for free lists and their limits. All free lists
in Object/ are named ``free_list``, the counter ``numfree`` and the upper
limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block.
The chances should make it easier to adjust Python for platforms with
less memory, e.g. mobile phones.
........
2008-02-06 14:31:34 +00:00
|
|
|
python_build = _python_build()
|
2001-08-02 20:03:12 +00:00
|
|
|
|
2000-04-10 01:17:49 +00:00
|
|
|
def get_python_inc(plat_specific=0, prefix=None):
|
2010-01-29 11:41:03 +00:00
|
|
|
"""This function is deprecated.
|
|
|
|
|
|
|
|
|
|
Return the directory containing installed Python header files.
|
2000-03-09 15:54:52 +00: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 13:41:06 +00:00
|
|
|
(namely pyconfig.h).
|
2000-03-09 15:54:52 +00:00
|
|
|
|
2000-04-10 01:17:49 +00:00
|
|
|
If 'prefix' is supplied, use it instead of sys.prefix or
|
|
|
|
|
sys.exec_prefix -- i.e., ignore 'plat_specific'.
|
2001-12-06 20:51:35 +00:00
|
|
|
"""
|
2010-01-29 11:41:03 +00:00
|
|
|
warn(_DEPRECATION_MSG % 'get_python_inc', DeprecationWarning)
|
|
|
|
|
get_path = _sysconfig.get_path
|
|
|
|
|
|
|
|
|
|
if prefix is not None:
|
|
|
|
|
vars = {'base': prefix}
|
|
|
|
|
return get_path('include', vars=vars)
|
|
|
|
|
|
|
|
|
|
if not plat_specific:
|
|
|
|
|
return get_path('include')
|
2000-03-09 03:16:05 +00:00
|
|
|
else:
|
2010-01-29 11:41:03 +00:00
|
|
|
return get_path('platinclude')
|
2000-03-09 03:16:05 +00:00
|
|
|
|
2010-01-29 11:41:03 +00:00
|
|
|
def get_python_lib(plat_specific=False, standard_lib=False, prefix=None):
|
|
|
|
|
"""This function is deprecated.
|
2000-03-09 03:16:05 +00:00
|
|
|
|
2010-01-29 11:41:03 +00:00
|
|
|
Return the directory containing the Python library (standard or
|
2000-03-09 15:54:52 +00:00
|
|
|
site additions).
|
2000-03-09 03:16:05 +00:00
|
|
|
|
2000-03-09 15:54:52 +00:00
|
|
|
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-04-10 01:17:49 +00:00
|
|
|
If 'prefix' is supplied, use it instead of sys.prefix or
|
|
|
|
|
sys.exec_prefix -- i.e., ignore 'plat_specific'.
|
2000-03-09 15:54:52 +00:00
|
|
|
"""
|
2010-01-29 11:41:03 +00:00
|
|
|
warn(_DEPRECATION_MSG % 'get_python_lib', DeprecationWarning)
|
|
|
|
|
vars = {}
|
|
|
|
|
get_path = _sysconfig.get_path
|
|
|
|
|
if prefix is not None:
|
2000-08-02 01:49:40 +00:00
|
|
|
if plat_specific:
|
2010-01-29 11:41:03 +00:00
|
|
|
vars['platbase'] = prefix
|
2000-03-09 03:16:05 +00:00
|
|
|
else:
|
2010-01-29 11:41:03 +00:00
|
|
|
vars['base'] = prefix
|
|
|
|
|
if standard_lib:
|
|
|
|
|
if plat_specific:
|
|
|
|
|
return get_path('platstdlib', vars=vars)
|
2002-01-31 18:56:00 +00:00
|
|
|
else:
|
2010-01-29 11:41:03 +00:00
|
|
|
return get_path('stdlib', vars=vars)
|
2000-03-09 03:16:05 +00:00
|
|
|
else:
|
2010-01-29 11:41:03 +00:00
|
|
|
if plat_specific:
|
|
|
|
|
return get_path('platlib', vars=vars)
|
2002-11-04 19:53:24 +00:00
|
|
|
else:
|
2010-01-29 11:41:03 +00:00
|
|
|
return get_path('purelib', vars=vars)
|
1998-12-18 23:46:33 +00:00
|
|
|
|
1999-01-06 14:46:06 +00:00
|
|
|
def get_makefile_filename():
|
2010-01-29 11:41:03 +00:00
|
|
|
"""This function is deprecated.
|
2000-03-09 03:16:05 +00:00
|
|
|
|
2010-01-29 11:41:03 +00:00
|
|
|
Return full pathname of installed Makefile from the Python build.
|
1999-01-06 16:28:34 +00:00
|
|
|
"""
|
1998-12-18 23:46:33 +00:00
|
|
|
|
2010-01-29 11:41:03 +00:00
|
|
|
warn(_DEPRECATION_MSG % 'get_makefile_filename', DeprecationWarning)
|
|
|
|
|
return _sysconfig._get_makefile_filename()
|
2000-09-17 00:53:02 +00: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-15 00:03:13 +00:00
|
|
|
def parse_makefile(fn, g=None):
|
2010-01-29 11:41:03 +00:00
|
|
|
"""This function is deprecated.
|
|
|
|
|
|
|
|
|
|
Parse a Makefile-style file.
|
2000-03-09 15:54:52 +00: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 16:28:34 +00:00
|
|
|
"""
|
2010-01-29 11:41:03 +00:00
|
|
|
warn(_DEPRECATION_MSG % 'parse_makefile', DeprecationWarning)
|
|
|
|
|
return _sysconfig._parse_makefile(fn, g)
|
1998-12-18 23:46:33 +00:00
|
|
|
|
2000-09-17 00:53:02 +00:00
|
|
|
def expand_makefile_vars(s, vars):
|
2010-01-29 11:41:03 +00:00
|
|
|
"""This function is deprecated.
|
|
|
|
|
|
|
|
|
|
Expand Makefile-style variables -- "${foo}" or "$(foo)" -- in
|
2000-09-17 00:53:02 +00: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'.
|
|
|
|
|
"""
|
2010-01-29 11:41:03 +00:00
|
|
|
warn('this function will be removed in then next version of Python',
|
|
|
|
|
DeprecationWarning)
|
2000-09-17 00:53:02 +00:00
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
|
|
2007-08-30 03:52:21 +00:00
|
|
|
while True:
|
2000-09-17 00:53:02 +00:00
|
|
|
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
|