本文整理汇总了Python中sysconfig._CONFIG_VARS属性的典型用法代码示例。如果您正苦于以下问题:Python sysconfig._CONFIG_VARS属性的具体用法?Python sysconfig._CONFIG_VARS怎么用?Python sysconfig._CONFIG_VARS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类sysconfig
的用法示例。
在下文中一共展示了sysconfig._CONFIG_VARS属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import _CONFIG_VARS [as 别名]
def setUp(self):
"""Make a copy of sys.path"""
super(TestSysConfig, self).setUp()
self.sys_path = sys.path[:]
self.makefile = None
# patching os.uname
if hasattr(os, 'uname'):
self.uname = os.uname
self._uname = os.uname()
else:
self.uname = None
self._uname = None
os.uname = self._get_uname
# saving the environment
self.name = os.name
self.platform = sys.platform
self.version = sys.version
self.sep = os.sep
self.join = os.path.join
self.isabs = os.path.isabs
self.splitdrive = os.path.splitdrive
self._config_vars = copy(sysconfig._CONFIG_VARS)
self.old_environ = deepcopy(os.environ)
示例2: test_getuserbase
# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import _CONFIG_VARS [as 别名]
def test_getuserbase(self):
site.USER_BASE = None
user_base = site.getuserbase()
# the call sets site.USER_BASE
self.assertEqual(site.USER_BASE, user_base)
# let's set PYTHONUSERBASE and see if it uses it
site.USER_BASE = None
import sysconfig
sysconfig._CONFIG_VARS = None
with EnvironmentVarGuard() as environ:
environ['PYTHONUSERBASE'] = 'xoxo'
self.assertTrue(site.getuserbase().startswith('xoxo'),
site.getuserbase())
示例3: tearDown
# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import _CONFIG_VARS [as 别名]
def tearDown(self):
sys.path[:] = self.sys_path
self._cleanup_testfn()
if self.uname is not None:
os.uname = self.uname
else:
del os.uname
os.name = self.name
sys.platform = self.platform
sys.version = self.version
os.sep = self.sep
os.path.join = self.join
os.path.isabs = self.isabs
os.path.splitdrive = self.splitdrive
sysconfig._CONFIG_VARS = self._config_vars[0]
sysconfig._CONFIG_VARS.clear()
sysconfig._CONFIG_VARS.update(self._config_vars[1])
for var, value in self._changed_envvars:
os.environ[var] = value
for var in self._added_envvars:
os.environ.pop(var, None)
super(TestSysConfig, self).tearDown()
示例4: setUp
# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import _CONFIG_VARS [as 别名]
def setUp(self):
"""Make a copy of sys.path"""
super(TestSysConfig, self).setUp()
self.sys_path = sys.path[:]
self.makefile = None
# patching os.uname
if hasattr(os, 'uname'):
self.uname = os.uname
self._uname = os.uname()
else:
self.uname = None
self._uname = None
os.uname = self._get_uname
# saving the environment
self.name = os.name
self.platform = sys.platform
if not is_jython:
self.version = sys.version
self.sep = os.sep
self.join = os.path.join
self.isabs = os.path.isabs
self.splitdrive = os.path.splitdrive
self._config_vars = copy(sysconfig._CONFIG_VARS)
self.old_environ = deepcopy(os.environ)
示例5: get_sysconfig__CONFIG_VARS
# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import _CONFIG_VARS [as 别名]
def get_sysconfig__CONFIG_VARS(self):
# make sure the dict is initialized
sysconfig.get_config_var('prefix')
return (id(sysconfig._CONFIG_VARS), sysconfig._CONFIG_VARS,
dict(sysconfig._CONFIG_VARS))
示例6: restore_sysconfig__CONFIG_VARS
# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import _CONFIG_VARS [as 别名]
def restore_sysconfig__CONFIG_VARS(self, saved):
sysconfig._CONFIG_VARS = saved[1]
sysconfig._CONFIG_VARS.clear()
sysconfig._CONFIG_VARS.update(saved[2])
示例7: test_version_int
# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import _CONFIG_VARS [as 别名]
def test_version_int(self):
source = self.mkdtemp()
target = self.mkdtemp()
expected = self.write_sample_scripts(source)
cmd = self.get_build_scripts_cmd(target,
[os.path.join(source, fn)
for fn in expected])
cmd.finalize_options()
# http://bugs.python.org/issue4524
#
# On linux-g++-32 with command line `./configure --enable-ipv6
# --with-suffix=3`, python is compiled okay but the build scripts
# failed when writing the name of the executable
old = sysconfig.get_config_vars().get('VERSION')
sysconfig._CONFIG_VARS['VERSION'] = 4
try:
cmd.run()
finally:
if old is not None:
sysconfig._CONFIG_VARS['VERSION'] = old
built = os.listdir(target)
for name in expected:
self.assertIn(name, built)
示例8: tearDown
# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import _CONFIG_VARS [as 别名]
def tearDown(self):
"""Restore sys.path"""
sys.path[:] = self.sys_path
if self.makefile is not None:
os.unlink(self.makefile)
self._cleanup_testfn()
if self.uname is not None:
os.uname = self.uname
else:
del os.uname
os.name = self.name
sys.platform = self.platform
sys.version = self.version
os.sep = self.sep
os.path.join = self.join
os.path.isabs = self.isabs
os.path.splitdrive = self.splitdrive
sysconfig._CONFIG_VARS = copy(self._config_vars)
for key, value in self.old_environ.items():
if os.environ.get(key) != value:
os.environ[key] = value
for key in os.environ.keys():
if key not in self.old_environ:
del os.environ[key]
super(TestSysConfig, self).tearDown()
示例9: setUp
# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import _CONFIG_VARS [as 别名]
def setUp(self):
"""Save a copy of sys.path"""
self.sys_path = sys.path[:]
self.old_base = site.USER_BASE
self.old_site = site.USER_SITE
self.old_prefixes = site.PREFIXES
self.old_vars = copy(sysconfig._CONFIG_VARS)
示例10: tearDown
# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import _CONFIG_VARS [as 别名]
def tearDown(self):
"""Restore sys.path"""
sys.path[:] = self.sys_path
site.USER_BASE = self.old_base
site.USER_SITE = self.old_site
site.PREFIXES = self.old_prefixes
sysconfig._CONFIG_VARS = self.old_vars
示例11: test_no_home_directory
# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import _CONFIG_VARS [as 别名]
def test_no_home_directory(self):
# bpo-10496: getuserbase() and getusersitepackages() must not fail if
# the current user has no home directory (if expanduser() returns the
# path unchanged).
site.USER_SITE = None
site.USER_BASE = None
sysconfig._CONFIG_VARS = None
with EnvironmentVarGuard() as environ, \
support.swap_attr(os.path, 'expanduser', lambda path: path):
del environ['PYTHONUSERBASE']
del environ['APPDATA']
user_base = site.getuserbase()
self.assertTrue(user_base.startswith('~' + os.sep),
user_base)
user_site = site.getusersitepackages()
self.assertTrue(user_site.startswith(user_base), user_site)
def fake_isdir(path):
fake_isdir.arg = path
return False
fake_isdir.arg = None
def must_not_be_called(*args):
raise AssertionError
with support.swap_attr(os.path, 'isdir', fake_isdir), \
support.swap_attr(site, 'addsitedir', must_not_be_called), \
support.swap_attr(site, 'ENABLE_USER_SITE', True):
# addusersitepackages() must not add user_site to sys.path
# if it is not an existing directory
known_paths = set()
site.addusersitepackages(known_paths)
self.assertEqual(fake_isdir.arg, user_site)
self.assertFalse(known_paths)
示例12: test_version_int
# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import _CONFIG_VARS [as 别名]
def test_version_int(self):
source = self.mkdtemp()
target = self.mkdtemp()
expected = self.write_sample_scripts(source)
cmd = self.get_build_scripts_cmd(target,
[os.path.join(source, fn)
for fn in expected])
cmd.finalize_options()
# http://bugs.python.org/issue4524
#
# On linux-g++-32 with command line `./configure --enable-ipv6
# --with-suffix=3`, python is compiled okay but the build scripts
# failed when writing the name of the executable
old = sysconfig.get_config_vars().get('VERSION')
sysconfig._CONFIG_VARS['VERSION'] = 4
try:
cmd.run()
finally:
if old is not None:
sysconfig._CONFIG_VARS['VERSION'] = old
built = os.listdir(target)
for name in expected:
self.assertTrue(name in built)