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


Python distutils.sysconfig方法代码示例

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


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

示例1: _all_base

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import sysconfig [as 别名]
def _all_base():
    if __file__.startswith(distutils.sysconfig.PREFIX):
        return os.path.join(distutils.sysconfig.PREFIX, 'bin')
    else:
        return os.path.join(os.path.dirname(__file__), '..', 'bin') 
开发者ID:shellphish,项目名称:shellphish-afl,代码行数:7,代码来源:__init__.py

示例2: get_exe_bytes

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import sysconfig [as 别名]
def get_exe_bytes (self):
        from distutils.msvccompiler import get_build_version
        # If a target-version other than the current version has been
        # specified, then using the MSVC version from *this* build is no good.
        # Without actually finding and executing the target version and parsing
        # its sys.version, we just hard-code our knowledge of old versions.
        # NOTE: Possible alternative is to allow "--target-version" to
        # specify a Python executable rather than a simple version string.
        # We can then execute this program to obtain any info we need, such
        # as the real sys.version string for the build.
        cur_version = get_python_version()
        if self.target_version and self.target_version != cur_version:
            # If the target version is *later* than us, then we assume they
            # use what we use
            # string compares seem wrong, but are what sysconfig.py itself uses
            if self.target_version > cur_version:
                bv = get_build_version()
            else:
                if self.target_version < "2.4":
                    bv = "6"
                else:
                    bv = "7.1"
        else:
            # for current version - use authoritative check.
            bv = get_build_version()

        # wininst-x.y.exe is in the same directory as this file
        directory = os.path.dirname(__file__)
        # we must use a wininst-x.y.exe built with the same C compiler
        # used for python.  XXX What about mingw, borland, and so on?
        filename = os.path.join(directory, "wininst-%s.exe" % bv)
        return open(filename, "rb").read()
# class bdist_wininst 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:35,代码来源:bdist_wininst.py

示例3: test_sysconfig_get_path_return_path

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import sysconfig [as 别名]
def test_sysconfig_get_path_return_path(writer, monkeypatch):
    monkeypatch.setattr(sysconfig, "get_path", lambda *a, **k: "/foo/bar/baz")
    logger.add(writer, backtrace=False, diagnose=True, colorize=False, format="")

    try:
        1 / 0
    except ZeroDivisionError:
        logger.exception("")

    assert writer.read().endswith("ZeroDivisionError: division by zero\n") 
开发者ID:Delgan,项目名称:loguru,代码行数:12,代码来源:test_catch_exceptions.py

示例4: test_sysconfig_get_path_return_none

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import sysconfig [as 别名]
def test_sysconfig_get_path_return_none(writer, monkeypatch):
    monkeypatch.setattr(sysconfig, "get_path", lambda *a, **k: None)
    logger.add(writer, backtrace=False, diagnose=True, colorize=False, format="")

    try:
        1 / 0
    except ZeroDivisionError:
        logger.exception("")

    assert writer.read().endswith("ZeroDivisionError: division by zero\n") 
开发者ID:Delgan,项目名称:loguru,代码行数:12,代码来源:test_catch_exceptions.py

示例5: test_distutils_get_python_lib_return_path

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import sysconfig [as 别名]
def test_distutils_get_python_lib_return_path(writer, monkeypatch):
    monkeypatch.setattr(distutils.sysconfig, "get_python_lib", lambda *a, **k: "/foo/bar/baz")
    logger.add(writer, backtrace=False, diagnose=True, colorize=False, format="")

    try:
        1 / 0
    except ZeroDivisionError:
        logger.exception("")

    assert writer.read().endswith("ZeroDivisionError: division by zero\n") 
开发者ID:Delgan,项目名称:loguru,代码行数:12,代码来源:test_catch_exceptions.py

示例6: test_distutils_get_python_lib_raise_exception

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import sysconfig [as 别名]
def test_distutils_get_python_lib_raise_exception(writer, monkeypatch):
    def raising(*a, **k):
        raise distutils.sysconfig.DistutilsPlatformError()

    monkeypatch.setattr(distutils.sysconfig, "get_python_lib", raising)
    logger.add(writer, backtrace=False, diagnose=True, colorize=False, format="")

    try:
        1 / 0
    except ZeroDivisionError:
        logger.exception("")

    assert writer.read().endswith("ZeroDivisionError: division by zero\n") 
开发者ID:Delgan,项目名称:loguru,代码行数:15,代码来源:test_catch_exceptions.py

