本文整理汇总了Python中Cython.Compiler.Main类的典型用法代码示例。如果您正苦于以下问题:Python Main类的具体用法?Python Main怎么用?Python Main使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Main类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cycompile
def cycompile(input_file, options=()):
from Cython.Compiler import Version, CmdLine, Main
options, sources = CmdLine.parse_command_line(list(options or ()) + ['--embed', input_file])
_debug('Using Cython %s to compile %s', Version.version, input_file)
result = Main.compile(sources, options)
if result.num_errors > 0:
sys.exit(1)
示例2: generate_c_from_cython
def generate_c_from_cython(extension, build_dir):
if not sys.platform == 'darwin':
print 'No %s will be built for this platform.' % (extension.name)
return
from distutils.dep_util import newer_group
name = extension.name.split('.')[-1]
source = extension.depends[0]
target = os.path.join(build_dir, name+'.c')
if newer_group(extension.depends, target):
from Cython.Compiler import Main
options = Main.CompilationOptions(
defaults=Main.default_options,
output_file=target)
cython_result = Main.compile(source, options=options)
if cython_result.num_errors != 0:
raise RuntimeError("%d errors in Cython compile" %
cython_result.num_errors)
return target
示例3: cython_extension
def cython_extension(srcfile):
options = Main.CompilationOptions(include_path=[os.path.join(os.path.abspath(os.path.dirname(__file__)), 'include')])
Main.compile(srcfile, options=options)
示例4: print
cmdclass['build_ext'] = build_pyx
else:
ext.sources[0] = 'fplib.cpp'
# This silly hack, inspired by the pymt setup.py, runs Cython if we're
# doing a source distribution. The MANIFEST.in file ensures that the
# C++ source is included in the tarball also.
if 'sdist' in sys.argv:
if not HAVE_CYTHON:
print('We need Cython to build a source distribution.')
sys.exit(1)
from Cython.Compiler import Main
source = ext.sources[0] # hacky!
Main.compile(
source,
cplus = True,
full_module_name = ext.name,
)
setup(
name = 'pylastfp',
version = '0.6',
description = "bindings for Last.fm's acoustic fingerprinting (fplib)",
author = 'Adrian Sampson',
author_email = '[email protected]',
url = 'http://github.com/sampsyo/pylastfp/',
license = 'LGPL',
platforms = 'ALL',
long_description = _read('README.rst'),
classifiers = [
'Topic :: Multimedia :: Sound/Audio :: Analysis',
示例5: cythonize_all
def cythonize_all(relpath):
"""Cythonize all Cython modules in relative path"""
from Cython.Compiler import Main
for fname in os.listdir(relpath):
if osp.splitext(fname)[1] == '.pyx':
Main.compile(osp.join(relpath, fname))
示例6: __init__
def __init__(self, *args, **kwargs):
for src in glob('timeuuid/*.pyx'):
print src
Main.compile(glob('timeuuid/*.pyx'),
Main.default_options)
sdist.__init__(self, *args, **kwargs)
示例7: __init__
def __init__(self, *args, **kwargs):
for src in glob('borg/*.pyx'):
cython_compiler.compile(src, cython_compiler.default_options)
super().__init__(*args, **kwargs)
示例8: __init__
def __init__(self, *args, **kwargs):
for src in glob('msgpack/*.pyx'):
cython_compiler.compile(glob('msgpack/*.pyx'),
cython_compiler.default_options)
sdist.__init__(self, *args, **kwargs)
示例9: __init__
def __init__(self, *args, **kwargs):
for src in glob('borg/*.pyx'):
cython_compiler.compile(src, cython_compiler.default_options)
versioneer.cmd_sdist.__init__(self, *args, **kwargs)
示例10:
pypissh.monkeypatch()
DEBUG = False
src_dir = 'src'
ext_dir = os.path.join(src_dir,'ext')
build_dir = 'build'
cchardet_dir = os.path.join(src_dir,'cchardet/')
charsetdetect_dir = os.path.join(ext_dir, 'libcharsetdetect/')
nspr_emu_dir = os.path.join(charsetdetect_dir,"nspr-emu/")
uchardet_dir = os.path.join(charsetdetect_dir,"mozilla/extensions/universalchardet/src/base/")
if have_cython:
pyx_sources = glob.glob(cchardet_dir+'*.pyx')
sys.stderr.write("cythonize: %r\n" % (pyx_sources,))
cython_compiler.compile(pyx_sources,options=cython_compiler.CompilationOptions(cplus=True))
cchardet_sources = glob.glob(cchardet_dir+'*.cpp')
sources = cchardet_sources + [os.path.join(charsetdetect_dir,"charsetdetect.cpp")] + glob.glob(uchardet_dir+'*.cpp')
macros = []
extra_compile_args = []
extra_link_args = []
if platform.system() == "Windows":
macros.append(("WIN32","1"))
if DEBUG:
macros.append(("DEBUG_chardet","1"))
extra_compile_args.append("-g"),
extra_link_args.append("-g"),
示例11: cythonize
def cythonize(src):
sys.stderr.write("cythonize: %r\n" % (src,))
cython_compiler.compile([src])
示例12: __init__
def __init__(self, *args, **kwargs):
for src in cython_sources:
cython_compiler.compile(src, cython_compiler.default_options)
super().__init__(*args, **kwargs)
示例13: cythonize
def cythonize(src):
sys.stderr.write("cythonize: %r\n" % (src,))
cython_compiler.compile([src], cplus=True, emit_linenums=True)
示例14: __init__
def __init__(self, *args, **kwargs):
cy_opt = cython_compiler.default_options.copy()
cy_opt["cplus"] = True
for src in glob("msgpack/*.pyx"):
cython_compiler.compile(glob("msgpack/*.pyx"), cy_opt)
sdist.__init__(self, *args, **kwargs)