Skip to content

Commit

Permalink
new script
Browse files Browse the repository at this point in the history
  • Loading branch information
bjodah committed Apr 24, 2024
1 parent f4142c7 commit bd75496
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 78 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Expand Up @@ -26,10 +26,7 @@ build/
*.bak0
*.bak1
sundials-*.tar.gz
.local/
.ipython/
.jupyter/*
!.jupyter/jupyter_notebook_config.py
.env/
tmp/
.coverage
htmlcov/
4 changes: 2 additions & 2 deletions README.rst
Expand Up @@ -107,13 +107,13 @@ Using Docker
If you have `Docker <https://www.docker.com>`_ installed, you may use it to host a jupyter
notebook server::

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

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

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

there will be a few skipped test (due to some dependencies not being installed by default) and
quite a few warnings.
Expand Down
File renamed without changes.
106 changes: 106 additions & 0 deletions scripts/host-env.sh
@@ -0,0 +1,106 @@
#!/bin/bash
show_help() {
echo "Usage:"
echo "$(basename $0) host-notebook --port 8888 --listen 127.0.0.1"
echo "$(basename $0) run-tests"
}
HOST_NOTEBOOK=0
RUN_TESTS=0
PORT=8000
while [ $# -gt 0]; do
case "$1" in
host-notebook)
HOST_NOTEBOOK=1
shift
;;
--port)
shift
PORT=$1
shift
;;
--listen)
shift
LISTEN=$1
shift
;;
run-tests)
RUN_TESTS=1
shift
;;
--help|-h)
show_help
exit 0
;;
--)
break;
*)
show_help
exit 1
;;
esac
done

set -euxo pipefail
if ! which pod-run >/dev/null; then
SOME_TEMP_DIR=$(mktemp -d)
trap 'rm -rf -- "$SOME_TEMP_DIR"' EXIT
( cd "$SOME_TEMP_DIR"; curl -LOs https://raw.githubusercontent.com/bjodah/dotfiles/master/per-leaf-dir/bin/podrun; chmod +x podrun )
export PATH="$SOME_TEMP_DIR:$PATH"
fi

SCRIPTS_DIR=$(dirname $(realpath "$BASH_SOURCE"))
REPO_DIR=$(realpath "$SCRIPTS_DIR/..")
ENV_DIR="$REPO_DIR/.env"
PKG_NAME=${PKG_NAME:-$(basename $REPO_DIR)}

mkdir -p $ENV_DIR

cat <<EOF>$ENV_DIR/setup.sh
if [ ! -d .env/ ]; then
>&2 echo "No .env directory?"
exit 1
fi
if [ ! -d .env/venv ]; then
python3 -m venv .env/venv
fi
source .env/venv/activate
if ! python -c "import pycvodes" 2>&1 >/dev/null; then
env \
PYCVODES_NO_LAPACK=1 \
PYCVODES_NO_KLU=1 \
LDFLAGS='-Wl,--disable-new-dtags -Wl,-rpath,/usr/local/lib -L/usr/local/lib' \
python -m pip install --cache-dir .env/pypi-cache -e .[all]
fi
if ! python -c "import pyodesys" 2>&1 >/dev/null; then
pip install --cache-dir .env/pypi-cache -e .[all]
jupyter-nbextension enable --user --py widgetsnbextension
fi
export MPLBACKEND=Agg
EOF
cat <<EOF>$ENV_DIR/run-tests.sh
source .env/setup.sh
pytest -sv -ra --pyargs $PKG_NAME
EOF
cat <<EOF>$ENV_DIR/host-notebook.sh
source .env/setup.sh
jupyter notebook --no-browser --port $PORT --ip=* index.ipynb
EOF
if [ $RUN_TESTS = 1 ]; then
podrun --cont-img-dir $SCRIPTS_DIR/environment \
--name "${PKG_NAME}_run_tests" \
--image $DOCKERIMAGE \
-- $ENV_DIR/run-tests.sh
fi
if [ $HOST_NOTEBOOK = 1 ]; then
podrun --cont-img-dir $SCRIPTS_DIR/environment \
--name "${PKG_NAME}_host_notebook_${PORT}" \
--image $DOCKERIMAGE \
-p $LISTEN:$PORT:$PORT \
-- $ENV_DIR/host-notebook.sh
fi
71 changes: 0 additions & 71 deletions scripts/host-jupyter-using-docker.sh

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -100,7 +100,7 @@ def _path_under_setup(*args):
_author, _author_email = open(_path_under_setup("AUTHORS"), "rt").readline().split("<")

extras_req = {
"integrators": ["pyodeint>=0.10.4", "pycvodes>=0.14.0", "pygslodeiv2>=0.9.4"],
"integrators": ["pyodeint>=0.10.4", "pycvodes>=0.14.5", "pygslodeiv2>=0.9.4"],
"solvers": ["pykinsol>=0.1.6"],
"native": ["pycompilation>=0.4.12", "pycodeexport>=0.1.3", "appdirs"],
"docs": ["Sphinx", "sphinx_rtd_theme", "numpydoc"],
Expand Down

0 comments on commit bd75496

Please sign in to comment.