本文整理匯總了Python中distutils.sysconfig.get_config_var方法的典型用法代碼示例。如果您正苦於以下問題:Python sysconfig.get_config_var方法的具體用法?Python sysconfig.get_config_var怎麽用?Python sysconfig.get_config_var使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類distutils.sysconfig
的用法示例。
在下文中一共展示了sysconfig.get_config_var方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_tests
# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_var [as 別名]
def get_tests(config={}):
tests = []
tests += list_test_cases(DSATest)
try:
from Crypto.PublicKey import _fastmath
tests += list_test_cases(DSAFastMathTest)
except ImportError:
from distutils.sysconfig import get_config_var
import inspect
_fm_path = os.path.normpath(os.path.dirname(os.path.abspath(
inspect.getfile(inspect.currentframe())))
+"/../../PublicKey/_fastmath"+get_config_var("SO"))
if os.path.exists(_fm_path):
raise ImportError("While the _fastmath module exists, importing "+
"it failed. This may point to the gmp or mpir shared library "+
"not being in the path. _fastmath was found at "+_fm_path)
tests += list_test_cases(DSASlowMathTest)
return tests
示例2: get_tests
# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_var [as 別名]
def get_tests(config={}):
tests = []
tests += list_test_cases(RSATest)
try:
from Crypto.PublicKey import _fastmath
tests += list_test_cases(RSAFastMathTest)
except ImportError:
from distutils.sysconfig import get_config_var
import inspect
_fm_path = os.path.normpath(os.path.dirname(os.path.abspath(
inspect.getfile(inspect.currentframe())))
+"/../../PublicKey/_fastmath"+get_config_var("SO"))
if os.path.exists(_fm_path):
raise ImportError("While the _fastmath module exists, importing "+
"it failed. This may point to the gmp or mpir shared library "+
"not being in the path. _fastmath was found at "+_fm_path)
if config.get('slow_tests',1):
tests += list_test_cases(RSASlowMathTest)
return tests
示例3: get_ext_filename
# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_var [as 別名]
def get_ext_filename(self, fullname):
filename = _build_ext.get_ext_filename(self, fullname)
if fullname in self.ext_map:
ext = self.ext_map[fullname]
use_abi3 = (
six.PY3
and getattr(ext, 'py_limited_api')
and get_abi3_suffix()
)
if use_abi3:
so_ext = get_config_var('EXT_SUFFIX')
filename = filename[:-len(so_ext)]
filename = filename + get_abi3_suffix()
if isinstance(ext, Library):
fn, ext = os.path.splitext(filename)
return self.shlib_compiler.library_filename(fn, libtype)
elif use_stubs and ext._links_to_dynamic:
d, fn = os.path.split(filename)
return os.path.join(d, 'dl-' + fn)
return filename
示例4: test_sysconfig_compiler_vars
# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_var [as 別名]
def test_sysconfig_compiler_vars(self):
# On OS X, binary installers support extension module building on
# various levels of the operating system with differing Xcode
# configurations. This requires customization of some of the
# compiler configuration directives to suit the environment on
# the installed machine. Some of these customizations may require
# running external programs and, so, are deferred until needed by
# the first extension module build. With Python 3.3, only
# the Distutils version of sysconfig is used for extension module
# builds, which happens earlier in the Distutils tests. This may
# cause the following tests to fail since no tests have caused
# the global version of sysconfig to call the customization yet.
# The solution for now is to simply skip this test in this case.
# The longer-term solution is to only have one version of sysconfig.
import sysconfig as global_sysconfig
if sysconfig.get_config_var('CUSTOMIZED_OSX_COMPILER'):
self.skipTest('compiler flags customized')
self.assertEqual(global_sysconfig.get_config_var('LDSHARED'), sysconfig.get_config_var('LDSHARED'))
self.assertEqual(global_sysconfig.get_config_var('CC'), sysconfig.get_config_var('CC'))
示例5: _fixup_command
# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_var [as 別名]
def _fixup_command(self, cmd):
# When Python was build with --enable-shared, -L. is not good enough
# to find the libpython<blah>.so. This is because regrtest runs it
# under a tempdir, not in the top level where the .so lives. By the
# time we've gotten here, Python's already been chdir'd to the
# tempdir.
#
# To further add to the fun, we can't just add library_dirs to the
# Extension() instance because that doesn't get plumbed through to the
# final compiler command.
if (sysconfig.get_config_var('Py_ENABLE_SHARED') and
not sys.platform.startswith('win')):
runshared = sysconfig.get_config_var('RUNSHARED')
if runshared is None:
cmd.library_dirs = ['.']
else:
name, equals, value = runshared.partition('=')
cmd.library_dirs = value.split(os.pathsep)
示例6: python_is_optimized
# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_var [as 別名]
def python_is_optimized():
"""Find if Python was built with optimizations."""
# We don't have sysconfig on Py2.6:
import sysconfig
cflags = sysconfig.get_config_var('PY_CFLAGS') or ''
final_opt = ""
for opt in cflags.split():
if opt.startswith('-O'):
final_opt = opt
return final_opt != '' and final_opt != '-O0'
示例7: run_unittest
# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_var [as 別名]
def run_unittest(*classes):
"""Run tests from unittest.TestCase-derived classes."""
valid_types = (unittest.TestSuite, unittest.TestCase)
suite = unittest.TestSuite()
for cls in classes:
if isinstance(cls, str):
if cls in sys.modules:
suite.addTest(unittest.findTestCases(sys.modules[cls]))
else:
raise ValueError("str arguments must be keys in sys.modules")
elif isinstance(cls, valid_types):
suite.addTest(cls)
else:
suite.addTest(unittest.makeSuite(cls))
def case_pred(test):
if match_tests is None:
return True
for name in test.id().split("."):
if fnmatch.fnmatchcase(name, match_tests):
return True
return False
_filter_suite(suite, case_pred)
_run_suite(suite)
# We don't have sysconfig on Py2.6:
# #=======================================================================
# # Check for the presence of docstrings.
#
# HAVE_DOCSTRINGS = (check_impl_detail(cpython=False) or
# sys.platform == 'win32' or
# sysconfig.get_config_var('WITH_DOC_STRINGS'))
#
# requires_docstrings = unittest.skipUnless(HAVE_DOCSTRINGS,
# "test requires docstrings")
#
#
# #=======================================================================
# doctest driver.
示例8: get_python_version
# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_var [as 別名]
def get_python_version():
"""Get version associated with the current python interpreter."""
python_version = sysconfig.get_config_var('VERSION')
if not python_version:
python_version = sysconfig.get_config_var('py_version_short')
if not python_version:
python_version = ".".join(map(str, sys.version_info[:2]))
return python_version
示例9: pythonlib_dir
# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_var [as 別名]
def pythonlib_dir():
"""return path where libpython* is."""
if sys.platform == 'win32':
return os.path.join(sys.prefix, "libs")
else:
return get_config_var('LIBDIR')
示例10: get_config_var
# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_var [as 別名]
def get_config_var(var):
try:
return sysconfig.get_config_var(var)
except IOError as e: # Issue #1074
warnings.warn("{0}".format(e), RuntimeWarning)
return None
示例11: get_impl_ver
# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_var [as 別名]
def get_impl_ver():
"""Return implementation version."""
impl_ver = get_config_var("py_version_nodot")
if not impl_ver or get_abbr_impl() == 'pp':
impl_ver = ''.join(map(str, get_impl_version_info()))
return impl_ver
示例12: get_flag
# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_var [as 別名]
def get_flag(var, fallback, expected=True, warn=True):
"""Use a fallback method for determining SOABI flags if the needed config
var is unset or unavailable."""
val = get_config_var(var)
if val is None:
if warn:
logger.debug("Config variable '%s' is unset, Python ABI tag may "
"be incorrect", var)
return fallback()
return val == expected
示例13: get_abi_tag
# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_var [as 別名]
def get_abi_tag():
"""Return the ABI tag based on SOABI (if available) or emulate SOABI
(CPython 2, PyPy)."""
soabi = get_config_var('SOABI')
impl = get_abbr_impl()
if not soabi and impl in ('cp', 'pp') and hasattr(sys, 'maxunicode'):
d = ''
m = ''
u = ''
if get_flag('Py_DEBUG',
lambda: hasattr(sys, 'gettotalrefcount'),
warn=(impl == 'cp')):
d = 'd'
if get_flag('WITH_PYMALLOC',
lambda: impl == 'cp',
warn=(impl == 'cp')):
m = 'm'
if get_flag('Py_UNICODE_SIZE',
lambda: sys.maxunicode == 0x10ffff,
expected=4,
warn=(impl == 'cp' and
sys.version_info < (3, 3))) \
and sys.version_info < (3, 3):
u = 'u'
abi = '%s%s%s%s%s' % (impl, get_impl_ver(), d, m, u)
elif soabi and soabi.startswith('cpython-'):
abi = 'cp' + soabi.split('-')[1]
elif soabi:
abi = soabi.replace('.', '_').replace('-', '_')
else:
abi = None
return abi
示例14: get_config_var
# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_var [as 別名]
def get_config_var(var):
try:
return sysconfig.get_config_var(var)
except IOError as e: # pip Issue #1074
warnings.warn("{0}".format(e), RuntimeWarning)
return None
示例15: get_flag
# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_var [as 別名]
def get_flag(var, fallback, expected=True, warn=True):
"""Use a fallback method for determining SOABI flags if the needed config
var is unset or unavailable."""
val = get_config_var(var)
if val is None:
if warn:
warnings.warn("Config variable '{0}' is unset, Python ABI tag may "
"be incorrect".format(var), RuntimeWarning, 2)
return fallback()
return val == expected