本文整理汇总了Python中sysconfig.get_scheme_names函数的典型用法代码示例。如果您正苦于以下问题:Python get_scheme_names函数的具体用法?Python get_scheme_names怎么用?Python get_scheme_names使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_scheme_names函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_scheme_names
def test_get_scheme_names(self):
wanted = ['nt', 'nt_user', 'osx_framework_user',
'posix_home', 'posix_prefix', 'posix_user']
if sys.platform == 'uwp':
wanted.extend(['uwp_os', 'uwp_os_user'])
wanted = tuple(wanted)
self.assertEqual(get_scheme_names(), wanted)
示例2: find_queries_path
def find_queries_path():
possible_paths = []
# Try all possible schemes where python expects data to stay.
for scheme in sysconfig.get_scheme_names():
default_path = sysconfig.get_path(name='data', scheme=scheme)
possible_paths.append(os.path.join(default_path, 'tract_querier', 'queries'))
# Try to manage Virtual Environments on some OSes,
# where data is not put the 'local' subdirectory,
# but at the root of the virtual environment.
if default_path.endswith('local'):
possible_paths.append(os.path.join(default_path.rsplit('local', 1)[0],
'tract_querier', 'queries'))
# Case where the Tract_querier is cloned from git and simply
# added to the python path, without installation.
possible_paths.append(os.path.abspath(os.path.join(
os.path.dirname(__file__), 'data')))
paths_found = [path for path in possible_paths if os.path.exists(path)]
if not paths_found:
raise Exception('Default path for queries not found')
return paths_found[0]
示例3: sysconfig2
def sysconfig2():
# import sysconfig module - Provide access to Python’s configuration information
import sysconfig
# returns an installation path corresponding to the path name
print("Path Name : ", sysconfig.get_path("stdlib"))
print()
# returns a string that identifies the current platform.
print("Current Platform : ", sysconfig.get_platform())
print()
# returns the MAJOR.MINOR Python version number as a string
print("Python Version Number : ", sysconfig.get_python_version())
print()
# returns a tuple containing all path names
print("Path Names : ", sysconfig.get_path_names())
print()
# returns a tuple containing all schemes
print("Scheme Names : ", sysconfig.get_scheme_names())
print()
# returns the value of a single variable name.
print("Variable name LIBDIR : ", sysconfig.get_config_var('LIBDIR'))
# returns the value of a single variable name.
print("Variable name LIBDEST : ", sysconfig.get_config_var('LIBDEST'))
示例4: get_soabi
def get_soabi():
soabi = None
try:
soabi = sysconfig.get_config_var('SOABI')
arch = sysconfig.get_config_var('MULTIARCH')
except IOError:
pass
if soabi and arch and 'pypy' in sysconfig.get_scheme_names():
soabi = '%s-%s' % (soabi, arch)
if soabi is None and 'pypy' in sysconfig.get_scheme_names():
# NOTE(sigmavirus24): PyPy only added support for the SOABI config var
# to sysconfig in 2015. That was well after 2.2.1 was published in the
# Ubuntu 14.04 archive.
for suffix, _, _ in imp.get_suffixes():
if suffix.startswith('.pypy') and suffix.endswith('.so'):
soabi = suffix.split('.')[1]
break
return soabi
示例5: get_sys_path
def get_sys_path(location, name):
# Returns the sysconfig path for a distribution, or None
for scheme in sysconfig.get_scheme_names():
for path_type in ["platlib", "purelib"]:
path = sysconfig.get_path(path_type, scheme)
try:
if samefile(path, location):
return sysconfig.get_path(name, scheme)
except EnvironmentError:
pass
示例6: test_user_site
def test_user_site(self):
# test install with --user
# preparing the environment for the test
self.old_user_base = get_config_var('userbase')
self.old_user_site = get_path('purelib', '%s_user' % os.name)
self.tmpdir = self.mkdtemp()
self.user_base = os.path.join(self.tmpdir, 'B')
self.user_site = os.path.join(self.tmpdir, 'S')
_CONFIG_VARS['userbase'] = self.user_base
scheme = '%s_user' % os.name
_SCHEMES.set(scheme, 'purelib', self.user_site)
def _expanduser(path):
if path[0] == '~':
path = os.path.normpath(self.tmpdir) + path[1:]
return path
self.old_expand = os.path.expanduser
os.path.expanduser = _expanduser
def cleanup():
_CONFIG_VARS['userbase'] = self.old_user_base
_SCHEMES.set(scheme, 'purelib', self.old_user_site)
os.path.expanduser = self.old_expand
self.addCleanup(cleanup)
schemes = get_scheme_names()
for key in ('nt_user', 'posix_user', 'os2_home'):
self.assertIn(key, schemes)
dist = Distribution({'name': 'xx'})
cmd = install_dist(dist)
# making sure the user option is there
options = [name for name, short, lable in
cmd.user_options]
self.assertIn('user', options)
# setting a value
cmd.user = True
# user base and site shouldn't be created yet
self.assertFalse(os.path.exists(self.user_base))
self.assertFalse(os.path.exists(self.user_site))
# let's run finalize
cmd.ensure_finalized()
# now they should
self.assertTrue(os.path.exists(self.user_base))
self.assertTrue(os.path.exists(self.user_site))
self.assertIn('userbase', cmd.config_vars)
self.assertIn('usersite', cmd.config_vars)
示例7: get_soabi
def get_soabi():
try:
return sysconfig.get_config_var('SOABI')
except IOError:
pass
if 'pypy' in sysconfig.get_scheme_names():
# NOTE(sigmavirus24): PyPy only added support for the SOABI config var
# to sysconfig in 2015. That was well after 2.2.1 was published in the
# Ubuntu 14.04 archive.
for suffix, _, _ in imp.get_suffixes():
if suffix.startswith('.pypy') and suffix.endswith('.so'):
return suffix.split('.')[1]
return None
示例8: get_soabi
def get_soabi():
soabi = None
try:
soabi = sysconfig.get_config_var("SOABI")
except IOError:
pass
if soabi is None and "pypy" in sysconfig.get_scheme_names():
# NOTE(sigmavirus24): PyPy only added support for the SOABI config var
# to sysconfig in 2015. That was well after 2.2.1 was published in the
# Ubuntu 14.04 archive.
for suffix, _, _ in imp.get_suffixes():
if suffix.startswith(".pypy") and suffix.endswith(".so"):
soabi = suffix.split(".")[1]
break
return soabi
示例9: test_get_scheme_names
def test_get_scheme_names(self):
wanted = ('nt', 'nt_user', 'os2', 'os2_home', 'osx_framework_user',
'posix_home', 'posix_prefix', 'posix_user', 'pypy')
self.assertEqual(get_scheme_names(), wanted)
示例10:
# coding=utf-8
# 使用sysconfig
import sysconfig
print sysconfig.get_config_var('Py_ENABLE_SHARED')
print sysconfig.get_config_var('LIBDIR')
print sysconfig.get_config_vars('AR', "CXX")
print sysconfig.get_scheme_names()
print sysconfig.get_path_names()
print sysconfig.get_python_version()
print sysconfig.get_platform()
# return true if current python installation was built from source
print sysconfig.is_python_build()
print sysconfig.get_config_h_filename()
print sysconfig._get_makefile_filename()
示例11: test_get_scheme_names
def test_get_scheme_names(self):
wanted = {'nt', 'nt_user', 'os2', 'os2_home', 'osx_framework_user',
'posix_home', 'posix_prefix', 'posix_user', 'java',
'java_user'}
self.assertEqual({name for name in get_scheme_names()}, wanted)
示例12: Copyright
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright (c) 2010 Doug Hellmann. All rights reserved.
#
"""Installation schemes.
"""
# end_pymotw_header
import sysconfig
for name in sysconfig.get_scheme_names():
print name
示例13: print
#!/usr/bin/python
# import sysconfig module
#provide access to python's configuration information
import sysconfig
#returns an installation path corresponding to the path name
print("Path Name : ", sysconfig.get_path("stdlib"))
print()
#returns a string that identifies the current platform
print("Current Platform : ", sysconfig.get_platform())
print()
# returns the MAJOR.MINOR Python version number as a string
print("Python Version Number : ", sysconfig.get_python_version())
print()
#returns a tuple containing all schemes
print("Scheme Names : ", sysconfig.get_scheme_names())
print()