Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 101 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ jobs:
mercantile
xyzservices

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.5.20"
enable-cache: true
python-version: "cpython-${{ matrix.python-version }}-linux-x86_64-gnu"

- name: Setup pip cache
uses: actions/cache@v4
with:
Expand Down Expand Up @@ -58,8 +65,8 @@ jobs:
set -eux
yarn install
yarn dev
jupyter labextension list 2>&1 | grep -ie "jupytergis-core.*OK"
jupyter labextension list 2>&1 | grep -ie "jupytergis-lab.*OK"
uv run jupyter labextension list 2>&1 | grep -ie "jupytergis-core.*OK"
uv run jupyter labextension list 2>&1 | grep -ie "jupytergis-lab.*OK"

- name: Package the extension
shell: bash -l {0}
Expand All @@ -82,7 +89,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.12']
python-version: [ '3.10', '3.12' ]

steps:
- name: Install Conda environment with Micromamba
Expand All @@ -98,21 +105,43 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.5.20"
enable-cache: true
python-version: "cpython-${{ matrix.python-version }}-linux-x86_64-gnu"

- name: Lock and Sync
shell: bash -l {0}
run: python scripts/dev-install.py
run: |
set -eux
uv lock
uv sync --all-groups

- name: Sync test dependencies
shell: bash -l {0}
run: |
set -eux
uv sync --group test

- name: Install test packages
- name: Install
shell: bash -l {0}
run: pip install pytest dirty-equals
run: |
set -eux
uv run python scripts/dev-install.py

- name: Run tests
shell: bash -l {0}
run: pytest --color=yes -v python/jupytergis_qgis/jupytergis_qgis/tests
run: |
set -eux
uv run pytest --color=yes -v python/jupytergis_qgis/jupytergis_qgis/tests

- name: Run Python API tests
shell: bash -l {0}
run: pytest --color=yes -v python/jupytergis_lab/
run: |
set -eux
uv run pytest --color=yes -v python/jupytergis_lab/

test_isolated:
needs: build
Expand All @@ -123,6 +152,20 @@ jobs:
with:
name: extension-artifacts-3.12

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.5.20"
enable-cache: true
python-version: "cpython-3.12.8-linux-x86_64-gnu"

- name: Lock and Sync
shell: bash -l {0}
run: |
set -eux
uv lock
uv sync --all-groups

- name: Install and Test
shell: bash -l {0}
run: |
Expand All @@ -132,10 +175,10 @@ jobs:
sudo rm -rf $(which node)

cp ./jupytergis_core/dist/jupytergis*.whl ./jupytergis_lab/dist/jupytergis*.whl ./jupytergis_qgis/dist/jupytergis*.whl .
python -m pip install jupytergis*.whl
uv run python -m pip install jupytergis*.whl

jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "jupytergis.*OK"
uv run jupyter labextension list
uv run jupyter labextension list 2>&1 | grep -ie "jupytergis.*OK"
# jupyterlab.browser_check will fail due to the core extension jupyterlab_pygments.
# It does not support lab v4.0.0
#python -m jupyterlab.browser_check --no-chrome-test
Expand Down Expand Up @@ -163,24 +206,40 @@ jobs:
ipywidgets
qgis

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.5.20"
enable-cache: true
python-version: "cpython-3.12-linux-x86_64-gnu"

- name: Download extension package
uses: actions/download-artifact@v4
with:
name: extension-artifacts-3.12

- name: Lock and Sync
shell: bash -l {0}
run: |
set -eux
uv lock
uv sync --all-groups

- name: Install the extension
shell: bash -l {0}
run: |
set -eux
cp ./jupytergis_core/dist/jupytergis*.whl ./jupytergis_lab/dist/jupytergis*.whl ./jupytergis_qgis/dist/jupytergis*.whl .
python -m pip install jupytergis*.whl "jupyter-collaboration>=3,<4"
uv run python -m pip install jupytergis*.whl "jupyter-collaboration>=3,<4"

