Python源码示例:joblib.__version__()
示例1
def set_configuration():
# set python version
config.ExternalDepFound('python', '.'.join([str(x)
for x in sys.version_info]))
version = mdp.__version__
if mdp.__revision__:
version += ', ' + mdp.__revision__
config.ExternalDepFound('mdp', version)
# parallel python dependency
try:
import pp
# set pp secret if not there already
# (workaround for debian patch to pp that disables pp's default password)
pp_secret = os.getenv('MDP_PP_SECRET') or 'mdp-pp-support-password'
# module 'user' has been deprecated since python 2.6 and deleted
# completely as of python 3.0.
# Basically pp can not work on python 3 at the moment.
import user
if not hasattr(user, 'pp_secret'):
user.pp_secret = pp_secret
except ImportError, exc:
config.ExternalDepFailed('parallel_python', exc)
示例2
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)
示例3
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})
示例4
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}
)