本文整理汇总了Python中distutils.msvc9compiler.MSVCCompiler.compile方法的典型用法代码示例。如果您正苦于以下问题:Python MSVCCompiler.compile方法的具体用法?Python MSVCCompiler.compile怎么用?Python MSVCCompiler.compile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类distutils.msvc9compiler.MSVCCompiler
的用法示例。
在下文中一共展示了MSVCCompiler.compile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compile_wrapper_python26
# 需要导入模块: from distutils.msvc9compiler import MSVCCompiler [as 别名]
# 或者: from distutils.msvc9compiler.MSVCCompiler import compile [as 别名]
def compile_wrapper_python26(self):
# For Python-2.6 we build with Visual Studio; trying to get a
# MingW32-built .exe to load the extensions we bundle for Python-2.6
# seems very difficult. We hope that our version of Visual Studio
# was close enough to the version that Python is built with so
# that if Python runs, we run.
#
# We use some distutils internals to locate the Visual Studio
# command line tools
#
from distutils.msvc9compiler import MSVCCompiler
compiler = MSVCCompiler()
# This looks for the tools and then adds them to os.environ['Path']
compiler.initialize()
python_topdir = os.path.dirname(os.path.dirname(shutil.__file__))
python_include = os.path.join(python_topdir, "include")
python_lib = os.path.join(python_topdir, "libs")
wrapper_c = os.path.join(self.topdir, "tools", "build_msi", "wrapper.c")
wrapper_rc = os.path.join(self.tempdir, "wrapper.rc")
f = open(wrapper_rc, "w")
f.write("""LANGUAGE 0, 0
100 ICON %s
""" % os.path.join(self.treedir, "Reinteract.ico"))
f.close()
# We can use distutils to do the basic compilation
objects = compiler.compile([wrapper_c, wrapper_rc],
output_dir=self.tempdir, include_dirs=[python_include])
# But have to do the linking a bit more manually since distutils
# doesn't know how to handle creating .exe files
wrapper = os.path.join(self.tempdir, "Reinteract.exe")
manifest = os.path.join(self.tempdir, "Reinteract.exe.manifest")
extra_libs = [
'user32.lib', # For MessageBox
]
check_call([compiler.linker,
"/MANIFEST",
"/MANIFESTFILE:" + manifest,
"/LIBPATH:" + python_lib,
"/OUT:" + wrapper]
+ objects + extra_libs)
# Embed the manifest into the executable
check_call(['mt.exe',
'-manifest', manifest,
'-outputresource:' + wrapper + ';1'])
self.add_file(wrapper, 'bin', feature='core')