Skip to content

Commit

Permalink
adapt to latest pycvodes (#114)
Browse files Browse the repository at this point in the history
* adapt to latest pycvodes

* bump pycompilation req

* Drop commented code

* Bump pycompilation>=0.4.9 to handle ldflags
  • Loading branch information
bjodah authored May 28, 2020
1 parent 1a47737 commit 86fbbae
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 29 deletions.
12 changes: 8 additions & 4 deletions .ci/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,21 @@ echo -e "[global]\nno-cache-dir = false\ndownload-cache = $(pwd)/ci_cache/pip_ca
python3 -m pip install symcxx pysym # unofficial backends, symengine is tested in the conda build

# (cd ./tmp/pycvodes;
CFLAGS="-isystem $SUNDBASE/include $CFLAGS" LDFLAGS="-Wl,--disable-new-dtags -Wl,-rpath,$SUNDBASE/lib -L$SUNDBASE/lib $LDFLAGS" python3 -m pip install pycvodes # setup.py install )
SUND_CFLAGS="-isystem $SUNDBASE/include $CFLAGS"
SUND_LDFLAGS="-Wl,--disable-new-dtags -Wl,-rpath,$SUNDBASE/lib -L$SUNDBASE/lib $LDFLAGS"
CFLAGS=$SUND_CFLAGS LDFLAGS=$SUND_LDFLAGS python3 -m pip install pycvodes
git clean -xfd # -e tmp/

export CPATH=$SUNDBASE/include
export LIBRARY_PATH=$SUNDBASE/lib
export LD_LIBRARY_PATH=$SUNDBASE/lib
# export CPATH=$SUNDBASE/include
# export LIBRARY_PATH=$SUNDBASE/lib
# export LD_LIBRARY_PATH=$SUNDBASE/lib

python3 setup.py sdist
PKG_VERSION=$(python3 setup.py --version)
(cd dist/; python3 -m pip install $PKG_NAME-$PKG_VERSION.tar.gz)
python3 -m pip install -e .[all]
export PYODESYS_CVODE_FLAGS=$SUND_CFLAGS
export PYODESYS_CVODE_LDFLAGS=$SUND_LDFLAGS
python3 -m pytest -xv -k test_integrate_chained_robertson pyodesys/tests/test_robertson.py
export PYTHONHASHSEED=$(python3 -c "import random; print(random.randint(1,2**32-1))")
PYTHON="python3 -R" ./scripts/run_tests.sh --cov $PKG_NAME --cov-report html
Expand Down
24 changes: 12 additions & 12 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,55 +17,55 @@ pipeline:
ttl: 90 # liftetime in days

# get-pre-reqs:
# image: bjodah/bjodahimg20dev:v1.1.0
# image: bjodah/bjodahimg20dev:v1.2.0
# commands:
# - mkdir ./tmp
# - git clone --recurse-submodules https://github.com/bjodah/pycvodes.git ./tmp/pycvodes

# test-py2:
# image: bjodah/bjodahimg20dev:v1.1.0
# image: bjodah/bjodahimg20dev:v1.2.0
# environment:
# - CC=gcc-10
# - CXX=g++-10
# - OMP_NUM_THREADS=1
# - ANYODE_NUM_THREADS=2
# - CPLUS_INCLUDE_PATH=/usr/include/suitesparse:/opt/boost_1_72_p/include
# - CPLUS_INCLUDE_PATH=/usr/include/suitesparse:/opt/boost_1_73_p/include
# - LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
# - LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
# - SUNDBASE=/opt/sundials-5.2.0-klu-lapack
# - SUNDBASE=/opt/sundials-5.3.0-klu-lapack
# commands:
# - apt-get update && apt-get --assume-yes install python2-dev
# - bash -c "ulimit -v 2048000; .ci/test_py2.sh pyodesys $SUNDBASE"

test-sund-5.2.0-klu:
test-sund-5.3.0-klu:
group: testing
image: bjodah/bjodahimg20dev:v1.1.0
image: bjodah/bjodahimg20dev:v1.2.0
environment:
- CC=gcc-10
- CXX=g++-10
- OMP_NUM_THREADS=1
- ANYODE_NUM_THREADS=2
- CPLUS_INCLUDE_PATH=/usr/include/suitesparse:/opt/boost_1_72_p/include
- CPLUS_INCLUDE_PATH=/usr/include/suitesparse:/opt/boost_1_73_p/include
- LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
- LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
- SUNDBASE=/opt/sundials-5.2.0-klu-lapack
- SUNDBASE=/opt/sundials-5.3.0-klu-lapack
commands:
- bash -c "ulimit -v 2048000; .ci/run_ci.sh pyodesys $SUNDBASE"
- ./scripts/prepare_deploy.sh
- bash -c '[[ $(python3 setup.py --version) =~ ^[0-9]+.* ]]'

test-sund-5.2.0-nolapack-noklu-extended:
test-sund-5.3.0-nolapack-noklu-extended:
group: testing
image: bjodah/bjodahimg20dev:v1.1.0
image: bjodah/bjodahimg20dev:v1.2.0
environment:
- CC=gcc-10
- CXX=g++-10
- OMP_NUM_THREADS=1
- ANYODE_NUM_THREADS=2
- CPLUS_INCLUDE_PATH=/usr/include/suitesparse:/opt/boost_1_72_p/include
- CPLUS_INCLUDE_PATH=/usr/include/suitesparse:/opt/boost_1_73_p/include
- LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
- LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
- SUNDBASE=/opt/sundials-5.2.0-noklu-nolapack-extended-int64
- SUNDBASE=/opt/sundials-5.3.0-noklu-nolapack-extended-int64
- PYCVODES_NO_LAPACK=1
- PYCVODES_NO_KLU=1
commands:
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ the solvers and then their python bindings. The 3rd party requirements are as fo

- pygslodeiv2_ (requires GSL_ >=1.16)
- pyodeint_ (requires boost_ >=1.72.0)
- pycvodes_ (requires SUNDIALS_ >=5.2.0)
- pycvodes_ (requires SUNDIALS_ >=5.3.0)

.. _GSL: https://www.gnu.org/software/gsl/
.. _boost: http://www.boost.org/
Expand Down
2 changes: 1 addition & 1 deletion conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ requirements:
- pyodeint >=0.10.1
- pygslodeiv2 >=0.9.1
- pycvodes >=0.11.12
- pycompilation >=0.4.6
- pycompilation >=0.4.9
- pycodeexport >=0.1.2
- cython
- python-symengine
Expand Down
2 changes: 1 addition & 1 deletion external/anyode
2 changes: 1 addition & 1 deletion pyodesys/_release.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.13.0.dev0+git'
__version__ = '0.13.1.dev0+git'
4 changes: 4 additions & 0 deletions pyodesys/native/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ class _NativeCodeBase(Cpp_Code):
# `namespace_extend` is set in init

def __init__(self, odesys, *args, **kwargs):
if Cpp_Code is object:
raise ModuleNotFoundError("failed to import Cpp_Code from pycodeexport")
if compile_sources is None:
raise ModuleNotFoundError("failed to import compile_sources from pycompilation")
if odesys.nroots > 0 and not self._support_roots:
raise ValueError("%s does not support nroots > 0" % self.__class__.__name__)
self.namespace_override = kwargs.pop('namespace_override', {})
Expand Down
16 changes: 9 additions & 7 deletions pyodesys/native/cvode.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ..util import import_
from ._base import _NativeCodeBase, _NativeSysBase, _compile_kwargs

_config, get_include, _libs = import_('pycvodes', 'config', 'get_include', "_libs")
get_include, config, _libs = import_("pycvodes", "get_include", "config", "_libs")

if sys.version_info < (3, 6, 0):
class ModuleNotFoundError(ImportError):
Expand All @@ -19,8 +19,8 @@ class NativeCvodeCode(_NativeCodeBase):
wrapper_name = '_cvode_wrapper'

try:
_realtype = _config['REAL_TYPE']
_indextype = _config['INDEX_TYPE']
_realtype = config['REAL_TYPE']
_indextype = config['INDEX_TYPE']
except ModuleNotFoundError:
_realtype = '#error "realtype_failed-to-import-pycvodes-or-too-old-version"'
_indextype = '#error "indextype_failed-to-import-pycvodes-or-too-old-version"'
Expand All @@ -37,13 +37,15 @@ class NativeCvodeCode(_NativeCodeBase):

def __init__(self, *args, **kwargs):
self.compile_kwargs = copy.deepcopy(_compile_kwargs)
self.compile_kwargs['define'] = ['PYCVODES_NO_KLU={}'.format("0" if _config.get('KLU', True) else "1"),
'PYCVODES_NO_LAPACK={}'.format("0" if _config.get('LAPACK', True) else "1"),
'ANYODE_NO_LAPACK={}'.format("0" if _config.get('LAPACK', True) else "1")]
self.compile_kwargs['define'] = ['PYCVODES_NO_KLU={}'.format("0" if config.get('KLU', True) else "1"),
'PYCVODES_NO_LAPACK={}'.format("0" if config.get('LAPACK', True) else "1"),
'ANYODE_NO_LAPACK={}'.format("0" if config.get('LAPACK', True) else "1")]
self.compile_kwargs['include_dirs'].append(get_include())
self.compile_kwargs['libraries'].extend(_libs.get_libs().split(','))
self.compile_kwargs['libraries'].extend([l for l in os.environ.get(
'PYODESYS_LAPACK', "lapack,blas" if _config["LAPACK"] else "").split(",") if l != ""])
'PYODESYS_LAPACK', "lapack,blas" if config["LAPACK"] else "").split(",") if l != ""])
self.compile_kwargs['flags'] = [f for f in os.environ.get("PYODESYS_CVODE_FLAGS", "").split() if f]
self.compile_kwargs['ldflags'] = [f for f in os.environ.get("PYODESYS_CVODE_LDFLAGS", "").split() if f]
super(NativeCvodeCode, self).__init__(*args, **kwargs)


Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ def _path_under_setup(*args):
_author, _author_email = open(_path_under_setup('AUTHORS'), 'rt').readline().split('<')

extras_req = {
'integrators': ['pyodeint>=0.10.3', 'pycvodes>=0.13', 'pygslodeiv2>=0.9.3'],
'native': ['pycompilation>=0.4.3', 'pycodeexport>=0.1.2', 'appdirs'],
'integrators': ['pyodeint>=0.10.3', 'pycvodes>=0.13.1', 'pygslodeiv2>=0.9.3'],
'native': ['pycompilation>=0.4.9', 'pycodeexport>=0.1.2', 'appdirs'],
'docs': ['Sphinx', 'sphinx_rtd_theme', 'numpydoc'],
'testing': ['pytest', 'pytest-cov', 'pytest-flakes', 'pytest-pep8', 'rstcheck']
}
Expand Down

0 comments on commit 86fbbae

Please sign in to comment.