Skip to content

Commit

Permalink
chore: Update requirements.lock to use uv pip compile (#86)
Browse files Browse the repository at this point in the history
* Use 'uv pip compile' to build book/requirements.lock.
* Update base image to python:3.12-slim-bookworm.
* Update nox to use 'uv pip compile'.
* Use 'uv pip install' for pyodide in CI.
* Update Jupyter Book deployment status to show deployment status.
matthewfeickert authored Jan 7, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 3247788 commit d5a293e
Showing 5 changed files with 1,717 additions and 1,375 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/deploy-jupyter-book.yml
Original file line number Diff line number Diff line change
@@ -54,17 +54,21 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v5
with:
version: "latest"

- name: Install pyodide
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade \
uv pip install --system --upgrade \
"jupyterlite[lab]" \
"jupytext>=1.14.0"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
[![JupyterLite](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://pyhf.github.io/pyhf-tutorial/live/lab/index.html?path=jupyterlite.ipynb)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4670321.svg)](https://doi.org/10.5281/zenodo.4670321)

[![Deploy Jupyter Book](https://github.com/pyhf/pyhf-tutorial/workflows/Deploy%20Jupyter%20Book/badge.svg?branch=main)](https://pyhf.github.io/pyhf-tutorial/)
[![Deploy Jupyter Book](https://github.com/pyhf/pyhf-tutorial/actions/workflows/deploy-jupyter-book.yml/badge.svg)](https://pyhf.github.io/pyhf-tutorial/)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/pyhf/pyhf-tutorial/main.svg)](https://results.pre-commit.ci/latest/github/pyhf/pyhf-tutorial/main)

## Setup
3,052 changes: 1,697 additions & 1,355 deletions book/requirements.lock

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions lock.sh
Original file line number Diff line number Diff line change
@@ -6,8 +6,7 @@ if [[ "$(uname -m)" != "x86_64" ]]; then
docker run --privileged --rm tonistiigi/binfmt --install amd64
fi

# Match CPython version with Docker image that contians ROOT
BUILD_IMAGE="python:3.10-slim-bookworm"
BUILD_IMAGE="python:3.12-slim-bookworm"
docker pull \
--platform linux/amd64 \
"${BUILD_IMAGE}"
@@ -21,14 +20,12 @@ docker run \
"${BUILD_IMAGE}" \
/bin/bash -c "\
python -m venv venv && . venv/bin/activate \
&& python -m pip install --upgrade pip wheel \
&& python -m pip install pip-tools \
&& python -m pip --no-cache-dir install --upgrade uv \
&& cat /read/binder/requirements.txt /read/book/requirements.txt > requirements.txt \
&& mkdir -p book \
&& pip-compile \
--resolver=backtracking \
&& uv pip compile \
--generate-hashes \
--output-file book/requirements.lock \
--output-file=book/requirements.lock \
requirements.txt \
&& cp book/requirements.lock /write \
"
15 changes: 7 additions & 8 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -13,14 +13,13 @@
@nox.session(reuse_venv=True)
def lock(session: nox.Session) -> None:
"""
Build a lock file with pip-tools
Build a lock file with uv pip compile
Examples:
$ nox --session lock
"""
session.install("--upgrade", "pip", "setuptools", "wheel")
session.install("--upgrade", "pip-tools")
session.install("--upgrade", "uv")
out = session.run(
"cat",
f"{DIR / 'binder' / 'requirements.txt'}",
@@ -33,11 +32,11 @@ def lock(session: nox.Session) -> None:
out_file.write(out.strip() + "\n")

session.run(
"pip-compile",
"--resolver=backtracking",
"uv",
"pip",
"compile",
"--generate-hashes",
"--output-file",
"book/requirements.lock",
"--output-file=book/requirements.lock",
intermediate_requirements.name,
)
if intermediate_requirements.exists():
@@ -47,7 +46,7 @@ def lock(session: nox.Session) -> None:
@nox.session(venv_backend="none")
def docker(session: nox.Session) -> None:
"""
Build a lock file with pip-tools using Docker
Build a lock file with uv pip compile using Docker
Examples:

0 comments on commit d5a293e

Please sign in to comment.