本文整理汇总了Python中distutils.msvccompiler方法的典型用法代码示例。如果您正苦于以下问题:Python distutils.msvccompiler方法的具体用法?Python distutils.msvccompiler怎么用?Python distutils.msvccompiler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类distutils
的用法示例。
在下文中一共展示了distutils.msvccompiler方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prevent_msvc_compiling_patch
# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import msvccompiler [as 别名]
def prevent_msvc_compiling_patch(): # type: ignore
import distutils
import distutils._msvccompiler
import distutils.msvc9compiler
import distutils.msvccompiler
from distutils.errors import CompileError
def raise_compile_error(*args, **kwargs): # type: ignore
raise CompileError('Chalice blocked C extension compiling.')
distutils._msvccompiler.MSVCCompiler.compile = raise_compile_error
distutils.msvc9compiler.MSVCCompiler.compile = raise_compile_error
distutils.msvccompiler.MSVCCompiler.compile = raise_compile_error
# This is the setuptools shim used to execute setup.py by pip.
# Lines 2 and 3 have been added to call the above function
# `prevent_msvc_compiling_patch` and extra escapes have been added on line
# 5 because it is passed through another layer of string parsing before it
# is executed.
示例2: get_build_architecture
# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import msvccompiler [as 别名]
def get_build_architecture():
# Importing distutils.msvccompiler triggers a warning on non-Windows
# systems, so delay the import to here.
from distutils.msvccompiler import get_build_architecture
return get_build_architecture()
示例3: get_build_architecture
# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import msvccompiler [as 别名]
def get_build_architecture():
from distutils.msvccompiler import get_build_architecture
return get_build_architecture()
示例4: msvc_exists
# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import msvccompiler [as 别名]
def msvc_exists():
""" Determine whether MSVC is available on the machine.
"""
result = 0
try:
p = subprocess.Popen(['cl'], shell=True,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
str_result = p.stdout.read()
if 'Microsoft' in str_result:
result = 1
except:
#assume we're ok if devstudio exists
import distutils.msvccompiler
# There was a change to 'distutils.msvccompiler' between Python 2.2
# and Python 2.3.
#
# In Python 2.2 the function is 'get_devstudio_versions'
# In Python 2.3 the function is 'get_build_version'
try:
version = distutils.msvccompiler.get_devstudio_versions()
except:
version = distutils.msvccompiler.get_build_version()
if version:
result = 1
return result
示例5: get_exe_bytes
# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import msvccompiler [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 self.target_version < "2.3":
raise NotImplementedError
elif self.target_version == "2.3":
bv = "6"
elif self.target_version in ("2.4", "2.5"):
bv = "7.1"
elif self.target_version in ("2.6", "2.7"):
bv = "9.0"
else:
raise NotImplementedError
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?
# The uninstallers need to be available in $PYEXT_CROSS/uninst/*.exe
# Use http://oss.itsystementwicklung.de/hg/pyext_cross_linux_to_win32/
# and copy it alongside your pysqlite checkout.
filename = os.path.join(directory, os.path.join(os.environ["PYEXT_CROSS"], "uninst", "wininst-%s.exe" % bv))
return open(filename, "rb").read()
# class bdist_wininst
示例6: get_exe_bytes
# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import msvccompiler [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
示例7: get_exe_bytes
# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import msvccompiler [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()
# class bdist_wininst
示例8: get_exe_bytes
# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import msvccompiler [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()