本文整理汇总了Python中pypy.translator.tool.cbuild.ExternalCompilationInfo.convert_sources_to_files方法的典型用法代码示例。如果您正苦于以下问题:Python ExternalCompilationInfo.convert_sources_to_files方法的具体用法?Python ExternalCompilationInfo.convert_sources_to_files怎么用?Python ExternalCompilationInfo.convert_sources_to_files使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypy.translator.tool.cbuild.ExternalCompilationInfo
的用法示例。
在下文中一共展示了ExternalCompilationInfo.convert_sources_to_files方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_convert_sources_to_c_files
# 需要导入模块: from pypy.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from pypy.translator.tool.cbuild.ExternalCompilationInfo import convert_sources_to_files [as 别名]
def test_convert_sources_to_c_files(self):
eci = ExternalCompilationInfo(
separate_module_sources = ['xxx'],
separate_module_files = ['x.c'],
)
cache_dir = udir.join('test_convert_sources').ensure(dir=1)
neweci = eci.convert_sources_to_files(cache_dir)
assert not neweci.separate_module_sources
res = neweci.separate_module_files
assert len(res) == 2
assert res[0] == 'x.c'
assert str(res[1]).startswith(str(cache_dir))
e = ExternalCompilationInfo()
assert e.convert_sources_to_files() is e
示例2: compile_module
# 需要导入模块: from pypy.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from pypy.translator.tool.cbuild.ExternalCompilationInfo import convert_sources_to_files [as 别名]
def compile_module(space, modname, **kwds):
"""
Build an extension module and return the filename of the resulting native
code file.
modname is the name of the module, possibly including dots if it is a module
inside a package.
Any extra keyword arguments are passed on to ExternalCompilationInfo to
build the module (so specify your source with one of those).
"""
modname = modname.split('.')[-1]
eci = ExternalCompilationInfo(
export_symbols=['init%s' % (modname,)],
include_dirs=api.include_dirs,
**kwds
)
eci = eci.convert_sources_to_files()
dirname = (udir/uniquemodulename('module')).ensure(dir=1)
soname = platform.platform.compile(
[], eci,
outputfilename=str(dirname/modname),
standalone=False)
from pypy.module.imp.importing import get_so_extension
pydname = soname.new(purebasename=modname, ext=get_so_extension(space))
soname.rename(pydname)
return str(pydname)