Skip to content

Commit 84733df

Browse files
authored
Make sure anyode headers are distributed (#124)
* run tests for sdist install * select all for tests * move flags for compilation * pass yes-flag to pip-uninstall * move nogil * bump commits * nogil except + * bjodahimg20dot -> triceratops-3:24 * ci: update paths and env * exit on first failed test * -std=c++11 -> -std=c++20 * .so -> EXT_SUFFIX in sysconfig * avoid package from bdf2 branch * relax test tolerances * add appdirs to default requirements * Bump CI image * specify branch for AnyODE submodule * update AnyODE * relax maxnum steps for CI server * Add boost to CPLUS_INCLUDE_PATH * Relax nsteps param for test for CI server * update CI image * TST: max_num_test to see if CI failure is resolved * split test * run ci tests with 4 GiB RAM? * handle flaky boost-odeint test * mark flaky test xfail * mark actual flaky test flaky * Python 3 no longer needs to inherit from object * Set PYTHONPATH during rendering of notebooks? * matplotlib, kw: linthreshy -> linthresh * Update matplotlib 3d projection code * PYTHONPATH shenanigans
1 parent c1665ad commit 84733df

21 files changed

Lines changed: 129 additions & 82 deletions

.ci/run_ci.sh

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,46 @@ if [ ! -e "$SUNDBASE/include/sundials/sundials_config.h" ]; then
99
>&2 echo "Not a valid prefix for sundials: $SUNDBASE"
1010
exit 1
1111
fi
12-
12+
if [ -e /etc/profile.d/boost.sh ]; then
13+
source /etc/profile.d/boost.sh
14+
export CPATH=$BOOST_ROOT/include
15+
fi
16+
source $(compgen -G "/opt-3/cpython-v3.*-apt-deb/bin/activate")
17+
python -m pip install --cache-dir $CI_WORKSPACE/cache-ci/pip_cache --upgrade-strategy=eager --upgrade cython "git+https://github.com/bjodah/pycompilation@master#egg=pycompilation"
1318
# REPO_TEMP_DIR="$(mktemp -d)"
1419
# trap 'rm -rf -- "$REPO_TEMP_DIR"' EXIT
1520
# cp -ra . "$REPO_TEMP_DIR/."
1621
# cd "$REPO_TEMP_DIR"
1722

1823
mkdir -p $HOME/.config/pip/
1924
echo -e "[global]\nno-cache-dir = false\ndownload-cache = $CI_WORKSPACE/cache-ci/pip_cache" >$HOME/.config/pip/pip.conf
20-
python3 -m pip install symcxx pysym # unofficial backends, symengine is tested in the conda build
25+
python -m pip install mako cython
26+
python -m pip install --no-build-isolation "git+https://github.com/bjodah/symcxx#egg=symcxx" "git+https://github.com/bjodah/pysym#egg=pysym" # unofficial backends, symengine is tested in the conda build
2127

2228
# (cd ./tmp/pycvodes;
2329
SUND_CFLAGS="-isystem $SUNDBASE/include $CFLAGS"
2430
SUND_LDFLAGS="-Wl,--disable-new-dtags -Wl,-rpath,$SUNDBASE/lib -L$SUNDBASE/lib $LDFLAGS"
25-
CFLAGS=$SUND_CFLAGS LDFLAGS=$SUND_LDFLAGS python3 -m pip install pycvodes
26-
31+
CFLAGS="$SUND_CFLAGS $CXXFLAGS" CXXFLAGS="$SUND_CFLAGS $CXXFLAGS" LDFLAGS=$SUND_LDFLAGS python -m pip install --no-build-isolation pycvodes
32+
CPLUS_INCLUDE_PATH="$BOOST_ROOT/include" python -m pip install --no-build-isolation "git+https://github.com/bjodah/pyodeint#egg=pyodeint"
33+
python -m pip install --no-build-isolation "git+https://github.com/bjodah/pygslodeiv2#egg=pygslodeiv2"
2734

28-
python3 setup.py sdist
29-
PKG_VERSION=$(python3 setup.py --version)
35+
python setup.py sdist
36+
PKG_VERSION=$(python setup.py --version)
3037
export PYODESYS_CVODE_FLAGS=$SUND_CFLAGS
3138
export PYODESYS_CVODE_LDFLAGS=$SUND_LDFLAGS
32-
(cd dist/; python3 -m pip install "$PKG_NAME-$PKG_VERSION.tar.gz[all]"; python3 -m pytest --pyargs $PKG_NAME)
33-
python3 -m pip uninstall --yes $PKG_NAME
34-
python3 -m pip install -e .[all]
35-
python3 -m pytest -xv -k test_integrate_chained_robertson pyodesys/tests/test_robertson.py
39+
(cd dist/; python -m pip install "$PKG_NAME-$PKG_VERSION.tar.gz[all]"; python -m pytest -v -x --pyargs $PKG_NAME)
40+
python -m pip uninstall --yes $PKG_NAME
41+
python -m pip install -e .[all]
42+
python -m pytest -xv -k test_integrate_chained_robertson pyodesys/tests/test_robertson.py
3643
export PYTHONHASHSEED=$(python3 -c "import random; print(random.randint(1,2**32-1))")
37-
PYTHON="python3 -R" ./scripts/run_tests.sh --cov $PKG_NAME --cov-report html
44+
PYTHON="python -R" ./scripts/run_tests.sh --cov $PKG_NAME --cov-report html
3845

39-
./scripts/render_notebooks.sh
40-
(cd $PKG_NAME/tests; jupyter nbconvert --log-level=INFO --to=html --ExecutePreprocessor.enabled=True --ExecutePreprocessor.timeout=600 *.ipynb)
46+
( export PYTHONPATH=$(pwd); ./scripts/render_notebooks.sh; cd $PKG_NAME/tests; jupyter nbconvert --log-level=INFO --to=html --ExecutePreprocessor.enabled=True --ExecutePreprocessor.timeout=600 *.ipynb )
4147
./scripts/generate_docs.sh
4248

4349
# Test package without any 3rd party libraries that are in extras_require:
44-
python3 -m pip install virtualenv
45-
python3 -m virtualenv venv
50+
python -m pip install virtualenv
51+
python -m virtualenv venv
4652
git archive -o dist/$PKG_NAME-head.zip HEAD # test pip installable zip (symlinks break)
4753
set +u
48-
(source ./venv/bin/activate; cd dist/; python3 -m pip install pytest $PKG_NAME-head.zip; python3 -m pytest --pyargs $PKG_NAME)
54+
(source ./venv/bin/activate; cd dist/; python -m pip install pytest $PKG_NAME-head.zip; python -m pytest --pyargs $PKG_NAME)

.gitmodules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[submodule "external/anyode"]
22
path = external/anyode
33
url = https://github.com/bjodah/anyode
4+
branch = master

.woodpecker.yaml

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,79 @@
1+
variables:
2+
- &ci_image 'cont-reg.bjodah.se:443/bjodah/triceratops-4:25'
3+
14
when:
25
- event: [push]
36

47
steps:
58

69
- name: restore-cache
7-
image: bjodah/bjodahimg20dot:21.8.a
10+
image: *ci_image
811
commands:
912
- curl ftp://${CI_REPO_NAME}:$${ARTIFACTS_PASS}@$${FTP_SERVER}/cache/cache-ci.tar | tar -C / x || mkdir -p $CI_WORKSPACE/cache-ci/pip_cache
1013
secrets: [ ARTIFACTS_PASS, FTP_SERVER ]
1114
when:
1215
- event: push
1316
repo: bjodah/pyodesys
1417

15-
- name: test-sund-5.7.0-rel
18+
- name: test-sund-6.7.0-rel
1619
depends_on: restore-cache
17-
image: bjodah/bjodahimg20dot:21.8.a
20+
image: *ci_image
1821
environment:
19-
- CC=gcc-11
20-
- CXX=g++-11
22+
- CC=gcc-14
23+
- CXX=g++-14
24+
- CXXFLAGS=-std=c++20
2125
- OMP_NUM_THREADS=1
2226
- ANYODE_NUM_THREADS=2
23-
- CPLUS_INCLUDE_PATH=/usr/include/suitesparse:/opt/boost-1.77.0/include
27+
- CPLUS_INCLUDE_PATH=/usr/include/suitesparse:/opt-3/boost-1.88.0/include
2428
- LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
2529
- LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
26-
- SUNDBASE=/opt/sundials-5.7.0-release
30+
- SUNDBASE=/opt-3/sundials-6.7.0-release
2731
commands:
28-
- cp -ra $CI_WORKSPACE /tmp/test-sund-5.7.0-rel
29-
- cd /tmp/test-sund-5.7.0-rel
30-
- python3 -m pip install --cache-dir $CI_WORKSPACE/cache-ci/pip_cache --upgrade-strategy=eager --upgrade cython https://github.com/bjodah/pycompilation/archive/master.tar.gz
31-
- bash -c "ulimit -v 2048000; .ci/run_ci.sh pyodesys $SUNDBASE"
32+
- cp -ra $CI_WORKSPACE /tmp/test-sund-6.7.0-rel
33+
- cd /tmp/test-sund-6.7.0-rel
34+
- bash -lc "ulimit -v 2048000; .ci/run_ci.sh pyodesys $SUNDBASE"
3235
- ./scripts/prepare_deploy.sh
3336
- bash -c '[[ $(python3 setup.py --version) =~ ^[0-9]+.* ]]'
34-
- cp -ra /tmp/test-sund-5.7.0-rel/deploy $CI_WORKSPACE/
37+
- cp -ra /tmp/test-sund-6.7.0-rel/deploy $CI_WORKSPACE/
3538

36-
- name: test-sund-5.7.0-extended
39+
- name: test-sund-6.7.0-extended
3740
depends_on: restore-cache
38-
image: bjodah/bjodahimg20dot:21.8.a
41+
image: *ci_image
3942
environment:
40-
- CC=gcc-11
41-
- CXX=g++-11
43+
- CC=gcc-14
44+
- CXX=g++-14
45+
- CXXFLAGS=-std=c++20
4246
- OMP_NUM_THREADS=1
4347
- ANYODE_NUM_THREADS=2
44-
- CPLUS_INCLUDE_PATH=/usr/include/suitesparse:/opt/boost-1.77.0/include
48+
- CPLUS_INCLUDE_PATH=/usr/include/suitesparse:/opt-3/boost-1.88.0/include
4549
- LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
4650
- LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
47-
- SUNDBASE=/opt/sundials-5.7.0-extended
51+
- SUNDBASE=/opt-3/sundials-6.7.0-extended
4852
- PYCVODES_NO_LAPACK=1
4953
- PYCVODES_NO_KLU=1
5054
commands:
51-
- cp -ra $CI_WORKSPACE/ /tmp/test-sund-5.7.0-extended
52-
- cd /tmp/test-sund-5.7.0-extended
53-
- python3 -m pip install --cache-dir $CI_WORKSPACE/cache-ci/pip_cache --upgrade-strategy=eager --upgrade cython
54-
- bash -c "ulimit -v 2048000; .ci/run_ci.sh pyodesys $SUNDBASE"
55+
- cp -ra $CI_WORKSPACE/ /tmp/test-sund-6.7.0-extended
56+
- cd /tmp/test-sund-6.7.0-extended
57+
- bash -lc "ulimit -v 4096000; .ci/run_ci.sh pyodesys $SUNDBASE"
5558
- ./scripts/grep-for-merge-blocking-token.sh
5659
- ./scripts/grep-for-binary-data.sh
5760

5861
- name: rebuild-cache
59-
image: bjodah/bjodahimg20dot:21.8.a
62+
image: *ci_image
6063
commands:
6164
- find $CI_WORKSPACE/cache-ci/ -type f -mtime +90 -exec rm {} \;
6265
- tar cf cache-ci.tar $CI_WORKSPACE/cache-ci/
6366
- curl -T cache-ci.tar ftp://${CI_REPO_NAME}:$${ARTIFACTS_PASS}@$${FTP_SERVER}/cache/
6467
secrets: [ ARTIFACTS_PASS, FTP_SERVER ]
6568
depends_on:
66-
- test-sund-5.7.0-rel
69+
- test-sund-6.7.0-rel
6770

6871
- name: deploy-public-html
69-
image: bjodah/bjodahimg20dot:21.8.a
72+
image: *ci_image
7073
commands:
7174
- tar -C deploy/public_html -czf ${CI_REPO_NAME}-${CI_COMMIT_BRANCH}.tar.gz .
7275
- curl -T ${CI_REPO_NAME}-${CI_COMMIT_BRANCH}.tar.gz ftp://${CI_REPO_NAME}:$${ARTIFACTS_PASS}@$${FTP_SERVER}/public_html/
7376
secrets: [ ARTIFACTS_PASS, FTP_SERVER ]
7477
depends_on:
75-
- test-sund-5.7.0-rel
78+
- test-sund-6.7.0-rel
7679

examples/_native_override_chemical_kinetics.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
" axes[0].axvline(result.xout[-1], linestyle='--', label='t = %.4f' % result.xout[-1])\n",
5959
" result.plot(ax=axes[0])\n",
6060
" result.plot(ax=axes[1], deriv=True)\n",
61-
" axes[1].set_yscale('symlog', linthreshy=1e-9)\n",
61+
" axes[1].set_yscale('symlog', linthresh=1e-9)\n",
6262
" axes[1].axhline(1e-9, linestyle='--')\n",
6363
" axes[1].axhline(-1e-9, linestyle='--')\n",
6464
" for ax in axes:\n",

examples/_nonlinear_3body_system.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"outputs": [],
100100
"source": [
101101
"fig1 = plt.figure()\n",
102-
"ax = fig1.gca(projection='3d')\n",
102+
"ax = fig1.add_subplot(projection='3d')\n",
103103
"ax.plot(*res.yout[:, 0:3].T, alpha=1.0, color='r')\n",
104104
"ax.plot(*res.yout[:, 3:6].T, alpha=1.0, color='g')\n",
105105
"ax.plot(*res.yout[:, 6:9].T, alpha=1.0, color='b')"

examples/_radiolysis.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
" plot_kw = dict(legend=dict(loc='center left', prop={'size': 8}), xscale='log')\n",
5252
" for r, axcol in zip(res, axes.T):\n",
5353
" r.plot(ax=axcol[0], yscale='log', title_info=2, **plot_kw)\n",
54-
" r.plot(ax=axcol[1], deriv=True, yscale='symlog;linthreshy=1e-9', **plot_kw)\n",
54+
" r.plot(ax=axcol[1], deriv=True, yscale='symlog;linthresh=1e-9', **plot_kw)\n",
5555
" r.plot_invariant_violations(ax=axcol[2], **plot_kw)\n",
5656
" for ax in axcol:\n",
5757
" ax.set_xlim([1e-13, 1e-3])\n",

examples/lorenz.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
" xout, yout, info = odesystem.integrate(\n",
8585
" 10, y0, dict(sigma=sigma, rho=rho, beta=beta),\n",
8686
" integrator='cvode', nsteps=5000)\n",
87-
" ax = fig.gca(projection='3d')\n",
87+
" ax = fig.add_subplot(projection='3d')\n",
8888
" for lines in stack:\n",
8989
" lines[0].set_alpha(0.6*lines[0].get_alpha())\n",
9090
" stack.append(ax.plot(*yout.T, alpha=1.0, color='g'))\n",

pyodesys/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class RecoverableError(Exception):
2525
pass
2626

2727

28-
class ODESys(object):
28+
class ODESys:
2929
""" Object representing an ODE system.
3030
3131
``ODESys`` provides unified interface to:

pyodesys/native/_base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import os
99
import shutil
1010
import sys
11+
import sysconfig
1112
import tempfile
1213

1314
import numpy as np
@@ -39,13 +40,13 @@
3940

4041
_compile_kwargs = {
4142
'options': ['warn', 'pic', 'fast', 'openmp'],
42-
'std': 'c++11',
43+
'std': 'c++20',
4344
'include_dirs': [np.get_include(), pkg_resources.resource_filename(__name__, 'sources')],
4445
'libraries': [],
4546
'cplus': True,
4647
}
4748

48-
_ext_suffix = '.so' # sysconfig.get_config_var('EXT_SUFFIX')
49+
_ext_suffix = sysconfig.get_config_var('EXT_SUFFIX')
4950
_obj_suffix = '.o' # os.path.splitext(_ext_suffix)[0] + '.o' # '.obj'
5051

5152

@@ -90,7 +91,7 @@ def __init__(self, odesys, *args, **kwargs):
9091
self.namespace_extend = kwargs.pop('namespace_extend', {})
9192
self.tempdir_basename = '_pycodeexport_pyodesys_%s' % self.__class__.__name__
9293
self.obj_files = self.obj_files + ('%s%s' % (self.wrapper_name, _obj_suffix),)
93-
self.so_file = '%s%s' % (self.wrapper_name, '.so')
94+
self.so_file = '%s%s' % (self.wrapper_name, _ext_suffix)
9495
_wrapper_src = pkg_resources.resource_filename(
9596
__name__, 'sources/%s.pyx' % self.wrapper_name)
9697
if cachedir is None:

0 commit comments

Comments
 (0)