Skip to content

Commit f6657db

Browse files
authored
Update Dockerfile (#233)
* Update Dockerfile * new script * bump req. versions
1 parent 62946d8 commit f6657db

File tree

7 files changed

+128
-93
lines changed

7 files changed

+128
-93
lines changed

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ build/
2626
*.bak0
2727
*.bak1
2828
sundials-*.tar.gz
29-
.local/
30-
.ipython/
31-
.jupyter/*
32-
!.jupyter/jupyter_notebook_config.py
29+
.env/
3330
tmp/
3431
.coverage
3532
htmlcov/

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ Using Docker
107107
If you have `Docker <https://www.docker.com>`_ installed, you may use it to host a jupyter
108108
notebook server::
109109

110-
$ ./scripts/host-jupyter-using-docker.sh . 8888
110+
$ ./scripts/host-env.sh host-notebook --port 8888
111111

112112
the first time you run the command, some dependencies will be downloaded. When the installation
113113
is complete there will be a link visible which you can open in your browser. You can also run
114114
the test suite using the same docker-image::
115115

116-
$ ./scripts/host-jupyter-using-docker.sh . 0
116+
$ ./scripts/host-env.sh run-tests
117117

118118
there will be a few skipped test (due to some dependencies not being installed by default) and
119119
quite a few warnings.

chempy/util/tests/test_graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from ..testing import requires, skipif
1212

1313
try:
14-
dot_missing = subprocess.call(["dot", "-?"]) != 0
14+
dot_missing = subprocess.run(["dot", "-?"]).returncode != 0
1515
except OSError:
1616
dot_missing = True
1717

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
FROM docker.io/debian:bullseye
1+
FROM docker.io/debian:bookworm
22

33
MAINTAINER Björn Dahlgren <[email protected]>
44

55
ENV LANG C.UTF-8
66

77
RUN apt-get update && \
8-
apt-get --quiet --assume-yes install curl git g++-10 gfortran-10 libgmp-dev binutils-dev bzip2 make cmake sudo \
9-
python3-dev python3-pip libboost-dev libgsl-dev liblapack-dev libsuitesparse-dev graphviz && \
8+
apt-get --quiet --assume-yes install --no-install-recommends \
9+
curl git g++ gfortran libgmp-dev binutils-dev bzip2 make cmake sudo \
10+
python3-dev python3-venv python3-pip libboost-dev libgsl-dev liblapack-dev libsuitesparse-dev graphviz && \
1011
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
1112

12-
RUN mkdir /tmp/sundials-5.5.0-build && \
13-
curl -Ls https://github.com/LLNL/sundials/releases/download/v5.5.0/sundials-5.5.0.tar.gz | tar xz -C /tmp && \
14-
FC=gfortran-10 cmake \
15-
-S /tmp/sundials-5.5.0 \
16-
-B /tmp/sundials-5.5.0-build \
13+
RUN mkdir /tmp/sundials-5.8.0-build && \
14+
curl -Ls https://github.com/LLNL/sundials/releases/download/v5.8.0/sundials-5.8.0.tar.gz | tar xz -C /tmp && \
15+
FC=gfortran cmake \
16+
-S /tmp/sundials-5.8.0 \
17+
-B /tmp/sundials-5.8.0-build \
1718
-DCMAKE_INSTALL_PREFIX=/usr/local \
1819
-DCMAKE_BUILD_TYPE=Release \
1920
-DBUILD_SHARED_LIBS=ON \
@@ -25,15 +26,11 @@ RUN mkdir /tmp/sundials-5.5.0-build && \
2526
-DENABLE_KLU=ON \
2627
-DKLU_INCLUDE_DIR=/usr/include/suitesparse \
2728
-DKLU_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu && \
28-
cmake --build /tmp/sundials-5.5.0-build && \
29-
cmake --build /tmp/sundials-5.5.0-build --target install && \
30-
rm -r /tmp/sundials-5.5.0*/ && \
31-
python3 -m pip install --upgrade-strategy=eager --upgrade pip && \
32-
python3 -m pip install --upgrade-strategy=eager numpy cython setuptools && \
29+
cmake --build /tmp/sundials-5.8.0-build && \
30+
cmake --build /tmp/sundials-5.8.0-build --target install && \
31+
rm -r /tmp/sundials-5.8.0*/ && \
3332
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
3433

3534

36-
# http://computation.llnl.gov/projects/sundials/download/sundials-5.5.0.tar.gz
37-
3835
# At this point the system should be able to pip-install the package and all of its dependencies. We'll do so
3936
# when running the image using the ``host-jupyter-using-docker.sh`` script. Installed packages are cached.

scripts/host-env.sh

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/bin/bash
2+
show_help() {
3+
echo "Usage:"
4+
echo "$(basename $0) host-notebook --port 8888 --listen 127.0.0.1"
5+
echo "$(basename $0) run-tests"
6+
}
7+
set -euxo pipefail
8+
9+
HOST_NOTEBOOK=0
10+
RUN_TESTS=0
11+
PORT=8000
12+
while [ $# -gt 0 ]; do
13+
case "$1" in
14+
host-notebook)
15+
HOST_NOTEBOOK=1
16+
shift
17+
;;
18+
--port)
19+
shift
20+
PORT=$1
21+
shift
22+
;;
23+
--listen)
24+
shift
25+
LISTEN=$1
26+
shift
27+
;;
28+
run-tests)
29+
RUN_TESTS=1
30+
shift
31+
;;
32+
--help|-h)
33+
show_help
34+
exit 0
35+
;;
36+
--)
37+
break;
38+
;;
39+
*)
40+
show_help
41+
exit 1
42+
;;
43+
esac
44+
done
45+
46+
if ! which podrun >/dev/null; then
47+
SOME_TEMP_DIR=$(mktemp -d)
48+
trap 'rm -rf -- "$SOME_TEMP_DIR"' EXIT
49+
( cd "$SOME_TEMP_DIR"; curl -LOs https://raw.githubusercontent.com/bjodah/dotfiles/master/per-leaf-dir/bin/podrun; chmod +x podrun )
50+
export PATH="$SOME_TEMP_DIR:$PATH"
51+
fi
52+
53+
SCRIPTS_DIR=$(dirname $(realpath "$BASH_SOURCE"))
54+
REPO_DIR=$(realpath "$SCRIPTS_DIR/..")
55+
ENV_DIR="$REPO_DIR/.env"
56+
PKG_NAME=${PKG_NAME:-$(basename $REPO_DIR)}
57+
58+
mkdir -p $ENV_DIR
59+
60+
cat <<EOF>$ENV_DIR/setup.sh
61+
if [ ! -d .env/ ]; then
62+
>&2 echo "No .env directory?"
63+
exit 1
64+
fi
65+
if [ ! -d .env/venv ]; then
66+
python3 -m venv .env/venv
67+
fi
68+
source .env/venv/bin/activate
69+
if ! python -c "import pycvodes" 2>&1 >/dev/null; then
70+
python -m pip install --upgrade-strategy=eager --upgrade pip && \
71+
python -m pip install --upgrade-strategy=eager numpy 'cython>=3.0.10' setuptools && \
72+
env \
73+
PYCVODES_NO_LAPACK=1 \
74+
PYCVODES_NO_KLU=1 \
75+
LDFLAGS='-Wl,--disable-new-dtags -Wl,-rpath,/usr/local/lib -L/usr/local/lib' \
76+
python -m pip install --cache-dir .env/pypi-cache -e .[all]
77+
fi
78+
if ! python -c "import pyodesys" 2>&1 >/dev/null; then
79+
python -m pip install --cache-dir .env/pypi-cache -e .[all]
80+
#jupyter-nbextension enable --user --py widgetsnbextension
81+
fi
82+
export MPLBACKEND=Agg
83+
EOF
84+
85+
cat <<EOF>$ENV_DIR/run-tests.sh
86+
#!/bin/bash
87+
set -e
88+
source .env/setup.sh
89+
pytest -sv -ra --pyargs $PKG_NAME
90+
EOF
91+
92+
cat <<EOF>$ENV_DIR/host-notebook.sh
93+
#!/bin/bash
94+
set -e
95+
source .env/setup.sh
96+
jupyter notebook --no-browser --port $PORT --ip=* index.ipynb
97+
EOF
98+
99+
100+
if [ $RUN_TESTS = 1 ]; then
101+
podrun --cont-img-dir $SCRIPTS_DIR/environment \
102+
--name "${PKG_NAME}_run_tests" \
103+
-- bash $ENV_DIR/run-tests.sh
104+
fi
105+
if [ $HOST_NOTEBOOK = 1 ]; then
106+
podrun --cont-img-dir $SCRIPTS_DIR/environment \
107+
--name "${PKG_NAME}_host_notebook_${PORT}" \
108+
-p $LISTEN:$PORT:$PORT \
109+
-- bash $ENV_DIR/host-notebook.sh
110+
fi

scripts/host-jupyter-using-docker.sh

Lines changed: 0 additions & 69 deletions
This file was deleted.

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def _path_under_setup(*args):
100100
_author, _author_email = open(_path_under_setup("AUTHORS"), "rt").readline().split("<")
101101

102102
extras_req = {
103-
"integrators": ["pyodeint>=0.10.4", "pycvodes>=0.14.0", "pygslodeiv2>=0.9.4"],
103+
"integrators": ["pyodeint>=0.10.4", "pycvodes>=0.14.5", "pygslodeiv2>=0.9.4"],
104104
"solvers": ["pykinsol>=0.1.6"],
105105
"native": ["pycompilation>=0.4.12", "pycodeexport>=0.1.3", "appdirs"],
106106
"docs": ["Sphinx", "sphinx_rtd_theme", "numpydoc"],
@@ -128,7 +128,7 @@ def _path_under_setup(*args):
128128
"sympy>=1.1.1,!=1.2",
129129
"quantities>=0.12.1",
130130
"pyneqsys>=0.5.5",
131-
"pyodesys>=0.14.1" if sys.version_info[0] >= 3 else "pyodesys<0.12",
131+
"pyodesys>=0.14.4" if sys.version_info[0] >= 3 else "pyodesys<0.12",
132132
"pyparsing>=2.0.3",
133133
"sym>=0.3.4",
134134
"pulp>=1.6.8",

0 commit comments

Comments
 (0)