本文整理汇总了Python中distutils.core.Extension.language方法的典型用法代码示例。如果您正苦于以下问题:Python Extension.language方法的具体用法?Python Extension.language怎么用?Python Extension.language使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类distutils.core.Extension
的用法示例。
在下文中一共展示了Extension.language方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_distutils
# 需要导入模块: from distutils.core import Extension [as 别名]
# 或者: from distutils.core.Extension import language [as 别名]
def run_distutils(self, test_directory, module, workdir, incdir):
cwd = os.getcwd()
os.chdir(workdir)
try:
build_extension = build_ext(distutils_distro)
build_extension.include_dirs = INCLUDE_DIRS[:]
if incdir:
build_extension.include_dirs.append(incdir)
build_extension.finalize_options()
ext_include_dirs = []
for match, get_additional_include_dirs in EXT_DEP_INCLUDES:
if match(module):
ext_include_dirs += get_additional_include_dirs()
self.copy_related_files(test_directory, workdir, module)
extension = Extension(
module,
sources = self.find_source_files(workdir, module),
include_dirs = ext_include_dirs,
extra_compile_args = CFLAGS,
)
if self.language == 'cpp':
extension.language = 'c++'
build_extension.extensions = [extension]
build_extension.build_temp = workdir
build_extension.build_lib = workdir
build_extension.run()
finally:
os.chdir(cwd)
示例2: Extension
# 需要导入模块: from distutils.core import Extension [as 别名]
# 或者: from distutils.core.Extension import language [as 别名]
from distutils.core import setup
from distutils.core import Extension
import os
import subprocess
import sys
module = Extension("simplepinyin", ["simplepinyin.cpp"])
module.language = 'c++'
if os.system("pkg-config --exists libpinyin") != 0:
print("Please install libpinyin.", file=sys.stderr)
sys.exit(1)
libpinyin_args = subprocess.check_output(["pkg-config", "--cflags", "--libs", "libpinyin"], universal_newlines=True).strip().split(" ")
libpinyin_data = subprocess.check_output(["pkg-config", "--variable=pkgdatadir", "libpinyin"], universal_newlines=True).strip()+"/data"
#print(libpinyin_data)
module.include_dirs = [arg.lstrip("-I") for arg in libpinyin_args if arg.startswith("-I")]
module.library_dirs = [arg.lstrip("-L") for arg in libpinyin_args if arg.startswith("-L")]
module.libraries = [arg.lstrip("-l") for arg in libpinyin_args if arg.startswith("-l")]
module.define_macros = [("LIBPINYIN_DATA", "\""+libpinyin_data+"\"")]
setup(name="simplepinyin", version="1.0",
ext_modules=[module])