From c9ced7a1f0c8a78d5b5ac23a8dd440e865cb383d Mon Sep 17 00:00:00 2001 From: jorgensd Date: Mon, 19 Sep 2022 12:00:15 +0200 Subject: [PATCH 1/3] Minor configs to get binder to work --- README.md | 3 +-- docs/_config.yml | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1ef19be..8acdb02 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,7 @@ This repository is a template for how to set up a reproducible python environmen ## Python-packaging -To be able to create a python package, we need a folder with the name of the package (in this repository `mypackage`), and a `pyproject.toml` file. - +To be able to create a python package, we need a folder with the name of the package (in this repository it is called `mypackage`, located under `src/mypackage`), and a `pyproject.toml` file. ## Make a repository citable diff --git a/docs/_config.yml b/docs/_config.yml index 4bc9884..98f49fe 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -15,8 +15,8 @@ execute: # Information about where the book exists on the web repository: url: https://github.com/jorgensd/reproducibility # Online location of your book - path_to_book: docs # Optional path to your book, relative to the repository root - branch: main # Which branch of the repository should be used when creating links (optional) + path_to_book: _sources # Optional path to your book, relative to the repository root + branch: gh-pages # Which branch of the repository should be used when creating links (optional) sphinx: From dddbb7fe07ad13d77f7eb482c8cf3fbf75640352 Mon Sep 17 00:00:00 2001 From: jorgensd Date: Mon, 19 Sep 2022 14:30:15 +0200 Subject: [PATCH 2/3] Minor updates --- Dockerfile | 11 +++++++++-- docs/_config.yml | 25 ++++++++++--------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 96ed47e..4ee619c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,13 +2,20 @@ FROM ubuntu:22.04 + RUN apt-get update && \ - apt-get install -y python3-pip + apt-get install -y python3-pip git # Use modern setuptools from pip instead of apt RUN pip3 install pip setuptools --upgrade -RUN apt-get purge python3-setuptools +RUN apt-get purge -y python3-setuptools + +WORKDIR /tmp/ +RUN git clone https://github.com/jorgensd/reproducibility && \ + pip3 install ./reproducibility + +RUN rm -rf /tmp # Create user with a home directory ARG NB_USER diff --git a/docs/_config.yml b/docs/_config.yml index 98f49fe..15df70a 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -18,30 +18,25 @@ repository: path_to_book: _sources # Optional path to your book, relative to the repository root branch: gh-pages # Which branch of the repository should be used when creating links (optional) - -sphinx: - extra_extensions: - - 'sphinx.ext.autodoc' - - 'sphinx.ext.napoleon' - - 'sphinx.ext.viewcode' - - launch_buttons: notebook_interface: "jupyterlab" # The interface interactive links will activate ["classic", "jupyterlab"] binderhub_url: "https://mybinder.org" - colab_url: "https://colab.research.google.com" - - -# Add GitHub buttons to your book -# See https://jupyterbook.org/customize/config.html#add-a-link-to-your-repository html: use_issues_button: true use_repository_button: true - parse: myst_enable_extensions: - amsmath - dollarmath - - linkify \ No newline at end of file + - linkify + +sphinx: + extra_extensions: + - 'sphinx.ext.autodoc' + - 'sphinx.ext.napoleon' + - 'sphinx.ext.viewcode' + + + From bc51db54f8c9598fd975e44c5f5f9a24debeb2e1 Mon Sep 17 00:00:00 2001 From: jorgensd Date: Mon, 19 Sep 2022 16:31:30 +0200 Subject: [PATCH 3/3] Finally get binder to "work" --- Dockerfile | 4 +++- Makefile | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4ee619c..ef189c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,9 +11,11 @@ RUN pip3 install pip setuptools --upgrade RUN apt-get purge -y python3-setuptools + +# Install mypackage WORKDIR /tmp/ RUN git clone https://github.com/jorgensd/reproducibility && \ - pip3 install ./reproducibility + pip3 install ./reproducibility[docs] RUN rm -rf /tmp diff --git a/Makefile b/Makefile index 75906e5..5e9f700 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,9 @@ doc: # Generate Sphinx HTML documentation, including API docs @for file in ${DOCS}; do \ cp $$file docs/. ;\ done +# We use --set-kernel with jupytext to make it possible for binder to pick it up @for demo in ${DEMOS}; do \ - jupytext --to=ipynb demo/$$demo.py --output=docs/$$demo.ipynb ;\ + jupytext --to=ipynb --set-kernel=python3 demo/$$demo.py --output=docs/$$demo.ipynb ;\ jupyter book build -W docs ;\ done