Skip to content

Commit 94a262e

Browse files
committed
Use Micromamba instead of one of the out-of-the-box tool options
Creating multiple environments with mamba exposed lots of problems: * RTD's default machinery expects a single environment YAML file when using conda/mamba. Injecting a 2nd environment into the normal build process gets confusing. * Other hidden assumptions in the default RTD build machinery; I don't remember all the problems I ran in to, but getting a working build required an unsustainable amount of trial-and-error. * Default-installed mamba is too old to support 'emscripten' platform, needs to be upgraded. When upgrading mamba, ran in to a weird issue where the build.html step could not find the python interpreter. It's possible to fully override build steps, but this is an _undocumented feature_. See: readthedocs/readthedocs.org#11551 Instead of overriding build steps, perhaps it will be best long-term to override the entire build with `build.commands`. See: https://blog.readthedocs.com/build-customization/
1 parent 5953801 commit 94a262e

File tree

1 file changed

+36
-26
lines changed

1 file changed

+36
-26
lines changed

.readthedocs.yaml

+36-26
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,50 @@ version: 2
44
build:
55
os: "ubuntu-24.04"
66
tools:
7-
# https://docs.readthedocs.io/en/stable/config-file/v2.html#build-tools-python
8-
python: "mambaforge-latest"
97
nodejs: "20"
108
jobs:
11-
# We need new versions to support the 'emscripten' platform
9+
# Install micromamba
1210
pre_create_environment:
13-
- conda install -n base -c conda-forge "conda>=24.11.2"
14-
# Before building the docs, build JupyterGIS in an isolated environment,
11+
# The recommended syntax in the micromamba docs is process substitution.
12+
# RTD's default shell chokes on it, so we're doing it in multiple steps
13+
# instead.
14+
- curl -L micro.mamba.pm/install.sh > /tmp/micromamba-install.sh
15+
- chmod +x /tmp/micromamba-install.sh
16+
# For some reason, SHELL is not set. The install script requires it.
17+
- SHELL=/bin/bash /bin/bash /tmp/micromamba-install.sh
18+
19+
# Override the create_environment step (undocumented feature) to create
20+
# multiple environments.
21+
create_environment:
22+
# Create the env for building the docs
23+
- /bin/bash --login -c "micromamba env create -n jupytergis-docs -f docs/environment-docs.yml"
24+
# Create the isolated env for building JupyterGIS
25+
- /bin/bash --login -c "micromamba create -n jupytergis-build -c conda-forge yarn=3 hatch pip python=3.10"
26+
- /bin/bash --login -c "micromamba run -n jupytergis-build pip install -r requirements-build.txt"
27+
28+
# Override the install step to do nothing - we already created the envs
29+
install:
30+
- "echo 'Skipping! We already have the environments we need.'"
31+
32+
# Before building the docs, build JupyterGIS in its isolated environment,
1533
# then install the wheels into the docs environment.
1634
pre_build:
17-
- mamba create -n jupytergis-build -c conda-forge yarn=3 hatch pip python=3.10
18-
- mamba run -n jupytergis-build pip install -r requirements-build.txt
19-
- mamba run -n jupytergis-build yarn install
20-
- mamba run -n jupytergis-build yarn dev
21-
- mamba run -n jupytergis-build jupyter labextension list 2>&1 | grep -ie "jupytergis-core.*OK"
22-
- mamba run -n jupytergis-build jupyter labextension list 2>&1 | grep -ie "jupytergis-lab.*OK"
35+
- /bin/bash --login -c "micromamba run -n jupytergis-build yarn install"
36+
- /bin/bash --login -c "micromamba run -n jupytergis-build yarn dev"
37+
- /bin/bash --login -c "micromamba run -n jupytergis-build jupyter labextension list 2>&1 | grep -ie 'jupytergis-core.*OK'"
38+
- /bin/bash --login -c "micromamba run -n jupytergis-build jupyter labextension list 2>&1 | grep -ie 'jupytergis-lab.*OK'"
39+
- /bin/bash --login -c "micromamba run -n jupytergis-build yarn build:packages"
2340

24-
- mamba run -n jupytergis-build yarn build:packages
25-
26-
# Install the wheels into the main docs environment, which is activated
27-
# automatically:
2841
- >-
42+
/bin/bash --login -c "micromamba run -n jupytergis-docs
2943
python -m pip install
3044
$(ls ./python/jupytergis_core/dist/jupytergis*.whl)
3145
$(ls ./python/jupytergis_lab/dist/jupytergis*.whl)
32-
$(ls ./python/jupytergis_qgis/dist/jupytergis*.whl)
33-
34-
35-
sphinx:
36-
configuration: "docs/conf.py"
37-
# There doesn't seem to be a way to turn on nitpicky mode.
38-
# This is equivalent to `-W --keep-going`.
39-
# TODO: Enable after merging https://github.com/geojupyter/jupytergis/pull/273/
40-
# fail_on_warning: True
46+
$(ls ./python/jupytergis_qgis/dist/jupytergis*.whl)"
4147
42-
conda:
43-
environment: "docs/environment-docs.yml"
48+
build:
49+
html:
50+
- >-
51+
/bin/bash --login -c "cd docs && micromamba run -n jupytergis-docs
52+
python -m sphinx -T -b html -d _build/doctrees -D language=en .
53+
$READTHEDOCS_OUTPUT/html"

0 commit comments

Comments
 (0)