- name: Install dependencies
shell: bash -l {0}
working-directory: ui-tests
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: jlpm install
run: |
set -eux
uv run jlpm install

- name: Set up browser cache
uses: actions/cache@v4
Expand Down Expand Up @@ -233,12 +292,20 @@ jobs:
jupyterlab=4
yarn=3

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.5.20"
enable-cache: true
python-version: "cpython-3.12.8-linux-x86_64-gnu"

- name: Lint
shell: bash -l {0}
run: |
jlpm install
jlpm run eslint:check
jlpm run prettier:check
set -eux
uv run jlpm install
uv run jlpm run eslint:check
uv run jlpm run prettier:check

check_links:
name: Check Links
Expand Down Expand Up @@ -281,12 +348,27 @@ jobs:
with:
name: extension-artifacts-3.12

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.5.20"
enable-cache: true
python-version: "cpython-3.10.16-linux-x86_64-gnu"

- name: Lock and Sync
shell: bash -l {0}
run: |
set -eux
uv lock
uv sync --all-groups

- name: Install the extension
shell: bash -l {0}
run: |
set -eux
cp ./jupytergis_core/dist/jupytergis*.whl ./jupytergis_lab/dist/jupytergis*.whl ./jupytergis_qgis/dist/jupytergis*.whl .
python -m pip install jupytergis*.whl
uv run python -m pip install jupytergis_core/dist/jupytergis*.whl
uv run python -m pip install jupytergis_lab/dist/jupytergis*.whl
uv run python -m pip install jupytergis_qgis/dist/jupytergis*.whl

- name: Build the docs site
shell: bash -l {0}
Expand Down
43 changes: 18 additions & 25 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,41 @@ build:
python: "3.12"
nodejs: "20"
jobs:
# Install micromamba
# Install uv
pre_create_environment:
# The recommended syntax in the micromamba docs is process substitution.
# RTD's default shell chokes on it, so we're doing it in multiple steps
# instead.
- curl -L micro.mamba.pm/install.sh > /tmp/micromamba-install.sh
- chmod +x /tmp/micromamba-install.sh
# For some reason, SHELL is not set. The install script requires it.
- SHELL=/bin/bash /bin/bash /tmp/micromamba-install.sh
- curl -LsSf https://astral.sh/uv/install.sh | sh
- export PATH="$HOME/.local/bin:$PATH"
- /bin/bash --login -c "uv --version"

# Override the create_environment step (undocumented feature) to create
# multiple environments.
# Create and lock environments using uv
create_environment:
# Create the env for building the docs
- /bin/bash --login -c "micromamba env create -n jupytergis-docs -f docs/environment-docs.yml"
# Create the isolated env for building JupyterGIS
- /bin/bash --login -c "micromamba create -n jupytergis-build -c conda-forge yarn=3 hatch pip python=3.12"
- /bin/bash --login -c "micromamba run -n jupytergis-build pip install -r requirements-build.txt"
# Sync the environment for building the docs
- /bin/bash --login -c "uv python install 3.12"
- /bin/bash --login -c "uv sync --group docs"
# Sync the build environment for JupyterGIS
- /bin/bash --login -c "uv sync --group build"

# Override the install step to do nothing - we already created the envs
# Override the install step to do nothing - environments are already created
install:
- "echo 'Skipping! We already have the environments we need.'"

# Before building the docs, build JupyterGIS in its isolated environment,
# then install the wheels into the docs environment.
pre_build:
- /bin/bash --login -c "micromamba run -n jupytergis-build yarn install"
- /bin/bash --login -c "micromamba run -n jupytergis-build yarn dev"
- /bin/bash --login -c "micromamba run -n jupytergis-build jupyter labextension list 2>&1 | grep -ie 'jupytergis-core.*OK'"
- /bin/bash --login -c "micromamba run -n jupytergis-build jupyter labextension list 2>&1 | grep -ie 'jupytergis-lab.*OK'"
- /bin/bash --login -c "micromamba run -n jupytergis-build yarn build:packages"
- /bin/bash --login -c "uv run jupytergis-build jlpm install"
- /bin/bash --login -c "uv run jupytergis-build jlpm run dev"
- /bin/bash --login -c "uv run jupytergis-build jupyter labextension list 2>&1 | grep -ie 'jupytergis-core.*OK'"
- /bin/bash --login -c "uv run jupytergis-build jupyter labextension list 2>&1 | grep -ie 'jupytergis-lab.*OK'"
- /bin/bash --login -c "uv run jupytergis-build jlpm run build:packages"

