当前位置: 首页>>代码示例>>Python>>正文


Python Cython.__version__方法代码示例

本文整理汇总了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 
开发者ID:pulse2percept,项目名称:pulse2percept,代码行数:20,代码来源:setup.py

示例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 
开发者ID:pulse2percept,项目名称:pulse2percept,代码行数:20,代码来源:setup.py

示例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}) 
开发者ID:scikit-multiflow,项目名称:scikit-multiflow,代码行数:23,代码来源:setup.py

示例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) 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:24,代码来源:__init__.py

示例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 
开发者ID:tenpy,项目名称:tenpy,代码行数:30,代码来源:setup.py

示例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) 
开发者ID:alkaline-ml,项目名称:pmdarima,代码行数:16,代码来源:__init__.py

示例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}) 
开发者ID:alkaline-ml,项目名称:pmdarima,代码行数:37,代码来源:__init__.py

示例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}) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:29,代码来源:__init__.py

示例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 
开发者ID:pyCGNS,项目名称:pyCGNS,代码行数:30,代码来源:setuputils.py

示例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) 
开发者ID:tgsmith61591,项目名称:skoot,代码行数:28,代码来源:__init__.py

示例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}
        ) 
开发者ID:alan-turing-institute,项目名称:sktime,代码行数:40,代码来源:__init__.py

示例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) 
开发者ID:edgedb,项目名称:edgedb-python,代码行数:15,代码来源:setup.py

示例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) 
开发者ID:MagicStack,项目名称:asyncpg,代码行数:15,代码来源:setup.py

示例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() 
开发者ID:edgedb,项目名称:edgedb,代码行数:52,代码来源:setup.py

示例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 
开发者ID:MagicStack,项目名称:httptools,代码行数:59,代码来源:setup.py


注:本文中的Cython.__version__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。