本文整理汇总了Python中Cython.__version__方法的典型用法代码示例。如果您正苦于以下问题:Python Cython.__version__方法的具体用法?Python Cython.__version__怎么用?Python Cython.__version__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cython
的用法示例。
在下文中一共展示了Cython.__version__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_numpy_status
# 需要导入模块: import Cython [as 别名]
# 或者: from Cython import __version__ [as 别名]
def get_numpy_status():
"""
Returns a dictionary containing a boolean specifying whether NumPy
is up-to-date, along with the version string (empty string if
not installed).
"""
numpy_status = {}
try:
import numpy
numpy_version = numpy.__version__
numpy_status['up_to_date'] = parse_version(
numpy_version) >= parse_version(NUMPY_MIN_VERSION)
numpy_status['version'] = numpy_version
except ImportError:
traceback.print_exc()
numpy_status['up_to_date'] = False
numpy_status['version'] = ""
return numpy_status
示例2: get_cython_status
# 需要导入模块: import Cython [as 别名]
# 或者: from Cython import __version__ [as 别名]
def get_cython_status():
"""
Returns a dictionary containing a boolean specifying whether Cython is
up-to-date, along with the version string (empty string if not installed).
"""
cython_status = {}
try:
import Cython
from Cython.Build import cythonize
cython_version = Cython.__version__
cython_status['up_to_date'] = parse_version(
cython_version) >= parse_version(CYTHON_MIN_VERSION)
cython_status['version'] = cython_version
except ImportError:
traceback.print_exc()
cython_status['up_to_date'] = False
cython_status['version'] = ""
return cython_status
示例3: maybe_cythonize_extensions
# 需要导入模块: import Cython [as 别名]
# 或者: from Cython import __version__ [as 别名]
def maybe_cythonize_extensions(top_path, config):
"""Tweaks for building extensions between release and development mode."""
is_release = os.path.exists(os.path.join(top_path, 'PKG-INFO'))
if is_release:
build_from_c_and_cpp_files(config.ext_modules)
else:
message = ('Please install cython with a version >= {0} in order '
'to build a scikit-multiflow development version.').format(
CYTHON_MIN_VERSION)
try:
import Cython
if LooseVersion(Cython.__version__) < CYTHON_MIN_VERSION:
message += ' Your version of Cython was {0}.'.format(
Cython.__version__)
raise ValueError(message)
from Cython.Build import cythonize
except ImportError as exc:
exc.args += (message,)
raise
config.ext_modules = cythonize(config.ext_modules,
compiler_directives={'language_level': 3})
示例4: maybe_cythonize_extensions
# 需要导入模块: import Cython [as 别名]
# 或者: from Cython import __version__ [as 别名]
def maybe_cythonize_extensions(top_path, config):
"""Tweaks for building extensions between release and development mode."""
is_release = os.path.exists(os.path.join(top_path, 'PKG-INFO'))
if is_release:
build_from_c_and_cpp_files(config.ext_modules)
else:
message = ('Please install cython with a version >= {0} in order '
'to build a scikit-learn development version.').format(
CYTHON_MIN_VERSION)
try:
import Cython
if LooseVersion(Cython.__version__) < CYTHON_MIN_VERSION:
message += ' Your version of Cython was {0}.'.format(
Cython.__version__)
raise ValueError(message)
from Cython.Build import cythonize
except ImportError as exc:
exc.args += (message,)
raise
config.ext_modules = cythonize(config.ext_modules)
示例5: write_version_py
# 需要导入模块: import Cython [as 别名]
# 或者: from Cython import __version__ [as 别名]
def write_version_py(full_version, git_rev, filename='tenpy/_version.py'):
"""Write the version during compilation to disc."""
content = """\
# THIS FILE IS GENERATED FROM setup.py
# thus, it contains the version during compilation
# Copyright 2018-2020 TeNPy Developers, GNU GPLv3
version = '{version!s}'
short_version = 'v' + version
released = {released!s}
full_version = '{full_version!s}'
git_revision = '{git_rev!s}'
numpy_version = '{numpy_ver!s}'
cython_version = '{cython_ver!s}'
"""
try:
import Cython
cython_ver = Cython.__version__
except:
cython_ver = "(not available)"
content = content.format(version=VERSION,
full_version=full_version,
released=RELEASED,
git_rev=git_rev,
numpy_ver=numpy.version.full_version,
cython_ver=cython_ver)
with open(filename, 'w') as f:
f.write(content)
# done
示例6: _check_cython_version
# 需要导入模块: import Cython [as 别名]
# 或者: from Cython import __version__ [as 别名]
def _check_cython_version():
message = 'Please install Cython with a version >= {0} in order ' \
'to build a pmdarima distribution from source.' \
.format(CYTHON_MIN_VERSION)
try:
import Cython
except ModuleNotFoundError:
# Re-raise with more informative error message instead:
raise ModuleNotFoundError(message)
if LooseVersion(Cython.__version__) < CYTHON_MIN_VERSION:
message += (' The current version of Cython is {} installed in {}.'
.format(Cython.__version__, Cython.__path__))
raise ValueError(message)
示例7: cythonize_extensions
# 需要导入模块: import Cython [as 别名]
# 或者: from Cython import __version__ [as 别名]
def cythonize_extensions(top_path, config):
"""Check that a recent Cython is available and cythonize extensions"""
_check_cython_version()
from Cython.Build import cythonize
# Fast fail before cythonization if compiler fails compiling basic test
# code even without OpenMP
basic_check_build()
# check simple compilation with OpenMP. If it fails scikit-learn will be
# built without OpenMP and the test test_openmp_supported in the test suite
# will fail.
# `check_openmp_support` compiles a small test program to see if the
# compilers are properly configured to build with OpenMP. This is expensive
# and we only want to call this function once.
# The result of this check is cached as a private attribute on the sklearn
# module (only at build-time) to be used twice:
# - First to set the value of SKLEARN_OPENMP_PARALLELISM_ENABLED, the
# cython build-time variable passed to the cythonize() call.
# - Then in the build_ext subclass defined in the top-level setup.py file
# to actually build the compiled extensions with OpenMP flags if needed.
n_jobs = 1
with contextlib.suppress(ImportError):
import joblib
if LooseVersion(joblib.__version__) > LooseVersion("0.13.0"):
# earlier joblib versions don't account for CPU affinity
# constraints, and may over-estimate the number of available
# CPU particularly in CI (cf loky#114)
n_jobs = joblib.cpu_count()
config.ext_modules = cythonize(
config.ext_modules,
nthreads=n_jobs,
compiler_directives={'language_level': 3})
示例8: maybe_cythonize_extensions
# 需要导入模块: import Cython [as 别名]
# 或者: from Cython import __version__ [as 别名]
def maybe_cythonize_extensions(top_path, config):
"""Tweaks for building extensions between release and development mode."""
with_openmp = check_openmp_support()
is_release = os.path.exists(os.path.join(top_path, 'PKG-INFO'))
if is_release:
build_from_c_and_cpp_files(config.ext_modules)
else:
message = ('Please install cython with a version >= {0} in order '
'to build a scikit-learn development version.').format(
CYTHON_MIN_VERSION)
try:
import Cython
if LooseVersion(Cython.__version__) < CYTHON_MIN_VERSION:
message += ' Your version of Cython was {0}.'.format(
Cython.__version__)
raise ValueError(message)
from Cython.Build import cythonize
except ImportError as exc:
exc.args += (message,)
raise
config.ext_modules = cythonize(
config.ext_modules,
compile_time_env={'SKLEARN_OPENMP_SUPPORTED': with_openmp},
compiler_directives={'language_level': 3})
示例9: updateVersionInFile
# 需要导入模块: import Cython [as 别名]
# 或者: from Cython import __version__ [as 别名]
def updateVersionInFile(filename, cfg):
f = open('{}/revision.tmp'.format(cfg.PRODUCTION_DIR))
r = int(f.readlines()[0][:-1])
REVISION = r
f = open(filename, 'r')
l = f.readlines()
f.close()
vver = '@@UPDATEVERSION@@'
vrel = '@@UPDATERELEASE@@'
vrev = '@@UPDATEREVISION@@'
r = []
for ll in l:
rl = ll
if (ll[-len(vver) - 1:-1] == vver):
rl = '__version__=%s # %s\n' % (MAJOR_VERSION, vver)
if (ll[-len(vrel) - 1:-1] == vrel):
rl = '__release__=%s # %s\n' % (MINOR_VERSION, vrel)
if (ll[-len(vrev) - 1:-1] == vrev):
ACTUALREV = REVISION
rl = '__revision__=%s # %s\n' % (ACTUALREV, vrev)
r += [rl]
f = open(filename, 'w+')
f.writelines(r)
f.close()
cfg.REVISION = REVISION
# --------------------------------------------------------------------
# Clean target redefinition - force clean everything
示例10: maybe_cythonize_extensions
# 需要导入模块: import Cython [as 别名]
# 或者: from Cython import __version__ [as 别名]
def maybe_cythonize_extensions(top_path, config):
"""Tweaks for building extensions between release and development mode."""
is_release = os.path.exists(os.path.join(top_path, 'PKG-INFO'))
if is_release:
print("Release detected--building from source files")
build_from_c_f_and_cpp_files(config.ext_modules)
else:
print("Development build detected--building from .pyx & .pyf")
message = ('Please install cython with a version >= {0} in order '
'to build a {1} development version.').format(
CYTHON_MIN_VERSION, DEFAULT_ROOT)
try:
import Cython
loose_cython_ver = LooseVersion(Cython.__version__) # type: str
if loose_cython_ver < CYTHON_MIN_VERSION:
message += ' Your version of Cython was {0}.'.format(
Cython.__version__)
raise ValueError(message)
from Cython.Build import cythonize
except ImportError as exc:
exc.args += (message,)
raise
# cythonize or fortranize...
config.ext_modules = cythonize(config.ext_modules)
示例11: maybe_cythonize_extensions
# 需要导入模块: import Cython [as 别名]
# 或者: from Cython import __version__ [as 别名]
def maybe_cythonize_extensions(top_path, config):
"""Tweaks for building extensions between release and development mode."""
with_openmp = check_openmp_support()
is_release = os.path.exists(os.path.join(top_path, 'PKG-INFO'))
if is_release:
build_from_c_and_cpp_files(config.ext_modules)
else:
message = ('Please install Cython with a version >= {0} in order '
'to build a sktime development version.').format(
CYTHON_MIN_VERSION)
try:
import Cython
if LooseVersion(Cython.__version__) < CYTHON_MIN_VERSION:
message += ' Your version of Cython was {0}.'.format(
Cython.__version__)
raise ValueError(message)
from Cython.Build import cythonize
except ImportError as exc:
exc.args += (message,)
raise
n_jobs = 1
with contextlib.suppress(ImportError):
import joblib
if LooseVersion(joblib.__version__) > LooseVersion("0.13.0"):
# earlier joblib versions don't account for CPU affinity
# constraints, and may over-estimate the number of available
# CPU particularly in CI (cf loky#114)
n_jobs = joblib.effective_n_jobs()
config.ext_modules = cythonize(
config.ext_modules,
nthreads=n_jobs,
compile_time_env={'SKTIME_OPENMP_SUPPORTED': with_openmp},
compiler_directives={'language_level': 3}
)
示例12: _fix_version
# 需要导入模块: import Cython [as 别名]
# 或者: from Cython import __version__ [as 别名]
def _fix_version(self, filename):
# Replace edgedb.__version__ with the actual version
# of the distribution (possibly inferred from git).
with open(str(filename)) as f:
content = f.read()
version_re = r"(.*__version__\s*=\s*)'[^']+'(.*)"
repl = r"\1'{}'\2".format(self.distribution.metadata.version)
content = re.sub(version_re, repl, content)
with open(str(filename), 'w') as f:
f.write(content)
示例13: _fix_version
# 需要导入模块: import Cython [as 别名]
# 或者: from Cython import __version__ [as 别名]
def _fix_version(self, filename):
# Replace asyncpg.__version__ with the actual version
# of the distribution (possibly inferred from git).
with open(str(filename)) as f:
content = f.read()
version_re = r"(.*__version__\s*=\s*)'[^']+'(.*)"
repl = r"\1'{}'\2".format(self.distribution.metadata.version)
content = re.sub(version_re, repl, content)
with open(str(filename), 'w') as f:
f.write(content)
示例14: finalize_options
# 需要导入模块: import Cython [as 别名]
# 或者: from Cython import __version__ [as 别名]
def finalize_options(self):
# finalize_options() may be called multiple times on the
# same command object, so make sure not to override previously
# set options.
if getattr(self, '_initialized', False):
return
import pkg_resources
# Double check Cython presence in case setup_requires
# didn't go into effect (most likely because someone
# imported Cython before setup_requires injected the
# correct egg into sys.path.
try:
import Cython
except ImportError:
raise RuntimeError(
'please install {} to compile edgedb from source'.format(
CYTHON_DEPENDENCY))
cython_dep = pkg_resources.Requirement.parse(CYTHON_DEPENDENCY)
if Cython.__version__ not in cython_dep:
raise RuntimeError(
'edgedb requires {}, got Cython=={}'.format(
CYTHON_DEPENDENCY, Cython.__version__
))
from Cython.Build import cythonize
directives = {
'language_level': '3'
}
if self.cython_directives:
for directive in self.cython_directives.split(','):
k, _, v = directive.partition('=')
if v.lower() == 'false':
v = False
if v.lower() == 'true':
v = True
directives[k] = v
self.distribution.ext_modules[:] = cythonize(
self.distribution.ext_modules,
compiler_directives=directives,
annotate=self.cython_annotate,
include_path=["edb/server/pgproto/"])
super(build_ext, self).finalize_options()
示例15: finalize_options
# 需要导入模块: import Cython [as 别名]
# 或者: from Cython import __version__ [as 别名]
def finalize_options(self):
# finalize_options() may be called multiple times on the
# same command object, so make sure not to override previously
# set options.
if getattr(self, '_initialized', False):
return
need_cythonize = self.cython_always
cfiles = {}
for extension in self.distribution.ext_modules:
for i, sfile in enumerate(extension.sources):
if sfile.endswith('.pyx'):
prefix, ext = os.path.splitext(sfile)
cfile = prefix + '.c'
if os.path.exists(cfile) and not self.cython_always:
extension.sources[i] = cfile
else:
if os.path.exists(cfile):
cfiles[cfile] = os.path.getmtime(cfile)
else:
cfiles[cfile] = 0
need_cythonize = True
if need_cythonize:
try:
import Cython
except ImportError:
raise RuntimeError(
'please install Cython to compile httptools from source')
if Cython.__version__ < '0.29':
raise RuntimeError(
'httptools requires Cython version 0.29 or greater')
from Cython.Build import cythonize
directives = {}
if self.cython_directives:
for directive in self.cython_directives.split(','):
k, _, v = directive.partition('=')
if v.lower() == 'false':
v = False
if v.lower() == 'true':
v = True
directives[k] = v
self.distribution.ext_modules[:] = cythonize(
self.distribution.ext_modules,
compiler_directives=directives,
annotate=self.cython_annotate)
super().finalize_options()
self._initialized = True