mirror of https://github.com/python/cpython.git
Update and add docstrings.
This commit is contained in:
parent
c553358c63
commit
522af3a126
|
@ -1,8 +1,5 @@
|
||||||
"""Prototype sysconfig module that loads information when run as a script,
|
"""Provide access to Python's configuration information. The specific names
|
||||||
but only defines constants when imported.
|
defined in the module depend heavily on the platform and configuration.
|
||||||
|
|
||||||
This should be run as a script as one of the last steps of the Python
|
|
||||||
installation process.
|
|
||||||
|
|
||||||
Written by: Fred L. Drake, Jr.
|
Written by: Fred L. Drake, Jr.
|
||||||
Email: <fdrake@acm.org>
|
Email: <fdrake@acm.org>
|
||||||
|
@ -18,14 +15,20 @@
|
||||||
|
|
||||||
|
|
||||||
def get_config_h_filename():
|
def get_config_h_filename():
|
||||||
|
"""Return full pathname of installed config.h file."""
|
||||||
return os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3],
|
return os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3],
|
||||||
"config", "config.h")
|
"config", "config.h")
|
||||||
|
|
||||||
def get_makefile_filename():
|
def get_makefile_filename():
|
||||||
|
"""Return full pathname of installed Makefile from the Python build."""
|
||||||
return os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3],
|
return os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3],
|
||||||
"config", "Makefile")
|
"config", "Makefile")
|
||||||
|
|
||||||
def parse_config_h(fp, g=None):
|
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:
|
if g is None:
|
||||||
g = {}
|
g = {}
|
||||||
define_rx = re.compile("#define ([A-Z][A-Z0-9_]+) (.*)\n")
|
define_rx = re.compile("#define ([A-Z][A-Z0-9_]+) (.*)\n")
|
||||||
|
@ -48,6 +51,10 @@ def parse_config_h(fp, g=None):
|
||||||
return g
|
return g
|
||||||
|
|
||||||
def parse_makefile(fp, g=None):
|
def parse_makefile(fp, 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.
|
||||||
|
"""
|
||||||
if g is None:
|
if g is None:
|
||||||
g = {}
|
g = {}
|
||||||
variable_rx = re.compile("([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)\n")
|
variable_rx = re.compile("([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)\n")
|
||||||
|
@ -114,6 +121,7 @@ def parse_makefile(fp, g=None):
|
||||||
|
|
||||||
|
|
||||||
def _init_posix():
|
def _init_posix():
|
||||||
|
"""Initialize the module as appropriate for POSIX systems."""
|
||||||
g = globals()
|
g = globals()
|
||||||
# load the installed config.h:
|
# load the installed config.h:
|
||||||
parse_config_h(open(get_config_h_filename()), g)
|
parse_config_h(open(get_config_h_filename()), g)
|
||||||
|
|
Loading…
Reference in New Issue