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