Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../usr/lib64/python3....
File: sysconfig.py
"""Access to Python's configuration information."""
[0] Fix | Delete
[1] Fix | Delete
import os
[2] Fix | Delete
import sys
[3] Fix | Delete
from os.path import pardir, realpath
[4] Fix | Delete
[5] Fix | Delete
__all__ = [
[6] Fix | Delete
'get_config_h_filename',
[7] Fix | Delete
'get_config_var',
[8] Fix | Delete
'get_config_vars',
[9] Fix | Delete
'get_makefile_filename',
[10] Fix | Delete
'get_path',
[11] Fix | Delete
'get_path_names',
[12] Fix | Delete
'get_paths',
[13] Fix | Delete
'get_platform',
[14] Fix | Delete
'get_python_version',
[15] Fix | Delete
'get_scheme_names',
[16] Fix | Delete
'parse_config_h',
[17] Fix | Delete
]
[18] Fix | Delete
[19] Fix | Delete
# Keys for get_config_var() that are never converted to Python integers.
[20] Fix | Delete
_ALWAYS_STR = {
[21] Fix | Delete
'MACOSX_DEPLOYMENT_TARGET',
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
_INSTALL_SCHEMES = {
[25] Fix | Delete
'posix_prefix': {
[26] Fix | Delete
'stdlib': '{installed_base}/lib64/python{py_version_short}',
[27] Fix | Delete
'platstdlib': '{platbase}/lib64/python{py_version_short}',
[28] Fix | Delete
'purelib': '{base}/lib/python{py_version_short}/site-packages',
[29] Fix | Delete
'platlib': '{platbase}/lib64/python{py_version_short}/site-packages',
[30] Fix | Delete
'include':
[31] Fix | Delete
'{installed_base}/include/python{py_version_short}{abiflags}',
[32] Fix | Delete
'platinclude':
[33] Fix | Delete
'{installed_platbase}/include/python{py_version_short}{abiflags}',
[34] Fix | Delete
'scripts': '{base}/bin',
[35] Fix | Delete
'data': '{base}',
[36] Fix | Delete
},
[37] Fix | Delete
'posix_home': {
[38] Fix | Delete
'stdlib': '{installed_base}/lib/python',
[39] Fix | Delete
'platstdlib': '{base}/lib/python',
[40] Fix | Delete
'purelib': '{base}/lib/python',
[41] Fix | Delete
'platlib': '{base}/lib/python',
[42] Fix | Delete
'include': '{installed_base}/include/python',
[43] Fix | Delete
'platinclude': '{installed_base}/include/python',
[44] Fix | Delete
'scripts': '{base}/bin',
[45] Fix | Delete
'data': '{base}',
[46] Fix | Delete
},
[47] Fix | Delete
'nt': {
[48] Fix | Delete
'stdlib': '{installed_base}/Lib',
[49] Fix | Delete
'platstdlib': '{base}/Lib',
[50] Fix | Delete
'purelib': '{base}/Lib/site-packages',
[51] Fix | Delete
'platlib': '{base}/Lib/site-packages',
[52] Fix | Delete
'include': '{installed_base}/Include',
[53] Fix | Delete
'platinclude': '{installed_base}/Include',
[54] Fix | Delete
'scripts': '{base}/Scripts',
[55] Fix | Delete
'data': '{base}',
[56] Fix | Delete
},
[57] Fix | Delete
# NOTE: When modifying "purelib" scheme, update site._get_path() too.
[58] Fix | Delete
'nt_user': {
[59] Fix | Delete
'stdlib': '{userbase}/Python{py_version_nodot}',
[60] Fix | Delete
'platstdlib': '{userbase}/Python{py_version_nodot}',
[61] Fix | Delete
'purelib': '{userbase}/Python{py_version_nodot}/site-packages',
[62] Fix | Delete
'platlib': '{userbase}/Python{py_version_nodot}/site-packages',
[63] Fix | Delete
'include': '{userbase}/Python{py_version_nodot}/Include',
[64] Fix | Delete
'scripts': '{userbase}/Python{py_version_nodot}/Scripts',
[65] Fix | Delete
'data': '{userbase}',
[66] Fix | Delete
},
[67] Fix | Delete
'posix_user': {
[68] Fix | Delete
'stdlib': '{userbase}/lib64/python{py_version_short}',
[69] Fix | Delete
'platstdlib': '{userbase}/lib64/python{py_version_short}',
[70] Fix | Delete
'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
[71] Fix | Delete
'platlib': '{userbase}/lib64/python{py_version_short}/site-packages',
[72] Fix | Delete
'include': '{userbase}/include/python{py_version_short}',
[73] Fix | Delete
'scripts': '{userbase}/bin',
[74] Fix | Delete
'data': '{userbase}',
[75] Fix | Delete
},
[76] Fix | Delete
'osx_framework_user': {
[77] Fix | Delete
'stdlib': '{userbase}/lib/python',
[78] Fix | Delete
'platstdlib': '{userbase}/lib/python',
[79] Fix | Delete
'purelib': '{userbase}/lib/python/site-packages',
[80] Fix | Delete
'platlib': '{userbase}/lib/python/site-packages',
[81] Fix | Delete
'include': '{userbase}/include',
[82] Fix | Delete
'scripts': '{userbase}/bin',
[83] Fix | Delete
'data': '{userbase}',
[84] Fix | Delete
},
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
_SCHEME_KEYS = ('stdlib', 'platstdlib', 'purelib', 'platlib', 'include',
[88] Fix | Delete
'scripts', 'data')
[89] Fix | Delete
[90] Fix | Delete
# FIXME don't rely on sys.version here, its format is an implementation detail
[91] Fix | Delete
# of CPython, use sys.version_info or sys.hexversion
[92] Fix | Delete
_PY_VERSION = sys.version.split()[0]
[93] Fix | Delete
_PY_VERSION_SHORT = '%d.%d' % sys.version_info[:2]
[94] Fix | Delete
_PY_VERSION_SHORT_NO_DOT = '%d%d' % sys.version_info[:2]
[95] Fix | Delete
_PREFIX = os.path.normpath(sys.prefix)
[96] Fix | Delete
_BASE_PREFIX = os.path.normpath(sys.base_prefix)
[97] Fix | Delete
_EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
[98] Fix | Delete
_BASE_EXEC_PREFIX = os.path.normpath(sys.base_exec_prefix)
[99] Fix | Delete
_CONFIG_VARS = None
[100] Fix | Delete
_USER_BASE = None
[101] Fix | Delete
[102] Fix | Delete
[103] Fix | Delete
def _safe_realpath(path):
[104] Fix | Delete
try:
[105] Fix | Delete
return realpath(path)
[106] Fix | Delete
except OSError:
[107] Fix | Delete
return path
[108] Fix | Delete
[109] Fix | Delete
if sys.executable:
[110] Fix | Delete
_PROJECT_BASE = os.path.dirname(_safe_realpath(sys.executable))
[111] Fix | Delete
else:
[112] Fix | Delete
# sys.executable can be empty if argv[0] has been changed and Python is
[113] Fix | Delete
# unable to retrieve the real program name
[114] Fix | Delete
_PROJECT_BASE = _safe_realpath(os.getcwd())
[115] Fix | Delete
[116] Fix | Delete
if (os.name == 'nt' and
[117] Fix | Delete
_PROJECT_BASE.lower().endswith(('\\pcbuild\\win32', '\\pcbuild\\amd64'))):
[118] Fix | Delete
_PROJECT_BASE = _safe_realpath(os.path.join(_PROJECT_BASE, pardir, pardir))
[119] Fix | Delete
[120] Fix | Delete
# set for cross builds
[121] Fix | Delete
if "_PYTHON_PROJECT_BASE" in os.environ:
[122] Fix | Delete
_PROJECT_BASE = _safe_realpath(os.environ["_PYTHON_PROJECT_BASE"])
[123] Fix | Delete
[124] Fix | Delete
def _is_python_source_dir(d):
[125] Fix | Delete
for fn in ("Setup", "Setup.local"):
[126] Fix | Delete
if os.path.isfile(os.path.join(d, "Modules", fn)):
[127] Fix | Delete
return True
[128] Fix | Delete
return False
[129] Fix | Delete
[130] Fix | Delete
_sys_home = getattr(sys, '_home', None)
[131] Fix | Delete
[132] Fix | Delete
if os.name == 'nt':
[133] Fix | Delete
def _fix_pcbuild(d):
[134] Fix | Delete
if d and os.path.normcase(d).startswith(
[135] Fix | Delete
os.path.normcase(os.path.join(_PREFIX, "PCbuild"))):
[136] Fix | Delete
return _PREFIX
[137] Fix | Delete
return d
[138] Fix | Delete
_PROJECT_BASE = _fix_pcbuild(_PROJECT_BASE)
[139] Fix | Delete
_sys_home = _fix_pcbuild(_sys_home)
[140] Fix | Delete
[141] Fix | Delete
def is_python_build(check_home=False):
[142] Fix | Delete
if check_home and _sys_home:
[143] Fix | Delete
return _is_python_source_dir(_sys_home)
[144] Fix | Delete
return _is_python_source_dir(_PROJECT_BASE)
[145] Fix | Delete
[146] Fix | Delete
_PYTHON_BUILD = is_python_build(True)
[147] Fix | Delete
[148] Fix | Delete
if _PYTHON_BUILD:
[149] Fix | Delete
for scheme in ('posix_prefix', 'posix_home'):
[150] Fix | Delete
_INSTALL_SCHEMES[scheme]['include'] = '{srcdir}/Include'
[151] Fix | Delete
_INSTALL_SCHEMES[scheme]['platinclude'] = '{projectbase}/.'
[152] Fix | Delete
[153] Fix | Delete
[154] Fix | Delete
def _subst_vars(s, local_vars):
[155] Fix | Delete
try:
[156] Fix | Delete
return s.format(**local_vars)
[157] Fix | Delete
except KeyError:
[158] Fix | Delete
try:
[159] Fix | Delete
return s.format(**os.environ)
[160] Fix | Delete
except KeyError as var:
[161] Fix | Delete
raise AttributeError('{%s}' % var) from None
[162] Fix | Delete
[163] Fix | Delete
def _extend_dict(target_dict, other_dict):
[164] Fix | Delete
target_keys = target_dict.keys()
[165] Fix | Delete
for key, value in other_dict.items():
[166] Fix | Delete
if key in target_keys:
[167] Fix | Delete
continue
[168] Fix | Delete
target_dict[key] = value
[169] Fix | Delete
[170] Fix | Delete
[171] Fix | Delete
def _expand_vars(scheme, vars):
[172] Fix | Delete
res = {}
[173] Fix | Delete
if vars is None:
[174] Fix | Delete
vars = {}
[175] Fix | Delete
_extend_dict(vars, get_config_vars())
[176] Fix | Delete
[177] Fix | Delete
for key, value in _INSTALL_SCHEMES[scheme].items():
[178] Fix | Delete
if os.name in ('posix', 'nt'):
[179] Fix | Delete
value = os.path.expanduser(value)
[180] Fix | Delete
res[key] = os.path.normpath(_subst_vars(value, vars))
[181] Fix | Delete
return res
[182] Fix | Delete
[183] Fix | Delete
[184] Fix | Delete
def _get_default_scheme():
[185] Fix | Delete
if os.name == 'posix':
[186] Fix | Delete
# the default scheme for posix is posix_prefix
[187] Fix | Delete
return 'posix_prefix'
[188] Fix | Delete
return os.name
[189] Fix | Delete
[190] Fix | Delete
[191] Fix | Delete
# NOTE: site.py has copy of this function.
[192] Fix | Delete
# Sync it when modify this function.
[193] Fix | Delete
def _getuserbase():
[194] Fix | Delete
env_base = os.environ.get("PYTHONUSERBASE", None)
[195] Fix | Delete
if env_base:
[196] Fix | Delete
return env_base
[197] Fix | Delete
[198] Fix | Delete
def joinuser(*args):
[199] Fix | Delete
return os.path.expanduser(os.path.join(*args))
[200] Fix | Delete
[201] Fix | Delete
if os.name == "nt":
[202] Fix | Delete
base = os.environ.get("APPDATA") or "~"
[203] Fix | Delete
return joinuser(base, "Python")
[204] Fix | Delete
[205] Fix | Delete
if sys.platform == "darwin" and sys._framework:
[206] Fix | Delete
return joinuser("~", "Library", sys._framework,
[207] Fix | Delete
"%d.%d" % sys.version_info[:2])
[208] Fix | Delete
[209] Fix | Delete
return joinuser("~", ".local")
[210] Fix | Delete
[211] Fix | Delete
[212] Fix | Delete
def _parse_makefile(filename, vars=None):
[213] Fix | Delete
"""Parse a Makefile-style file.
[214] Fix | Delete
[215] Fix | Delete
A dictionary containing name/value pairs is returned. If an
[216] Fix | Delete
optional dictionary is passed in as the second argument, it is
[217] Fix | Delete
used instead of a new dictionary.
[218] Fix | Delete
"""
[219] Fix | Delete
# Regexes needed for parsing Makefile (and similar syntaxes,
[220] Fix | Delete
# like old-style Setup files).
[221] Fix | Delete
import re
[222] Fix | Delete
_variable_rx = re.compile(r"([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)")
[223] Fix | Delete
_findvar1_rx = re.compile(r"\$\(([A-Za-z][A-Za-z0-9_]*)\)")
[224] Fix | Delete
_findvar2_rx = re.compile(r"\${([A-Za-z][A-Za-z0-9_]*)}")
[225] Fix | Delete
[226] Fix | Delete
if vars is None:
[227] Fix | Delete
vars = {}
[228] Fix | Delete
done = {}
[229] Fix | Delete
notdone = {}
[230] Fix | Delete
[231] Fix | Delete
with open(filename, errors="surrogateescape") as f:
[232] Fix | Delete
lines = f.readlines()
[233] Fix | Delete
[234] Fix | Delete
for line in lines:
[235] Fix | Delete
if line.startswith('#') or line.strip() == '':
[236] Fix | Delete
continue
[237] Fix | Delete
m = _variable_rx.match(line)
[238] Fix | Delete
if m:
[239] Fix | Delete
n, v = m.group(1, 2)
[240] Fix | Delete
v = v.strip()
[241] Fix | Delete
# `$$' is a literal `$' in make
[242] Fix | Delete
tmpv = v.replace('$$', '')
[243] Fix | Delete
[244] Fix | Delete
if "$" in tmpv:
[245] Fix | Delete
notdone[n] = v
[246] Fix | Delete
else:
[247] Fix | Delete
try:
[248] Fix | Delete
if n in _ALWAYS_STR:
[249] Fix | Delete
raise ValueError
[250] Fix | Delete
[251] Fix | Delete
v = int(v)
[252] Fix | Delete
except ValueError:
[253] Fix | Delete
# insert literal `$'
[254] Fix | Delete
done[n] = v.replace('$$', '$')
[255] Fix | Delete
else:
[256] Fix | Delete
done[n] = v
[257] Fix | Delete
[258] Fix | Delete
# do variable interpolation here
[259] Fix | Delete
variables = list(notdone.keys())
[260] Fix | Delete
[261] Fix | Delete
# Variables with a 'PY_' prefix in the makefile. These need to
[262] Fix | Delete
# be made available without that prefix through sysconfig.
[263] Fix | Delete
# Special care is needed to ensure that variable expansion works, even
[264] Fix | Delete
# if the expansion uses the name without a prefix.
[265] Fix | Delete
renamed_variables = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS')
[266] Fix | Delete
[267] Fix | Delete
while len(variables) > 0:
[268] Fix | Delete
for name in tuple(variables):
[269] Fix | Delete
value = notdone[name]
[270] Fix | Delete
m1 = _findvar1_rx.search(value)
[271] Fix | Delete
m2 = _findvar2_rx.search(value)
[272] Fix | Delete
if m1 and m2:
[273] Fix | Delete
m = m1 if m1.start() < m2.start() else m2
[274] Fix | Delete
else:
[275] Fix | Delete
m = m1 if m1 else m2
[276] Fix | Delete
if m is not None:
[277] Fix | Delete
n = m.group(1)
[278] Fix | Delete
found = True
[279] Fix | Delete
if n in done:
[280] Fix | Delete
item = str(done[n])
[281] Fix | Delete
elif n in notdone:
[282] Fix | Delete
# get it on a subsequent round
[283] Fix | Delete
found = False
[284] Fix | Delete
elif n in os.environ:
[285] Fix | Delete
# do it like make: fall back to environment
[286] Fix | Delete
item = os.environ[n]
[287] Fix | Delete
[288] Fix | Delete
elif n in renamed_variables:
[289] Fix | Delete
if (name.startswith('PY_') and
[290] Fix | Delete
name[3:] in renamed_variables):
[291] Fix | Delete
item = ""
[292] Fix | Delete
[293] Fix | Delete
elif 'PY_' + n in notdone:
[294] Fix | Delete
found = False
[295] Fix | Delete
[296] Fix | Delete
else:
[297] Fix | Delete
item = str(done['PY_' + n])
[298] Fix | Delete
[299] Fix | Delete
else:
[300] Fix | Delete
done[n] = item = ""
[301] Fix | Delete
[302] Fix | Delete
if found:
[303] Fix | Delete
after = value[m.end():]
[304] Fix | Delete
value = value[:m.start()] + item + after
[305] Fix | Delete
if "$" in after:
[306] Fix | Delete
notdone[name] = value
[307] Fix | Delete
else:
[308] Fix | Delete
try:
[309] Fix | Delete
if name in _ALWAYS_STR:
[310] Fix | Delete
raise ValueError
[311] Fix | Delete
value = int(value)
[312] Fix | Delete
except ValueError:
[313] Fix | Delete
done[name] = value.strip()
[314] Fix | Delete
else:
[315] Fix | Delete
done[name] = value
[316] Fix | Delete
variables.remove(name)
[317] Fix | Delete
[318] Fix | Delete
if name.startswith('PY_') \
[319] Fix | Delete
and name[3:] in renamed_variables:
[320] Fix | Delete
[321] Fix | Delete
name = name[3:]
[322] Fix | Delete
if name not in done:
[323] Fix | Delete
done[name] = value
[324] Fix | Delete
[325] Fix | Delete
else:
[326] Fix | Delete
# bogus variable reference (e.g. "prefix=$/opt/python");
[327] Fix | Delete
# just drop it since we can't deal
[328] Fix | Delete
done[name] = value
[329] Fix | Delete
variables.remove(name)
[330] Fix | Delete
[331] Fix | Delete
# strip spurious spaces
[332] Fix | Delete
for k, v in done.items():
[333] Fix | Delete
if isinstance(v, str):
[334] Fix | Delete
done[k] = v.strip()
[335] Fix | Delete
[336] Fix | Delete
# save the results in the global dictionary
[337] Fix | Delete
vars.update(done)
[338] Fix | Delete
return vars
[339] Fix | Delete
[340] Fix | Delete
[341] Fix | Delete
def get_makefile_filename():
[342] Fix | Delete
"""Return the path of the Makefile."""
[343] Fix | Delete
if _PYTHON_BUILD:
[344] Fix | Delete
return os.path.join(_sys_home or _PROJECT_BASE, "Makefile")
[345] Fix | Delete
if hasattr(sys, 'abiflags'):
[346] Fix | Delete
config_dir_name = 'config-%s%s' % (_PY_VERSION_SHORT, sys.abiflags)
[347] Fix | Delete
else:
[348] Fix | Delete
config_dir_name = 'config'
[349] Fix | Delete
if hasattr(sys.implementation, '_multiarch'):
[350] Fix | Delete
config_dir_name += '-%s' % sys.implementation._multiarch
[351] Fix | Delete
return os.path.join(get_path('stdlib'), config_dir_name, 'Makefile')
[352] Fix | Delete
[353] Fix | Delete
[354] Fix | Delete
def _get_sysconfigdata_name():
[355] Fix | Delete
return os.environ.get('_PYTHON_SYSCONFIGDATA_NAME',
[356] Fix | Delete
'_sysconfigdata_{abi}_{platform}_{multiarch}'.format(
[357] Fix | Delete
abi=sys.abiflags,
[358] Fix | Delete
platform=sys.platform,
[359] Fix | Delete
multiarch=getattr(sys.implementation, '_multiarch', ''),
[360] Fix | Delete
))
[361] Fix | Delete
[362] Fix | Delete
[363] Fix | Delete
def _generate_posix_vars():
[364] Fix | Delete
"""Generate the Python module containing build-time variables."""
[365] Fix | Delete
import pprint
[366] Fix | Delete
vars = {}
[367] Fix | Delete
# load the installed Makefile:
[368] Fix | Delete
makefile = get_makefile_filename()
[369] Fix | Delete
try:
[370] Fix | Delete
_parse_makefile(makefile, vars)
[371] Fix | Delete
except OSError as e:
[372] Fix | Delete
msg = "invalid Python installation: unable to open %s" % makefile
[373] Fix | Delete
if hasattr(e, "strerror"):
[374] Fix | Delete
msg = msg + " (%s)" % e.strerror
[375] Fix | Delete
raise OSError(msg)
[376] Fix | Delete
# load the installed pyconfig.h:
[377] Fix | Delete
config_h = get_config_h_filename()
[378] Fix | Delete
try:
[379] Fix | Delete
with open(config_h) as f:
[380] Fix | Delete
parse_config_h(f, vars)
[381] Fix | Delete
except OSError as e:
[382] Fix | Delete
msg = "invalid Python installation: unable to open %s" % config_h
[383] Fix | Delete
if hasattr(e, "strerror"):
[384] Fix | Delete
msg = msg + " (%s)" % e.strerror
[385] Fix | Delete
raise OSError(msg)
[386] Fix | Delete
# On AIX, there are wrong paths to the linker scripts in the Makefile
[387] Fix | Delete
# -- these paths are relative to the Python source, but when installed
[388] Fix | Delete
# the scripts are in another directory.
[389] Fix | Delete
if _PYTHON_BUILD:
[390] Fix | Delete
vars['BLDSHARED'] = vars['LDSHARED']
[391] Fix | Delete
[392] Fix | Delete
# There's a chicken-and-egg situation on OS X with regards to the
[393] Fix | Delete
# _sysconfigdata module after the changes introduced by #15298:
[394] Fix | Delete
# get_config_vars() is called by get_platform() as part of the
[395] Fix | Delete
# `make pybuilddir.txt` target -- which is a precursor to the
[396] Fix | Delete
# _sysconfigdata.py module being constructed. Unfortunately,
[397] Fix | Delete
# get_config_vars() eventually calls _init_posix(), which attempts
[398] Fix | Delete
# to import _sysconfigdata, which we won't have built yet. In order
[399] Fix | Delete
# for _init_posix() to work, if we're on Darwin, just mock up the
[400] Fix | Delete
# _sysconfigdata module manually and populate it with the build vars.
[401] Fix | Delete
# This is more than sufficient for ensuring the subsequent call to
[402] Fix | Delete
# get_platform() succeeds.
[403] Fix | Delete
name = _get_sysconfigdata_name()
[404] Fix | Delete
if 'darwin' in sys.platform:
[405] Fix | Delete
import types
[406] Fix | Delete
module = types.ModuleType(name)
[407] Fix | Delete
module.build_time_vars = vars
[408] Fix | Delete
sys.modules[name] = module
[409] Fix | Delete
[410] Fix | Delete
pybuilddir = 'build/lib.%s-%s' % (get_platform(), _PY_VERSION_SHORT)
[411] Fix | Delete
if hasattr(sys, "gettotalrefcount"):
[412] Fix | Delete
pybuilddir += '-pydebug'
[413] Fix | Delete
os.makedirs(pybuilddir, exist_ok=True)
[414] Fix | Delete
destfile = os.path.join(pybuilddir, name + '.py')
[415] Fix | Delete
[416] Fix | Delete
with open(destfile, 'w', encoding='utf8') as f:
[417] Fix | Delete
f.write('# system configuration generated and used by'
[418] Fix | Delete
' the sysconfig module\n')
[419] Fix | Delete
f.write('build_time_vars = ')
[420] Fix | Delete
pprint.pprint(vars, stream=f)
[421] Fix | Delete
[422] Fix | Delete
# Create file used for sys.path fixup -- see Modules/getpath.c
[423] Fix | Delete
with open('pybuilddir.txt', 'w', encoding='utf8') as f:
[424] Fix | Delete
f.write(pybuilddir)
[425] Fix | Delete
[426] Fix | Delete
def _init_posix(vars):
[427] Fix | Delete
"""Initialize the module as appropriate for POSIX systems."""
[428] Fix | Delete
# _sysconfigdata is generated at build time, see _generate_posix_vars()
[429] Fix | Delete
name = _get_sysconfigdata_name()
[430] Fix | Delete
_temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
[431] Fix | Delete
build_time_vars = _temp.build_time_vars
[432] Fix | Delete
vars.update(build_time_vars)
[433] Fix | Delete
[434] Fix | Delete
def _init_non_posix(vars):
[435] Fix | Delete
"""Initialize the module as appropriate for NT"""
[436] Fix | Delete
# set basic install directories
[437] Fix | Delete
import _imp
[438] Fix | Delete
vars['LIBDEST'] = get_path('stdlib')
[439] Fix | Delete
vars['BINLIBDEST'] = get_path('platstdlib')
[440] Fix | Delete
vars['INCLUDEPY'] = get_path('include')
[441] Fix | Delete
vars['EXT_SUFFIX'] = _imp.extension_suffixes()[0]
[442] Fix | Delete
vars['EXE'] = '.exe'
[443] Fix | Delete
vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
[444] Fix | Delete
vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable))
[445] Fix | Delete
[446] Fix | Delete
#
[447] Fix | Delete
# public APIs
[448] Fix | Delete
#
[449] Fix | Delete
[450] Fix | Delete
[451] Fix | Delete
def parse_config_h(fp, vars=None):
[452] Fix | Delete
"""Parse a config.h-style file.
[453] Fix | Delete
[454] Fix | Delete
A dictionary containing name/value pairs is returned. If an
[455] Fix | Delete
optional dictionary is passed in as the second argument, it is
[456] Fix | Delete
used instead of a new dictionary.
[457] Fix | Delete
"""
[458] Fix | Delete
if vars is None:
[459] Fix | Delete
vars = {}
[460] Fix | Delete
import re
[461] Fix | Delete
define_rx = re.compile("#define ([A-Z][A-Za-z0-9_]+) (.*)\n")
[462] Fix | Delete
undef_rx = re.compile("/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/\n")
[463] Fix | Delete
[464] Fix | Delete
while True:
[465] Fix | Delete
line = fp.readline()
[466] Fix | Delete
if not line:
[467] Fix | Delete
break
[468] Fix | Delete
m = define_rx.match(line)
[469] Fix | Delete
if m:
[470] Fix | Delete
n, v = m.group(1, 2)
[471] Fix | Delete
try:
[472] Fix | Delete
if n in _ALWAYS_STR:
[473] Fix | Delete
raise ValueError
[474] Fix | Delete
v = int(v)
[475] Fix | Delete
except ValueError:
[476] Fix | Delete
pass
[477] Fix | Delete
vars[n] = v
[478] Fix | Delete
else:
[479] Fix | Delete
m = undef_rx.match(line)
[480] Fix | Delete
if m:
[481] Fix | Delete
vars[m.group(1)] = 0
[482] Fix | Delete
return vars
[483] Fix | Delete
[484] Fix | Delete
[485] Fix | Delete
def get_config_h_filename():
[486] Fix | Delete
"""Return the path of pyconfig.h."""
[487] Fix | Delete
if _PYTHON_BUILD:
[488] Fix | Delete
if os.name == "nt":
[489] Fix | Delete
inc_dir = os.path.join(_sys_home or _PROJECT_BASE, "PC")
[490] Fix | Delete
else:
[491] Fix | Delete
inc_dir = _sys_home or _PROJECT_BASE
[492] Fix | Delete
else:
[493] Fix | Delete
inc_dir = get_path('platinclude')
[494] Fix | Delete
return os.path.join(inc_dir, 'pyconfig-64.h')
[495] Fix | Delete
[496] Fix | Delete
[497] Fix | Delete
def get_scheme_names():
[498] Fix | Delete
"""Return a tuple containing the schemes names."""
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function