- |-
/bin/bash --login -c "micromamba run -n jupytergis-docs \
python -m pip install \
/bin/bash --login -c "uv run jupytergis-docs python -m pip install \
$(ls ./python/jupytergis_core/dist/jupytergis*.whl) \
$(ls ./python/jupytergis_lab/dist/jupytergis*.whl) \
$(ls ./python/jupytergis_qgis/dist/jupytergis*.whl)"

build:
html:
- |-
/bin/bash --login -c "cd docs && micromamba run -n jupytergis-docs \
python -m sphinx -T -b html -d _build/doctrees -D language=en . \
/bin/bash --login -c "uv run jupytergis-docs python -m sphinx -T -b html -d docs/_build/doctrees -D language=en docs \
$READTHEDOCS_OUTPUT/html"
45 changes: 34 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
## Contributing

### Development install
### Development Install

**Note:** You will need [Node.js](https://nodejs.org/) to build the extension package.
**Note:** You will need [Node.js](https://nodejs.org/) to build the extension package and ensure
`UV` is installed on your the instructions at system. You can install `UV` by following
[UV Installation Guide](https://docs.astral.sh/uv/configuration/installer/).

The `jlpm` command is JupyterLab's pinned version of
[yarn](https://yarnpkg.com/) that is installed with JupyterLab. You may use
Expand All @@ -11,43 +13,64 @@ The `jlpm` command is JupyterLab's pinned version of
```bash
# Clone the repo to your local environment
git clone https://github.com/geojupyter/jupytergis.git

# Change directory to the jupytergis directory
cd jupytergis
# Install package in development mode
python scripts/dev-install.py

# Install the package in development mode using UV
uv run python scripts/dev-install.py
```

The above will:

1. Create a virtual environment.
2. Install all dependencies.
3. Build and install the JupyterLab extensions.

### Notes on Using UV

**Important Note:** With `UV`, you do not need to manually activate the virtual environment or
handle dependency management. Simply ensure `UV` is installed on your system by following the instructions at
[UV Installation Guide](https://docs.astral.sh/uv/configuration/installer/).

All commands can be prefixed with `uv run`, and `UV` will handle activating the virtual environment for you. If
you would like to activate the virtual environment manually, you can run `source .venv/bin/activate` on Unix-based
systems or `source .venv/Scripts/activate` on Windows. Then, you will be able to run commands without the `uv run`
prefix.

### Watching Source Files and Running JupyterLab

You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.

```bash
# Watch the source directory in one terminal, automatically rebuilding when needed
jlpm run watch
uv run jlpm run watch

# Alternatively, you can run the following after each TypeScript code change
jlpm run build:dev
uv run jlpm run build:dev

# Run JupyterLab in another terminal
jupyter lab
uv run jupyter lab
```

With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).

By default, the `jlpm run build` command generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command:

```bash
jupyter lab build --minimize=False
uv run jupyter lab build --minimize=False
```

### Development uninstall
### Development Uninstall

```bash
pip uninstall jupytergis
uv run pip uninstall jupytergis
```

In development mode, you will also need to remove the symlink created by `jupyter labextension develop`
command. To find its location, you can run `jupyter labextension list` to figure out where the `labextensions`
folder is located. Then you can remove the symlink named `jupytergis` within that folder.

### Packaging the extension
### Packaging the Extension

See [RELEASE](RELEASE.md)
Loading
Loading