当前位置: 首页>>代码示例>>Python>>正文


Python sysconfig.get_config_var方法代码示例

本文整理汇总了Python中sysconfig.get_config_var方法的典型用法代码示例。如果您正苦于以下问题:Python sysconfig.get_config_var方法的具体用法?Python sysconfig.get_config_var怎么用?Python sysconfig.get_config_var使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sysconfig的用法示例。


在下文中一共展示了sysconfig.get_config_var方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _pep425_get_abi

# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import get_config_var [as 别名]
def _pep425_get_abi():
    """
    :return:
        A unicode string of the system abi. Will be something like: "cp27m",
        "cp33m", etc.
    """

    try:
        soabi = sysconfig.get_config_var('SOABI')
        if soabi:
            if soabi.startswith('cpython-'):
                return 'cp%s' % soabi.split('-')[1]
            return soabi.replace('.', '_').replace('-', '_')
    except (IOError, NameError):
        pass

    impl = _pep425_implementation()
    suffix = ''
    if impl == 'cp':
        suffix += 'm'
    if sys.maxunicode == 0x10ffff and sys.version_info < (3, 3):
        suffix += 'u'
    return '%s%s%s' % (impl, ''.join(map(str_cls, _pep425_version())), suffix) 
开发者ID:wbond,项目名称:oscrypto,代码行数:25,代码来源:_pep425.py

示例2: _make_temp_dir_for_build

# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import get_config_var [as 别名]
def _make_temp_dir_for_build(TEMPDIR):
    # When tests are run from the Python build directory, it is best practice
    # to keep the test files in a subfolder.  It eases the cleanup of leftover
    # files using command "make distclean".
    if sysconfig.is_python_build():
        TEMPDIR = os.path.join(sysconfig.get_config_var('srcdir'), 'build')
        TEMPDIR = os.path.abspath(TEMPDIR)
        try:
            os.mkdir(TEMPDIR)
        except FileExistsError:
            pass

    # Define a writable temp dir that will be used as cwd while running
    # the tests. The name of the dir includes the pid to allow parallel
    # testing (see the -j option).
    TESTCWD = 'test_python_{}'.format(os.getpid())

    TESTCWD = os.path.join(TEMPDIR, TESTCWD)
    return TEMPDIR, TESTCWD 
开发者ID:war-and-code,项目名称:jawfish,代码行数:21,代码来源:regrtest.py

示例3: getusersitepackages

# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import get_config_var [as 别名]
def getusersitepackages():
    """Returns the user-specific site-packages directory path.

    If the global variable ``USER_SITE`` is not initialized yet, this
    function will also set it.
    """
    global USER_SITE
    user_base = getuserbase() # this will also set USER_BASE

    if USER_SITE is not None:
        return USER_SITE

    from sysconfig import get_path
    import os

    if sys.platform == 'darwin':
        from sysconfig import get_config_var
        if get_config_var('PYTHONFRAMEWORK'):
            USER_SITE = get_path('purelib', 'osx_framework_user')
            return USER_SITE

    USER_SITE = get_path('purelib', '%s_user' % os.name)
    return USER_SITE 
开发者ID:glmcdona,项目名称:meddle,代码行数:25,代码来源:site.py

示例4: test_sysconfig_compiler_vars

# 需要导入模块: import sysconfig [as 别名]
# 或者: from 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')) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_sysconfig.py

示例5: _get_xxmodule_path

# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import get_config_var [as 别名]
def _get_xxmodule_path():
    # FIXME when run from regrtest, srcdir seems to be '.', which does not help
    # us find the xxmodule.c file
    srcdir = sysconfig.get_config_var('srcdir')
    candidates = [
        # use installed copy if available
        os.path.join(os.path.dirname(__file__), 'xxmodule.c'),
        # otherwise try using copy from build directory
        os.path.join(srcdir, 'Modules', 'xxmodule.c'),
        # srcdir mysteriously can be $srcdir/Lib/distutils/tests when
        # this file is run from its parent directory, so walk up the
        # tree to find the real srcdir
        os.path.join(srcdir, '..', '..', '..', 'Modules', 'xxmodule.c'),
    ]
    for path in candidates:
        if os.path.exists(path):
            return path 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:support.py

示例6: test_getgroups

# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import get_config_var [as 别名]
def test_getgroups(self):
        with os.popen('id -G 2>/dev/null') as idg:
            groups = idg.read().strip()
            ret = idg.close()

        if ret != None or not groups:
            raise unittest.SkipTest("need working 'id -G'")

        # Issues 16698: OS X ABIs prior to 10.6 have limits on getgroups()
        if sys.platform == 'darwin':
            import sysconfig
            dt = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') or '10.0'
            if tuple(int(n) for n in dt.split('.')[0:2]) < (10, 6):
                raise unittest.SkipTest("getgroups(2) is broken prior to 10.6")

        # 'id -G' and 'os.getgroups()' should return the same
        # groups, ignoring order and duplicates.
        # #10822 - it is implementation defined whether posix.getgroups()
        # includes the effective gid so we include it anyway, since id -G does
        self.assertEqual(
                set([int(x) for x in groups.split()]),
                set(posix.getgroups() + [posix.getegid()])) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:24,代码来源:test_posix.py

示例7: get_sysconfig__CONFIG_VARS

# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import get_config_var [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)) 
开发者ID:war-and-code,项目名称:jawfish,代码行数:7,代码来源:regrtest.py

示例8: python_is_optimized

# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import get_config_var [as 别名]
def python_is_optimized():
    """Find if Python was built with optimizations."""
    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' 
开发者ID:war-and-code,项目名称:jawfish,代码行数:10,代码来源:support.py

示例9: get_ext_filename

# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import get_config_var [as 别名]
def get_ext_filename(self, ext_name):
        from distutils.sysconfig import get_config_var
        ext_path = ext_name.split('.')
        filename = build_ext.get_ext_filename(self, ext_name)
        name, ext_suffix = os.path.splitext(filename)
        return os.path.join(*ext_path) + ext_suffix 
开发者ID:pyscf,项目名称:pyscf,代码行数:8,代码来源:setup.py

示例10: python_is_optimized

# 需要导入模块: import sysconfig [as 别名]
# 或者: from 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' 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:12,代码来源:support.py

示例11: run_unittest

# 需要导入模块: import sysconfig [as 别名]
# 或者: from 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. 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:40,代码来源:support.py

示例12: get_python_version

# 需要导入模块: import sysconfig [as 别名]
# 或者: from 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 
开发者ID:pykaldi,项目名称:pykaldi,代码行数:13,代码来源:find_python_library.py

示例13: get_config_var

# 需要导入模块: import sysconfig [as 别名]
# 或者: from 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 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:8,代码来源:pep425tags.py

示例14: get_impl_ver

# 需要导入模块: import sysconfig [as 别名]
# 或者: from 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 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:8,代码来源:pep425tags.py

示例15: get_flag

# 需要导入模块: import sysconfig [as 别名]
# 或者: from 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 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:12,代码来源:pep425tags.py


注:本文中的sysconfig.get_config_var方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。