示例7: test_distutils_not_installed

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import sysconfig [as 别名]
def test_distutils_not_installed(writer, monkeypatch):
    monkeypatch.setitem(sys.modules, "distutils", None)
    monkeypatch.setitem(sys.modules, "distutils.errors", None)
    monkeypatch.setitem(sys.modules, "distutils.sysconfig", None)
    monkeypatch.delattr(loguru._better_exceptions, "distutils", raising=False)
    monkeypatch.delattr(loguru._better_exceptions, "distutils.errors", raising=False)
    monkeypatch.delattr(loguru._better_exceptions, "distutils.syconfig", raising=False)
    logger.add(writer, backtrace=False, diagnose=True, colorize=False, format="")

    try:
        1 / 0
    except ZeroDivisionError:
        logger.exception("")

    assert writer.read().endswith("ZeroDivisionError: division by zero\n") 
开发者ID:Delgan,项目名称:loguru,代码行数:17,代码来源:test_catch_exceptions.py

示例8: get_exe_bytes

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import sysconfig [as 别名]
def get_exe_bytes(self):
        from distutils.msvccompiler import get_build_version
        # If a target-version other than the current version has been
        # specified, then using the MSVC version from *this* build is no good.
        # Without actually finding and executing the target version and parsing
        # its sys.version, we just hard-code our knowledge of old versions.
        # NOTE: Possible alternative is to allow "--target-version" to
        # specify a Python executable rather than a simple version string.
        # We can then execute this program to obtain any info we need, such
        # as the real sys.version string for the build.
        cur_version = get_python_version()
        if self.target_version and self.target_version != cur_version:
            # If the target version is *later* than us, then we assume they
            # use what we use
            # string compares seem wrong, but are what sysconfig.py itself uses
            if self.target_version > cur_version:
                bv = get_build_version()
            else:
                if self.target_version < "2.4":
                    bv = 6.0
                else:
                    bv = 7.1
        else:
            # for current version - use authoritative check.
            bv = get_build_version()

        # wininst-x.y.exe is in the same directory as this file
        directory = os.path.dirname(__file__)
        # we must use a wininst-x.y.exe built with the same C compiler
        # used for python.  XXX What about mingw, borland, and so on?

        # if plat_name starts with "win" but is not "win32"
        # we want to strip "win" and leave the rest (e.g. -amd64)
        # for all other cases, we don't want any suffix
        if self.plat_name != 'win32' and self.plat_name[:3] == 'win':
            sfix = self.plat_name[3:]
        else:
            sfix = ''

        filename = os.path.join(directory, "wininst-%.1f%s.exe" % (bv, sfix))
        f = open(filename, "rb")
        try:
            return f.read()
        finally:
            f.close() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:47,代码来源:bdist_wininst.py

示例9: get_exe_bytes

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import sysconfig [as 别名]
def get_exe_bytes(self):
        # If a target-version other than the current version has been
        # specified, then using the MSVC version from *this* build is no good.
        # Without actually finding and executing the target version and parsing
        # its sys.version, we just hard-code our knowledge of old versions.
        # NOTE: Possible alternative is to allow "--target-version" to
        # specify a Python executable rather than a simple version string.
        # We can then execute this program to obtain any info we need, such
        # as the real sys.version string for the build.
        cur_version = get_python_version()

        # If the target version is *later* than us, then we assume they
        # use what we use
        # string compares seem wrong, but are what sysconfig.py itself uses
        if self.target_version and self.target_version < cur_version:
            if self.target_version < "2.4":
                bv = 6.0
            elif self.target_version == "2.4":
                bv = 7.1
            elif self.target_version == "2.5":
                bv = 8.0
            elif self.target_version <= "3.2":
                bv = 9.0
            elif self.target_version <= "3.4":
                bv = 10.0
            else:
                bv = 14.0
        else:
            # for current version - use authoritative check.
            try:
                from msvcrt import CRT_ASSEMBLY_VERSION
            except ImportError:
                # cross-building, so assume the latest version
                bv = 14.0
            else:
                bv = float('.'.join(CRT_ASSEMBLY_VERSION.split('.', 2)[:2]))


        # wininst-x.y.exe is in the same directory as this file
        directory = os.path.dirname(__file__)
        # we must use a wininst-x.y.exe built with the same C compiler
        # used for python.  XXX What about mingw, borland, and so on?

        # if plat_name starts with "win" but is not "win32"
        # we want to strip "win" and leave the rest (e.g. -amd64)
        # for all other cases, we don't want any suffix
        if self.plat_name != 'win32' and self.plat_name[:3] == 'win':
            sfix = self.plat_name[3:]
        else:
            sfix = ''

        filename = os.path.join(directory, "wininst-%.1f%s.exe" % (bv, sfix))
        f = open(filename, "rb")
        try:
            return f.read()
        finally:
            f.close() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:59,代码来源:bdist_wininst.py

