當前位置: 首頁>>代碼示例>>Python>>正文


Python sysconfig.get_config_vars方法代碼示例

本文整理匯總了Python中distutils.sysconfig.get_config_vars方法的典型用法代碼示例。如果您正苦於以下問題:Python sysconfig.get_config_vars方法的具體用法?Python sysconfig.get_config_vars怎麽用?Python sysconfig.get_config_vars使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在distutils.sysconfig的用法示例。


在下文中一共展示了sysconfig.get_config_vars方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: expanduser

# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_vars [as 別名]
def expanduser(path):
    """
    Expand ~ and ~user constructions.

    Includes a workaround for http://bugs.python.org/issue14768
    """
    expanded = os.path.expanduser(path)
    if path.startswith('~/') and expanded.startswith('//'):
        expanded = expanded[1:]
    return expanded


# packages in the stdlib that may have installation metadata, but should not be
# considered 'installed'.  this theoretically could be determined based on
# dist.location (py27:`sysconfig.get_paths()['stdlib']`,
# py26:sysconfig.get_config_vars('LIBDEST')), but fear platform variation may
# make this ineffective, so hard-coding 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:19,代碼來源:__init__.py

示例2: test_customize_compiler_before_get_config_vars

# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_vars [as 別名]
def test_customize_compiler_before_get_config_vars(self):
        # Issue #21923: test that a Distribution compiler
        # instance can be called without an explicit call to
        # get_config_vars().
        with open(TESTFN, 'w') as f:
            f.writelines(textwrap.dedent('''\
                from distutils.core import Distribution
                config = Distribution().get_command_obj('config')
                # try_compile may pass or it may fail if no compiler
                # is found but it should not raise an exception.
                rc = config.try_compile('int x;')
                '''))
        p = subprocess.Popen([str(sys.executable), TESTFN],
                stdout=subprocess.PIPE,
                stderr=subprocess.STDOUT,
                universal_newlines=True)
        outs, errs = p.communicate()
        self.assertEqual(0, p.returncode, "Subprocess failed: " + outs) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:20,代碼來源:test_sysconfig.py

示例3: fix_warnings

# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_vars [as 別名]
def fix_warnings():
    import platform
    if platform.system() == 'Darwin':
        # Get rid of various flags that cause warnings and/or errors
        import distutils.sysconfig as ds
        import string
        a = ds.get_config_vars()
        for k, v in list(a.items()):
            try:
                if string.find(v, '-Wstrict-prototypes') != -1:
                    a[k] = string.replace(v, '-Wstrict-prototypes', '')
                if string.find(v, '-arch i386') != -1:
                    a[k] = string.replace(v, '-arch i386', '')
                if string.find(v, '-mno-fused-madd ') != -1:
                    a[k] = string.replace(v, '-mno-fused-madd', '')
            except:
                pass 
開發者ID:mattloper,項目名稱:opendr,代碼行數:19,代碼來源:fix_warnings.py

示例4: test_osx_cc_overrides_ldshared

# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_vars [as 別名]
def test_osx_cc_overrides_ldshared(self):
        # Issue #18080:
        # ensure that setting CC env variable also changes default linker
        def gcv(v):
            if v == 'LDSHARED':
                return 'gcc-4.2 -bundle -undefined dynamic_lookup '
            return 'gcc-4.2'

        def gcvs(*args, _orig=sysconfig.get_config_vars):
            if args:
                return list(map(sysconfig.get_config_var, args))
            return _orig()
        sysconfig.get_config_var = gcv
        sysconfig.get_config_vars = gcvs
        with EnvironmentVarGuard() as env:
            env['CC'] = 'my_cc'
            del env['LDSHARED']
            sysconfig.customize_compiler(self.cc)
        self.assertEqual(self.cc.linker_so[0], 'my_cc') 
開發者ID:pypa,項目名稱:setuptools,代碼行數:21,代碼來源:test_unixccompiler.py

示例5: test_osx_explicit_ldshared

# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_vars [as 別名]
def test_osx_explicit_ldshared(self):
        # Issue #18080:
        # ensure that setting CC env variable does not change
        #   explicit LDSHARED setting for linker
        def gcv(v):
            if v == 'LDSHARED':
                return 'gcc-4.2 -bundle -undefined dynamic_lookup '
            return 'gcc-4.2'

        def gcvs(*args, _orig=sysconfig.get_config_vars):
            if args:
                return list(map(sysconfig.get_config_var, args))
            return _orig()
        sysconfig.get_config_var = gcv
        sysconfig.get_config_vars = gcvs
        with EnvironmentVarGuard() as env:
            env['CC'] = 'my_cc'
            env['LDSHARED'] = 'my_ld -bundle -dynamic'
            sysconfig.customize_compiler(self.cc)
        self.assertEqual(self.cc.linker_so[0], 'my_ld') 
