From ee594a8e7454961598b80bbb62d7168fdef8b9f6 Mon Sep 17 00:00:00 2001 From: "Mads R. B. Kristensen" Date: Fri, 7 Dec 2018 11:33:15 +0100 Subject: [PATCH 1/5] Added a separate version of npbackend --- bridge/npbackend/bohrium/__init__.py | 1 + bridge/npbackend/bohrium/__main__.py | 2 + bridge/npbackend/setup.py | 55 +++++++++++++++++++++++-- bridge/py_api/bohrium_api/stack_info.py | 12 +++--- bridge/py_api/setup.py | 2 +- 5 files changed, 60 insertions(+), 12 deletions(-) diff --git a/bridge/npbackend/bohrium/__init__.py b/bridge/npbackend/bohrium/__init__.py index c36a1b2c8..a7b2c3751 100644 --- a/bridge/npbackend/bohrium/__init__.py +++ b/bridge/npbackend/bohrium/__init__.py @@ -13,6 +13,7 @@ from numpy_force import * from numpy_force import testing +from .version import __version__ from .array_create import * from .array_manipulation import * from .reorganization import * diff --git a/bridge/npbackend/bohrium/__main__.py b/bridge/npbackend/bohrium/__main__.py index edea49e19..7005b4ed0 100644 --- a/bridge/npbackend/bohrium/__main__.py +++ b/bridge/npbackend/bohrium/__main__.py @@ -8,6 +8,7 @@ import argparse import bohrium from . import bh_info +from . import version @bohrium.replace_numpy @@ -49,6 +50,7 @@ def execfile_wrapper(path): execfile_wrapper(sys.argv[0]) else: if args.info: + print("----\nBohrium version: %s" % version.__version__) print(bh_info.pprint()) cmd = "import bohrium as bh; import numpy as np; assert((bh.arange(10) == np.arange(10)).all())" diff --git a/bridge/npbackend/setup.py b/bridge/npbackend/setup.py index 6e8e32f53..ea38fb5de 100755 --- a/bridge/npbackend/setup.py +++ b/bridge/npbackend/setup.py @@ -26,10 +26,19 @@ from setuptools import setup, find_packages from setuptools.extension import Extension from setuptools.command.build_ext import build_ext as setup_build_ext +from setuptools.command.build_py import build_py as setup_build_py +from setuptools.command.sdist import sdist as setup_sdist import numbers import os import glob +""" Beside the regular setup arguments, this script reads the follow environment variables: + + * USE_CYTHON - if defined, this setup will cythonize all pyx files. + + NB: when running the source distribution command, `setup.py sdist`, do it from the same directory as `setup.py` +""" + def script_path(*paths): prefix = os.path.abspath(os.path.dirname(__file__)) @@ -37,6 +46,21 @@ def script_path(*paths): return os.path.join(prefix, *paths) +def get_version(): + """Returns the version and true if version.py exist""" + ver_path = script_path("bohrium", "version.py") + if os.path.exists(ver_path): + print("Getting version from version.py") + # Loading `__version__` variable from the version file + with open(ver_path, "r") as f: + exec (f.read()) + return (__version__, True) + else: + print("Getting version from bohrium_api") + import bohrium_api + return (bohrium_api.__version__, False) + + def get_pyx_extensions(): """Find and compiles all cython extensions""" include_dirs = [] @@ -60,9 +84,33 @@ def get_pyx_extensions(): return ret +def gen_version_file_in_cmd(self, target_dir): + """We extend the setup commands to also generate the `version.py` file if it doesn't exist already""" + if not self.dry_run: + version, version_file_exist = get_version() + if not version_file_exist: + self.mkpath(target_dir) + p = os.path.join(target_dir, 'version.py') + print("Generating '%s'" % p) + with open(p, 'w') as fobj: + fobj.write("__version__ = \"%s\"\n" % version) + + +class BuildPy(setup_build_py): + def run(self): + gen_version_file_in_cmd(self, os.path.join(self.build_lib, 'bohrium')) + setup_build_py.run(self) + + +class Sdist(setup_sdist): + def run(self): + gen_version_file_in_cmd(self, "bohrium") + setup_sdist.run(self) + + class BuildExt(setup_build_ext): """We delay the numpy and bohrium dependency to the build command. - Hopefully, PIP has installed them at this point.""" + Hopefully, PIP has installed them at this point.""" def run(self): if not self.dry_run: @@ -77,12 +125,11 @@ class DelayedVersion(numbers.Number): """In order to delay the version evaluation that depend on `bohrium_api`, we use this class""" def __str__(self): - import bohrium_api - return bohrium_api.__version__ + return get_version()[0] setup( - cmdclass={'build_ext': BuildExt}, + cmdclass={'build_ext': BuildExt, 'build_py': BuildPy, 'sdist': Sdist}, name='bohrium', version=DelayedVersion(), description='Bohrium Python/NumPy Backend', diff --git a/bridge/py_api/bohrium_api/stack_info.py b/bridge/py_api/bohrium_api/stack_info.py index 8821d6728..cb164dae1 100644 --- a/bridge/py_api/bohrium_api/stack_info.py +++ b/bridge/py_api/bohrium_api/stack_info.py @@ -82,17 +82,15 @@ def is_proxy_in_stack(): def pprint(): """Pretty print Bohrium info""" - ret = "" - if not (is_opencl_in_stack() or is_cuda_in_stack()): - ret += "Note: in order to activate and retrieve GPU info, set the `BH_STACK=opencl` " \ - "or `BH_STACK=cuda` environment variable.\n" - - ret += """---- -Bohrium version: %s + ret = """---- +Bohrium API version: %s Installed through PyPI: %s Config file: %s Header dir: %s Backend stack: %s---- """ % (version(), installed_through_pypi(), config_file_path(), header_dir(), messaging.runtime_info()) + if not (is_opencl_in_stack() or is_cuda_in_stack()): + ret += "Note: in order to activate and retrieve GPU info, set the `BH_STACK=opencl` " \ + "or `BH_STACK=cuda` environment variable.\n" return ret diff --git a/bridge/py_api/setup.py b/bridge/py_api/setup.py index 80e86210e..e739a4f83 100755 --- a/bridge/py_api/setup.py +++ b/bridge/py_api/setup.py @@ -200,7 +200,7 @@ def write_header(header_file): # The version if written in the VERSION file in the root of Bohrium with open(src_root("VERSION"), "r") as f: version = f.read().strip() -print("Bohrium version: %s" % version) +print("Bohrium API version: %s" % version) # Information variables that should be written to the _info.py file info_vars = {'__version__': version} From d5e3ce6987f4a9f9375e4ea9ae490883f04acab6 Mon Sep 17 00:00:00 2001 From: "Mads R. B. Kristensen" Date: Fri, 7 Dec 2018 17:58:31 +0100 Subject: [PATCH 2/5] py_api: added a version.py --- bridge/py_api/bohrium_api/stack_info.py | 2 +- bridge/py_api/setup.py | 54 +++++++++++++++++-------- 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/bridge/py_api/bohrium_api/stack_info.py b/bridge/py_api/bohrium_api/stack_info.py index cb164dae1..9283c619b 100644 --- a/bridge/py_api/bohrium_api/stack_info.py +++ b/bridge/py_api/bohrium_api/stack_info.py @@ -47,7 +47,7 @@ def header_dir(): def info(): """Return a dict with all info""" return { - "config_path" : config_file_path(), + "config_path": config_file_path(), "version": version(), "runtime_info": messaging.runtime_info(), "statistics": messaging.statistic(), diff --git a/bridge/py_api/setup.py b/bridge/py_api/setup.py index e739a4f83..23465b5f3 100755 --- a/bridge/py_api/setup.py +++ b/bridge/py_api/setup.py @@ -188,34 +188,49 @@ def write_header(header_file): header_file.write(head) -# Let's find the version -cmd = "git describe --tags --long --match v[0-9]*" +# Let's find the version as a tuple e.g. v0.8.9-47-g6464 => (0, 8, 9, 47) try: - # Let's get the Bohrium version without the 'v' and hash (e.g. v0.8.9-47-g6464 => v0.8.9-47) - version = subprocess.check_output(cmd, shell=True, cwd=src_root()).decode('utf-8') - version = re.match(".*v(.+-\d+)-", str(version)).group(1) + cmd = "git describe --tags --long --match v[0-9]*" + version_str = str(subprocess.check_output(cmd, shell=True, cwd=src_root()).decode('utf-8')).strip() except subprocess.CalledProcessError as e: print("Couldn't find the Bohrium version through `git describe`, are we not in the git repos?\n" "Using the VERSION file instead") - # The version if written in the VERSION file in the root of Bohrium with open(src_root("VERSION"), "r") as f: - version = f.read().strip() -print("Bohrium API version: %s" % version) + version_str = str(f.read().strip()) -# Information variables that should be written to the _info.py file -info_vars = {'__version__': version} +# In order to convert the version string to a tuple, we match major, minor, micro, and post version. +version_info = [0] * 4 +m = re.match("v?(\d+)", version_str) +if m: + version_info[0] = int(m.group(1)) +m = re.match("v?\d+\.(\d+)", version_str) +if m: + version_info[1] = int(m.group(1)) +m = re.match("v?\d+\.\d+\.(\d+)", version_str) +if m: + version_info[2] = int(m.group(1)) +m = re.match("v?[\d\.]+\-(\d+)", version_str) +if m: + version_info[3] = int(m.group(1)) +version_info = tuple(version_info) + +version_str = "%d.%d.%d" % (version_info[0], version_info[1], version_info[2]) +if version_info[3] > 0: + version_str += ".post%d" % version_info[3] + +print("Bohrium API version: %s" % version_str) + + +def write_version(o): + """Write the version.py file to `o`""" + o.write("__version__ = \"%s\"\n" % version_str) + o.write("__version_info__ = (%d, %d, %d, %d)\n" % version_info) def write_info(o): """Write the _info.py file to `o`""" o.write("# This file is auto generated by the setup.py\n") - # Write the information variables - o.write("\n# Info variables:\n") - for (key, val) in info_vars.items(): - o.write("%s = '%s'\n" % (key, val)) - o.write("\n") - ufunc = {} with open(src_root('core', 'codegen', 'opcodes.json'), 'r') as f: opcodes = json.loads(f.read()) @@ -299,6 +314,11 @@ def run(self): with open(p, 'w') as fobj: write_info(fobj) + p = os.path.join(target_dir, 'version.py') + print("Generating '%s'" % p) + with open(p, 'w') as fobj: + write_version(fobj) + self.mkpath(os.path.join(target_dir, 'include')) p = os.path.join(target_dir, 'include', 'bohrium_api.h') print("Generating '%s'" % p) @@ -335,7 +355,7 @@ def run(self): setup( cmdclass={'build_py': build_py}, name='bohrium_api', - version=version, + version=version_str, description='Bohrium Python API', long_description='Python API for the Bohrium project ', url='http://bh107.org', From 43d9db7deb9adc445a8ceb4c74db409e9244e7ca Mon Sep 17 00:00:00 2001 From: "Mads R. B. Kristensen" Date: Fri, 7 Dec 2018 20:05:25 +0100 Subject: [PATCH 3/5] Added a version_info and warnings --- bridge/npbackend/bohrium/__init__.py | 15 +++++++++++---- bridge/npbackend/bohrium/__main__.py | 4 ++-- bridge/npbackend/bohrium/interop_numpy.py | 4 ++-- bridge/npbackend/bohrium/interop_pycuda.py | 6 +++--- bridge/npbackend/bohrium/interop_pyopencl.py | 6 +++--- bridge/npbackend/bohrium/nobh/bincount.py | 5 ++--- bridge/npbackend/bohrium/ufuncs.pyx | 5 ++--- bridge/npbackend/setup.py | 9 +++++---- bridge/py_api/bohrium_api/__init__.py | 2 +- bridge/py_api/bohrium_api/stack_info.py | 12 ++++-------- 10 files changed, 35 insertions(+), 33 deletions(-) diff --git a/bridge/npbackend/bohrium/__init__.py b/bridge/npbackend/bohrium/__init__.py index a7b2c3751..2fd72fef8 100644 --- a/bridge/npbackend/bohrium/__init__.py +++ b/bridge/npbackend/bohrium/__init__.py @@ -6,14 +6,16 @@ if 'numpy_force' not in sys.modules: import numpy + sys.modules['numpy_force'] = numpy del numpy # We import all of NumPy and overwrite with the objects we implement our self from numpy_force import * from numpy_force import testing - -from .version import __version__ +import warnings +import bohrium_api +from .version import __version__, __version_info__ from .array_create import * from .array_manipulation import * from .reorganization import * @@ -30,7 +32,6 @@ from .concatenate import * from .ufuncs import _handle__array_ufunc__ from . import contexts -from bohrium_api import stack_info as bh_info from . import interop_pyopencl from . import interop_pycuda from . import interop_numpy @@ -45,11 +46,15 @@ # However, NumPy and SciPy's functionality differ! Thus, the ND version cannot replace NumPy's 1D version. from .signal import correlate1d as correlate, convolve1d as convolve from .signal import correlate as correlate_scipy, convolve as convolve_scipy - from numpy_force import dtype + asarray = array asanyarray = array +if __version_info__ > bohrium_api.__version_info__: + warnings.warn("The version of Bohrium API (%s) is newer than Bohrium (%s). Please upgrade " + "Bohrium (e.g. `pip install bohrium --upgrade`)" % (__version__, bohrium_api.__version__)) + def replace_numpy(function): def wrapper(*args, **kwargs): @@ -57,6 +62,7 @@ def wrapper(*args, **kwargs): # Run your function/program result = function(*args, **kwargs) return result + return wrapper @@ -113,6 +119,7 @@ def wrapper(*args, **kwargs): def set_printoptions(*args, **kwargs): numpy.core.arrayprint.set_printoptions(*args, **kwargs) + def get_printoptions(*args, **kwargs): return numpy.core.arrayprint.get_printoptions() diff --git a/bridge/npbackend/bohrium/__main__.py b/bridge/npbackend/bohrium/__main__.py index 7005b4ed0..3e763ae62 100644 --- a/bridge/npbackend/bohrium/__main__.py +++ b/bridge/npbackend/bohrium/__main__.py @@ -7,7 +7,7 @@ import os import argparse import bohrium -from . import bh_info +import bohrium_api from . import version @@ -51,7 +51,7 @@ def execfile_wrapper(path): else: if args.info: print("----\nBohrium version: %s" % version.__version__) - print(bh_info.pprint()) + print(bohrium_api.stack_info.pprint()) cmd = "import bohrium as bh; import numpy as np; assert((bh.arange(10) == np.arange(10)).all())" sys.stdout.write('Sanity Check: "%s"' % cmd) diff --git a/bridge/npbackend/bohrium/interop_numpy.py b/bridge/npbackend/bohrium/interop_numpy.py index 6df6662da..1a157913b 100644 --- a/bridge/npbackend/bohrium/interop_numpy.py +++ b/bridge/npbackend/bohrium/interop_numpy.py @@ -3,7 +3,7 @@ ~~~~~~~~~~~~~ """ from .bhary import get_base -from . import bh_info +from bohrium_api import stack_info def get_array(bh_ary): @@ -24,7 +24,7 @@ def get_array(bh_ary): """ - if bh_info.is_proxy_in_stack(): + if stack_info.is_proxy_in_stack(): raise RuntimeError("Cannot directly access array data through a proxy.") if get_base(bh_ary) is not bh_ary: diff --git a/bridge/npbackend/bohrium/interop_pycuda.py b/bridge/npbackend/bohrium/interop_pycuda.py index 4c4138deb..f1c22d478 100644 --- a/bridge/npbackend/bohrium/interop_pycuda.py +++ b/bridge/npbackend/bohrium/interop_pycuda.py @@ -2,10 +2,10 @@ Interop PyCUDA ~~~~~~~~~~~~~~ """ +from bohrium_api import stack_info from .bhary import get_base from ._bh import get_data_pointer from .backend_messaging import cuda_use_current_context -from . import bh_info from . import contexts @@ -19,11 +19,11 @@ def _import_pycuda_module(): except ImportError: raise ImportError("Failed to import the `pycuda` module, please install PyCUDA") - if not bh_info.is_cuda_in_stack(): + if not stack_info.is_cuda_in_stack(): raise RuntimeError("No CUDA device in the Bohrium stack! " "Try defining the environment variable `BH_STACK=cuda`.") - if bh_info.is_proxy_in_stack(): + if stack_info.is_proxy_in_stack(): raise RuntimeError("Cannot directly access the CUDA device through a proxy.") return pycuda diff --git a/bridge/npbackend/bohrium/interop_pyopencl.py b/bridge/npbackend/bohrium/interop_pyopencl.py index 34d96f933..9e869decc 100644 --- a/bridge/npbackend/bohrium/interop_pyopencl.py +++ b/bridge/npbackend/bohrium/interop_pyopencl.py @@ -2,9 +2,9 @@ Interop PyOpenCL ~~~~~~~~~~~~~~~~ """ +from bohrium_api import stack_info from .bhary import get_base from ._bh import get_data_pointer, set_data_pointer, get_device_context -from . import bh_info def _import_pyopencl_module(): @@ -14,11 +14,11 @@ def _import_pyopencl_module(): except ImportError: raise ImportError("Failed to import the `pyopencl` module, please install PyOpenCL") - if not bh_info.is_opencl_in_stack(): + if not stack_info.is_opencl_in_stack(): raise RuntimeError("No OpenCL device in the Bohrium stack! " "Try defining the environment variable `BH_STACK=opencl`.") - if bh_info.is_proxy_in_stack(): + if stack_info.is_proxy_in_stack(): raise RuntimeError("Cannot directly access the OpenCL device through a proxy.") return pyopencl diff --git a/bridge/npbackend/bohrium/nobh/bincount.py b/bridge/npbackend/bohrium/nobh/bincount.py index 0b1fdb321..26149523d 100644 --- a/bridge/npbackend/bohrium/nobh/bincount.py +++ b/bridge/npbackend/bohrium/nobh/bincount.py @@ -1,10 +1,9 @@ import math import numpy_force as np - +from bohrium_api import stack_info from .. import interop_pyopencl from .. import interop_pycuda from .. import array_create -from .. import bh_info from .bincount_cython import bincount_cython @@ -83,7 +82,7 @@ def bincount(x, weights=None, minlength=None): assert(np.issubdtype(x.dtype.type, np.integer)) assert(np.issubdtype(x.dtype.type, np.integer)) - if bh_info.is_proxy_in_stack(): # Cannot directly access array data through a proxy + if stack_info.is_proxy_in_stack(): # Cannot directly access array data through a proxy return np.bincount(x.copy2numpy(), weights=weights, minlength=minlength) try: diff --git a/bridge/npbackend/bohrium/ufuncs.pyx b/bridge/npbackend/bohrium/ufuncs.pyx index aff4445fd..b0d9eaba6 100644 --- a/bridge/npbackend/bohrium/ufuncs.pyx +++ b/bridge/npbackend/bohrium/ufuncs.pyx @@ -13,7 +13,7 @@ from . import _util from . import array_create from . import loop import numpy_force as np -from bohrium_api import _info +from bohrium_api import _info, stack_info from .numpy_backport import as_strided from ._util import dtype_equal from .bhary import fix_biclass_wrapper @@ -354,7 +354,6 @@ class Ufunc(object): [ 9, 13]]) """ from . import _bh - from . import bh_info if out is not None: if bhary.check(out): @@ -427,7 +426,7 @@ class Ufunc(object): else: # Let's sort the axis indexes by their stride # We use column major when a GPU is in the stack - column_major = bh_info.is_opencl_in_stack() or bh_info.is_cuda_in_stack() + column_major = stack_info.is_opencl_in_stack() or stack_info.is_cuda_in_stack() strides = [] for i, s in enumerate(ary.strides): if i in axis: diff --git a/bridge/npbackend/setup.py b/bridge/npbackend/setup.py index ea38fb5de..420a4e119 100755 --- a/bridge/npbackend/setup.py +++ b/bridge/npbackend/setup.py @@ -47,18 +47,18 @@ def script_path(*paths): def get_version(): - """Returns the version and true if version.py exist""" + """Returns the version, version_info, and true if version.py exist""" ver_path = script_path("bohrium", "version.py") if os.path.exists(ver_path): print("Getting version from version.py") # Loading `__version__` variable from the version file with open(ver_path, "r") as f: exec (f.read()) - return (__version__, True) + return (__version__, __version_info__, True) else: print("Getting version from bohrium_api") import bohrium_api - return (bohrium_api.__version__, False) + return (bohrium_api.__version__, bohrium_api.__version_info__, False) def get_pyx_extensions(): @@ -87,13 +87,14 @@ def get_pyx_extensions(): def gen_version_file_in_cmd(self, target_dir): """We extend the setup commands to also generate the `version.py` file if it doesn't exist already""" if not self.dry_run: - version, version_file_exist = get_version() + version, version_info, version_file_exist = get_version() if not version_file_exist: self.mkpath(target_dir) p = os.path.join(target_dir, 'version.py') print("Generating '%s'" % p) with open(p, 'w') as fobj: fobj.write("__version__ = \"%s\"\n" % version) + fobj.write("__version_info__ = (%d, %d, %d, %d)\n" % version_info) class BuildPy(setup_build_py): diff --git a/bridge/py_api/bohrium_api/__init__.py b/bridge/py_api/bohrium_api/__init__.py index 5c8349f4c..2cb2fd11c 100644 --- a/bridge/py_api/bohrium_api/__init__.py +++ b/bridge/py_api/bohrium_api/__init__.py @@ -7,7 +7,7 @@ """ import os from ._bh_api import _C_API # Exposing the C_API of `_bh_api.c` -from ._info import __version__ +from .version import __version__, __version_info__ from . import stack_info diff --git a/bridge/py_api/bohrium_api/stack_info.py b/bridge/py_api/bohrium_api/stack_info.py index 9283c619b..8f06a28fd 100644 --- a/bridge/py_api/bohrium_api/stack_info.py +++ b/bridge/py_api/bohrium_api/stack_info.py @@ -5,7 +5,7 @@ import os from os.path import join from . import messaging -from . import _info +from .version import __version__, __version_info__ # Some cached info _opencl_is_in_stack = None @@ -34,11 +34,6 @@ def installed_through_pypi(): return os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.ini")) -def version(): - """Return the version of Bohrium""" - return _info.__version__ - - def header_dir(): """Return the path to the C header directory""" return os.path.join(os.path.abspath(os.path.dirname(__file__)), "include") @@ -48,7 +43,8 @@ def info(): """Return a dict with all info""" return { "config_path": config_file_path(), - "version": version(), + "version": __version__, + "version_info": __version_info__, "runtime_info": messaging.runtime_info(), "statistics": messaging.statistic(), "header_dir": header_dir(), @@ -89,7 +85,7 @@ def pprint(): Header dir: %s Backend stack: %s---- -""" % (version(), installed_through_pypi(), config_file_path(), header_dir(), messaging.runtime_info()) +""" % (__version__, installed_through_pypi(), config_file_path(), header_dir(), messaging.runtime_info()) if not (is_opencl_in_stack() or is_cuda_in_stack()): ret += "Note: in order to activate and retrieve GPU info, set the `BH_STACK=opencl` " \ "or `BH_STACK=cuda` environment variable.\n" From e1c879748f4165115027784b3c251da980e94d5e Mon Sep 17 00:00:00 2001 From: "Mads R. B. Kristensen" Date: Mon, 10 Dec 2018 10:59:54 +0100 Subject: [PATCH 4/5] Now bohrium requires bohrium API of same version or higher --- bridge/npbackend/setup.py | 34 ++++++++++++++++++++++++++-------- bridge/py_api/build.bash | 2 +- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/bridge/npbackend/setup.py b/bridge/npbackend/setup.py index 420a4e119..ce59376da 100755 --- a/bridge/npbackend/setup.py +++ b/bridge/npbackend/setup.py @@ -46,19 +46,37 @@ def script_path(*paths): return os.path.join(prefix, *paths) +def version_file_exist(): + """Return whether the version.py file exist or not""" + ver_path = script_path("bohrium", "version.py") + return os.path.exists(ver_path) + + def get_version(): - """Returns the version, version_info, and true if version.py exist""" + """Returns the version and version_info. + If the version.py file doesn't exist, the version of Bohrium API is returned. + NB: If the version.py file doesn't exist, this function must be called after the call to `setup()`. + """ ver_path = script_path("bohrium", "version.py") if os.path.exists(ver_path): print("Getting version from version.py") # Loading `__version__` variable from the version file with open(ver_path, "r") as f: exec (f.read()) - return (__version__, __version_info__, True) + return (__version__, __version_info__) else: print("Getting version from bohrium_api") import bohrium_api - return (bohrium_api.__version__, bohrium_api.__version_info__, False) + return (bohrium_api.__version__, bohrium_api.__version_info__) + + +def get_bohrium_api_required_string(): + """Returns the install_requires/setup_requires string for `bohrium_api`""" + try: + ver_tuple = get_version()[1] + return "bohrium_api>=%d.%d.%d" % (ver_tuple[0], ver_tuple[1], ver_tuple[2]) + except ImportError: + return "bohrium_api" # If `bohrium_api` is not available, we expect PIP to install the newest package def get_pyx_extensions(): @@ -87,14 +105,14 @@ def get_pyx_extensions(): def gen_version_file_in_cmd(self, target_dir): """We extend the setup commands to also generate the `version.py` file if it doesn't exist already""" if not self.dry_run: - version, version_info, version_file_exist = get_version() - if not version_file_exist: + version, version_info = get_version() + if not version_file_exist(): self.mkpath(target_dir) p = os.path.join(target_dir, 'version.py') print("Generating '%s'" % p) with open(p, 'w') as fobj: fobj.write("__version__ = \"%s\"\n" % version) - fobj.write("__version_info__ = (%d, %d, %d, %d)\n" % version_info) + fobj.write("__version_info__ = %s\n" % str(version_info)) class BuildPy(setup_build_py): @@ -174,8 +192,8 @@ def __str__(self): keywords='Bohrium, bh107, Python, C, HPC, MPI, PGAS, CUDA, OpenCL, OpenMP', # Dependencies - install_requires=['numpy>=1.7', 'bohrium_api'], - setup_requires=['numpy>=1.7', 'bohrium_api'], + install_requires=['numpy>=1.7', get_bohrium_api_required_string()], + setup_requires=['numpy>=1.7', get_bohrium_api_required_string()], # You can just specify the packages manually here if your project is # simple. Or you can use find_packages(). diff --git a/bridge/py_api/build.bash b/bridge/py_api/build.bash index 583a26a5b..32eadcdf9 100755 --- a/bridge/py_api/build.bash +++ b/bridge/py_api/build.bash @@ -17,7 +17,7 @@ if [[ -d "$VR_PATH" ]]; then echo "Using virtualenv: $VR_PATH" else echo "Create virtualenv: $VR_PATH" - ${PYTHON_EXECUTABLE} -m virtualenv -p ${PY_EXE} ${VR_PATH} + ${PYTHON_EXECUTABLE} -m virtualenv -p ${PY_EXE} --system-site-packages ${VR_PATH} fi source ${VR_PATH}/bin/activate From f9da4d0088f9ffdd85604d77cc6879d6a1f795c6 Mon Sep 17 00:00:00 2001 From: "Mads R. B. Kristensen" Date: Mon, 10 Dec 2018 11:04:05 +0100 Subject: [PATCH 5/5] version bump --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 78bc1abd1..571215736 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.10.0 +0.10.1