本文整理汇总了Python中Cython.Tempita.sub方法的典型用法代码示例。如果您正苦于以下问题:Python Tempita.sub方法的具体用法?Python Tempita.sub怎么用?Python Tempita.sub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cython.Tempita
的用法示例。
在下文中一共展示了Tempita.sub方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_extensions
# 需要导入模块: from Cython import Tempita [as 别名]
# 或者: from Cython.Tempita import sub [as 别名]
def build_extensions(self):
for _pxifile in _pxifiles:
# build pxifiles first, template extention must be .pxi.in
assert _pxifile.endswith(".pxi.in")
pxifile = pjoin(_pxipath, _pxifile)
outfile = pxifile[:-3]
if os.path.exists(outfile) and os.stat(pxifile).st_mtime < os.stat(outfile).st_mtime:
# if .pxi.in is not updated, no need to output .pxi
continue
with open(pxifile, "r") as f:
tmpl = f.read()
pyxcontent = tempita.sub(tmpl)
with open(outfile, "w") as f:
f.write(pyxcontent)
numpy_incl = pkg_resources.resource_filename("numpy", "core/include")
for ext in self.extensions:
if hasattr(ext, "include_dirs") and not numpy_incl in ext.include_dirs:
ext.include_dirs.append(numpy_incl)
_build_ext.build_extensions(self)
示例2: build_extensions
# 需要导入模块: from Cython import Tempita [as 别名]
# 或者: from Cython.Tempita import sub [as 别名]
def build_extensions(self):
# if builing from c files, don't need to
# generate template output
if cython:
for pxifile in _pxifiles:
# build pxifiles first, template extension must be .pxi.in
assert pxifile.endswith('.pxi.in')
outfile = pxifile[:-3]
if (os.path.exists(outfile) and
os.stat(pxifile).st_mtime < os.stat(outfile).st_mtime):
# if .pxi.in is not updated, no need to output .pxi
continue
with open(pxifile, "r") as f:
tmpl = f.read()
pyxcontent = tempita.sub(tmpl)
with open(outfile, "w") as f:
f.write(pyxcontent)
numpy_incl = pkg_resources.resource_filename('numpy', 'core/include')
for ext in self.extensions:
if (hasattr(ext, 'include_dirs') and
numpy_incl not in ext.include_dirs):
ext.include_dirs.append(numpy_incl)
_build_ext.build_extensions(self)
示例3: process_tempita_pyx
# 需要导入模块: from Cython import Tempita [as 别名]
# 或者: from Cython.Tempita import sub [as 别名]
def process_tempita_pyx(fromfile, tofile):
try:
try:
from Cython import Tempita as tempita
except ImportError:
import tempita
except ImportError:
raise Exception("Building Statsmodels requires Tempita: " "pip install --user Tempita")
with open(fromfile, "r") as f:
tmpl = f.read()
pyxcontent = tempita.sub(tmpl)
assert fromfile.endswith(".pyx.in")
pyxfile = fromfile[: -len(".pyx.in")] + ".pyx"
with open(pyxfile, "w") as f:
f.write(pyxcontent)
process_pyx(pyxfile, tofile)
示例4: process_tempita_pxi
# 需要导入模块: from Cython import Tempita [as 别名]
# 或者: from Cython.Tempita import sub [as 别名]
def process_tempita_pxi(fromfile, tofile):
try:
try:
from Cython import Tempita as tempita
except ImportError:
import tempita
except ImportError:
raise Exception('Building %s requires Tempita: '
'pip install --user Tempita' % VENDOR)
assert fromfile.endswith('.pxi.in')
assert tofile.endswith('.pxi')
with open(fromfile, "r") as f:
tmpl = f.read()
pyxcontent = tempita.sub(tmpl)
with open(tofile, "w") as f:
f.write(pyxcontent)
示例5: render_templates
# 需要导入模块: from Cython import Tempita [as 别名]
# 或者: from Cython.Tempita import sub [as 别名]
def render_templates(cls, pxifiles):
for pxifile in pxifiles:
# build pxifiles first, template extension must be .pxi.in
assert pxifile.endswith('.pxi.in')
outfile = pxifile[:-3]
if (os.path.exists(outfile) and
os.stat(pxifile).st_mtime < os.stat(outfile).st_mtime):
# if .pxi.in is not updated, no need to output .pxi
continue
with open(pxifile, "r") as f:
tmpl = f.read()
pyxcontent = tempita.sub(tmpl)
with open(outfile, "w") as f:
f.write(pyxcontent)
示例6: process_tempita
# 需要导入模块: from Cython import Tempita [as 别名]
# 或者: from Cython.Tempita import sub [as 别名]
def process_tempita(source_name):
"""Runs pyx.in files through tempita is needed"""
if source_name.endswith('pyx.in'):
with open(source_name, 'r') as templated:
pyx_template = templated.read()
pyx = Tempita.sub(pyx_template)
pyx_filename = source_name[:-3]
with open(pyx_filename, 'w') as pyx_file:
pyx_file.write(pyx)
file_stats = os.stat(source_name)
try:
os.utime(pyx_filename, ns=(file_stats.st_atime_ns,
file_stats.st_mtime_ns))
except AttributeError:
os.utime(pyx_filename, (file_stats.st_atime, file_stats.st_mtime))
source_name = pyx_filename
return source_name
示例7: process_tempita_pyx
# 需要导入模块: from Cython import Tempita [as 别名]
# 或者: from Cython.Tempita import sub [as 别名]
def process_tempita_pyx(fromfile, tofile):
try:
try:
from Cython import Tempita as tempita
except ImportError:
import tempita
except ImportError:
raise Exception('Building DismalPy requires Tempita: '
'pip install --user Tempita')
with open(fromfile, "r") as f:
tmpl = f.read()
pyxcontent = tempita.sub(tmpl)
assert fromfile.endswith('.pyx.in')
pyxfile = fromfile[:-len('.pyx.in')] + '.pyx'
with open(pyxfile, "w") as f:
f.write(pyxcontent)
process_pyx(pyxfile, tofile)
示例8: configuration
# 需要导入模块: from Cython import Tempita [as 别名]
# 或者: from Cython.Tempita import sub [as 别名]
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration('linear_model', parent_package, top_path)
libraries = []
if os.name == 'posix':
libraries.append('m')
config.add_extension('cd_fast',
sources=['cd_fast.pyx'],
include_dirs=numpy.get_include(),
libraries=libraries)
config.add_extension('sgd_fast',
sources=['sgd_fast.pyx'],
include_dirs=numpy.get_include(),
libraries=libraries)
# generate sag_fast from template
sag_cython_file = 'sklearn/linear_model/sag_fast.pyx.tp'
sag_file = sag_cython_file.replace('.tp', '')
if not (os.path.exists(sag_file) and
os.stat(sag_cython_file).st_mtime < os.stat(sag_file).st_mtime):
with open(sag_cython_file, "r") as f:
tmpl = f.read()
tmpl_ = Tempita.sub(tmpl)
with open(sag_file, "w") as f:
f.write(tmpl_)
config.add_extension('sag_fast',
sources=['sag_fast.pyx'],
include_dirs=numpy.get_include())
# add other directories
config.add_subpackage('tests')
return config
示例9: open
# 需要导入模块: from Cython import Tempita [as 别名]
# 或者: from Cython.Tempita import sub [as 别名]
try:
from Cython import Tempita as tempita
except ImportError:
import tempita
except ImportError:
notempita_msg = ("# tempita needed to finish setup. run:\n\n" +
" $ pip install tempita # or easy_install tempita\n")
sys.exit(notempita_msg)
# DOC: Tempita create pyx files
code_cdir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "affine")
for folder, subdirs, files in os.walk(code_cdir):
for fil in files:
if fil.endswith(".pyx.in"):
with open(os.path.join(folder, fil), "r") as f:
cython_file = tempita.sub(f.read())
with open(os.path.join(folder, os.path.splitext(fil)[0]), "w") as f:
f.write(cython_file)
extensions = [Extension('affine.model.Cython_extensions',
['affine/extensions/Cython_extensions.pyx'])]
setup(
name='affine',
author='Barton Baker',
version='0.3',
packages=find_packages(),
description='This package offers a solver class for affine ' \
+ 'term structure models.',
author_email="[email protected]",
use_2to3=True,