示例10: get_exe_bytes

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import sysconfig [as 别名]
def get_exe_bytes(self):
        # If a target-version other than the current version has been
        # specified, then using the MSVC version from *this* build is no good.
        # Without actually finding and executing the target version and parsing
        # its sys.version, we just hard-code our knowledge of old versions.
        # NOTE: Possible alternative is to allow "--target-version" to
        # specify a Python executable rather than a simple version string.
        # We can then execute this program to obtain any info we need, such
        # as the real sys.version string for the build.
        cur_version = get_python_version()

        # If the target version is *later* than us, then we assume they
        # use what we use
        # string compares seem wrong, but are what sysconfig.py itself uses
        if self.target_version and self.target_version < cur_version:
            if self.target_version < "2.4":
                bv = '6.0'
            elif self.target_version == "2.4":
                bv = '7.1'
            elif self.target_version == "2.5":
                bv = '8.0'
            elif self.target_version <= "3.2":
                bv = '9.0'
            elif self.target_version <= "3.4":
                bv = '10.0'
            else:
                bv = '14.0'
        else:
            # for current version - use authoritative check.
            try:
                from msvcrt import CRT_ASSEMBLY_VERSION
            except ImportError:
                # cross-building, so assume the latest version
                bv = '14.0'
            else:
                # as far as we know, CRT is binary compatible based on
                # the first field, so assume 'x.0' until proven otherwise
                major = CRT_ASSEMBLY_VERSION.partition('.')[0]
                bv = major + '.0'


        # wininst-x.y.exe is in the same directory as this file
        directory = os.path.dirname(__file__)
        # we must use a wininst-x.y.exe built with the same C compiler
        # used for python.  XXX What about mingw, borland, and so on?

        # if plat_name starts with "win" but is not "win32"
        # we want to strip "win" and leave the rest (e.g. -amd64)
        # for all other cases, we don't want any suffix
        if self.plat_name != 'win32' and self.plat_name[:3] == 'win':
            sfix = self.plat_name[3:]
        else:
            sfix = ''

        filename = os.path.join(directory, "wininst-%s%s.exe" % (bv, sfix))
        f = open(filename, "rb")
        try:
            return f.read()
        finally:
            f.close() 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:62,代码来源:bdist_wininst.py

示例11: GetPythonInfo

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import sysconfig [as 别名]
def GetPythonInfo():
    """Returns a tuple containing the path to the Python executable, shared
    library, and include directory corresponding to the version of Python
    currently running. Returns None if any path could not be determined. This
    function always returns None on Windows or Linux.

    This function is primarily used to determine which version of
    Python USD should link against when multiple versions are installed.
    """
    # We just skip all this on Windows. Users on Windows are unlikely to have
    # multiple copies of the same version of Python, so the problem this
    # function is intended to solve doesn't arise on that platform.
    if Windows():
        return None

    # We also skip all this on Linux. The below code gets the wrong answer on
    # certain distributions like Ubuntu, which organizes libraries based on
    # multiarch. The below code yields /usr/lib/libpython2.7.so, but
    # the library is actually in /usr/lib/x86_64-linux-gnu. Since the problem
    # this function is intended to solve primarily occurs on macOS, so it's
    # simpler to just skip this for now.
    if Linux():
        return None

    try:
        import distutils.sysconfig

        pythonExecPath = None
        pythonLibPath = None

        pythonPrefix = distutils.sysconfig.PREFIX
        if pythonPrefix:
            pythonExecPath = os.path.join(pythonPrefix, 'bin', 'python')
            pythonLibPath = os.path.join(pythonPrefix, 'lib', 'libpython2.7.dylib')

        pythonIncludeDir = distutils.sysconfig.get_python_inc()
    except:
        return None

    if pythonExecPath and pythonIncludeDir and pythonLibPath:
        # Ensure that the paths are absolute, since depending on the version of
        # Python being run and the path used to invoke it, we may have gotten a
        # relative path from distutils.sysconfig.PREFIX.
        return (
            os.path.abspath(pythonExecPath),
            os.path.abspath(pythonLibPath),
            os.path.abspath(pythonIncludeDir))

    return None 
开发者ID:dreamworksanimation,项目名称:dwa_usd_plugins,代码行数:51,代码来源:build_usd.py


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