開發者ID:pypa,項目名稱:setuptools,代碼行數:22,代碼來源:test_unixccompiler.py

示例6: _c_arch_flags

# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_vars [as 別名]
def _c_arch_flags(self):
        """ Return detected arch flags from CFLAGS """
        from distutils import sysconfig
        try:
            cflags = sysconfig.get_config_vars()['CFLAGS']
        except KeyError:
            return []
        arch_re = re.compile(r"-arch\s+(\w+)")
        arch_flags = []
        for arch in arch_re.findall(cflags):
            arch_flags += ['-arch', arch]
        return arch_flags 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:14,代碼來源:gnu.py

示例7: UnixCCompiler__compile

# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_vars [as 別名]
def UnixCCompiler__compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
    """Compile a single source files with a Unix-style compiler."""
    # HP ad-hoc fix, see ticket 1383
    ccomp = self.compiler_so
    if ccomp[0] == 'aCC':
        # remove flags that will trigger ANSI-C mode for aCC
        if '-Ae' in ccomp:
            ccomp.remove('-Ae')
        if '-Aa' in ccomp:
            ccomp.remove('-Aa')
        # add flags for (almost) sane C++ handling
        ccomp += ['-AA']
        self.compiler_so = ccomp
    # ensure OPT environment variable is read
    if 'OPT' in os.environ:
        from distutils.sysconfig import get_config_vars
        opt = " ".join(os.environ['OPT'].split())
        gcv_opt = " ".join(get_config_vars('OPT')[0].split())
        ccomp_s = " ".join(self.compiler_so)
        if opt not in ccomp_s:
            ccomp_s = ccomp_s.replace(gcv_opt, opt)
            self.compiler_so = ccomp_s.split()
        llink_s = " ".join(self.linker_so)
        if opt not in llink_s:
            self.linker_so = llink_s.split() + opt.split()

    display = '%s: %s' % (os.path.basename(self.compiler_so[0]), src)
    try:
        self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
                   extra_postargs, display = display)
    except DistutilsExecError:
        msg = str(get_exception())
        raise CompileError(msg) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:35,代碼來源:unixccompiler.py

示例8: test_ext_fullpath

# 需要導入模塊: from distutils import sysconfig [as 別名]
# 或者: from distutils.sysconfig import get_config_vars [as 別名]
def test_ext_fullpath(self):
        ext = sysconfig.get_config_vars()['SO']
        dist = Distribution()
        cmd = build_ext(dist)
        cmd.inplace = 1
        cmd.distribution.package_dir = {'': 'src'}
        cmd.distribution.packages = ['lxml', 'lxml.html']
        curdir = os.getcwd()
        wanted = os.path.join(curdir, 'src', 'lxml', 'etree' + ext)
        path = cmd.get_ext_fullpath('lxml.etree')
        self.assertEqual(wanted, path)

        # building lxml.etree not inplace
        cmd.inplace = 0
        cmd.build_lib = os.path.join(curdir, 'tmpdir')
        wanted = os.path.join(curdir, 'tmpdir', 'lxml', 'etree' + ext)
        path = cmd.get_ext_fullpath('lxml.etree')
        self.assertEqual(wanted, path)

        # building twisted.runner.portmap not inplace
        build_py = cmd.get_finalized_command('build_py')
        build_py.package_dir = {}
        cmd.distribution.packages = ['twisted', 'twisted.runner.portmap']
        path = cmd.get_ext_fullpath('twisted.runner.portmap')
        wanted = os.path.join(curdir, 'tmpdir', 'twisted', 'runner',
                              'portmap' + ext)
        self.assertEqual(wanted, path)

        # building twisted.runner.portmap inplace
        cmd.inplace = 1
        path = cmd.get_ext_fullpath('twisted.runner.portmap')
        wanted = os.path.join(curdir, 'twisted', 'runner', 'portmap' + ext)
        self.assertEqual(wanted, path) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:35,代碼來源:test_build_ext.py


注:本文中的distutils.sysconfig.get_config_vars方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。