Skip to content

Commit

Permalink
DX: define developer environment with uv (#23)
Browse files Browse the repository at this point in the history
* DX: pin all notebook dependencies
* DX: switch to Python 3.10 in developer environment

---------

Co-authored-by: GitHub <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 24, 2024
1 parent a6cdc36 commit 10900e8
Show file tree
Hide file tree
Showing 128 changed files with 26,845 additions and 1,840 deletions.
20 changes: 20 additions & 0 deletions .binder/postBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -ex
curl -LsSf https://pixi.sh/install.sh | bash
export PATH="$HOME/.pixi/bin:$PATH"

pixi_packages="$(NO_COLOR= pixi list --explicit --no-install | awk 'NR > 1 {print $1}')"
if [[ -n "$pixi_packages" ]]; then
pixi global install $pixi_packages
fi
export PYTHONHASHSEED="0"
pixi clean cache --yes

uv export \
--extra jupyter \
--extra notebooks \
> requirements.txt
uv pip install \
--requirement requirements.txt \
--system
uv cache clean
1 change: 1 addition & 0 deletions .binder/runtime.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python-3.12
7 changes: 5 additions & 2 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
".readthedocs.yml",
".vscode/*",
"docs/conf.py",
"pyproject.toml",
"tox.ini"
"pyproject.toml"
],
"language": "en-US",
"overrides": [
Expand Down Expand Up @@ -89,6 +88,7 @@
"Mikhasenko",
"NumPy",
"parametrizations",
"Pixi",
"plotly",
"pyplot",
"QRules",
Expand Down Expand Up @@ -172,6 +172,7 @@
"iframe",
"imag",
"infty",
"installkernel",
"ioff",
"iplt",
"ipykernel",
Expand Down Expand Up @@ -242,6 +243,7 @@
"pycode",
"pyfunc",
"pygments",
"pyproject",
"pytest",
"quadpy",
"rankdir",
Expand Down Expand Up @@ -283,6 +285,7 @@
"unbinned",
"unnormalized",
"unsrt",
"venv",
"viridis",
"vmax",
"vmin",
Expand Down
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ indent_size = 4

[LICENSE]
indent_size = unset

[uv.lock]
indent_size = 4
14 changes: 4 additions & 10 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
if [ -e .venv ]; then
source .venv/bin/activate
elif [ -e venv ]; then
source venv/bin/activate
elif [ -e .pixi ]; then
watch_file pixi.lock
eval "$(pixi shell-hook)"
else
layout anaconda
fi
watch_file pixi.lock
eval "$(pixi shell-hook)"
uv sync --all-extras --quiet
source .venv/bin/activate
39 changes: 0 additions & 39 deletions .github/release-drafter.yml

This file was deleted.

16 changes: 0 additions & 16 deletions .github/workflows/cd.yml

This file was deleted.

8 changes: 2 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,15 @@ on:

jobs:
doc:
uses: ComPWA/actions/.github/workflows/ci-docs.yml@v1
uses: ComPWA/actions/.github/workflows/ci-docs.yml@v2
permissions:
pages: write
id-token: write
with:
apt-packages: graphviz
gh-pages: true
python-version: "3.12"
specific-pip-packages: ${{ inputs.specific-pip-packages }}
style:
if: inputs.specific-pip-packages == ''
secrets:
token: ${{ secrets.PAT }}
uses: ComPWA/actions/.github/workflows/pre-commit.yml@v1
with:
python-version: "3.12"
uses: ComPWA/actions/.github/workflows/pre-commit.yml@v2
4 changes: 2 additions & 2 deletions .github/workflows/clean-caches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ on:
jobs:
cleanup:
name: Remove caches
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: ComPWA/actions/clean-caches@v1
- uses: ComPWA/actions/clean-caches@v2
with:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ inputs.ref }}
24 changes: 24 additions & 0 deletions .github/workflows/lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Update

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: |-
${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }}
on:
pull_request:
branches:
- main
- epic/*
paths:
- .pre-commit-config.yaml
- Manifest.toml
- pixi.lock
- uv.lock
workflow_dispatch:

jobs:
lock:
uses: ComPWA/actions/.github/workflows/lock.yml@v2
secrets:
token: ${{ secrets.PAT }}
36 changes: 9 additions & 27 deletions .github/workflows/notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,16 @@ on:
jobs:
pytest:
name: Test all notebooks
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
key: |
${{ github.workflow }}-${{ github.job }}-${{ runner.os }}-${{ hashFiles('.constraints/py3.*.txt', 'setup.cfg') }}
path: |
.pytest_cache
~/.cache/pip/
- uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install dependencies
run: |
sudo apt-get -y install graphviz
pip install .[test]
- run: |
function run-nbmake() {
set +e
pytest --nbmake ${{ github.event.inputs.notebook-selector }}
error_code=$?
set -e
echo "Pytest returned error code $error_code"
case $error_code in
0|5) return 0;;
*) return $error_code;;
esac
}
run-nbmake
# cspell:ignore esac
python-version: "3.12"
- uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: Install graphviz
run: sudo apt-get -y install graphviz
- name: Run all notebooks
run: uv run --extra test pytest ${{ github.event.inputs.notebook-selector }}
2 changes: 1 addition & 1 deletion .github/workflows/pr-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ on:

jobs:
lint-pr:
uses: ComPWA/actions/.github/workflows/pr-linting.yml@v1
uses: ComPWA/actions/.github/workflows/pr-linting.yml@v2
16 changes: 0 additions & 16 deletions .github/workflows/release-drafter.yml

This file was deleted.

3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ version.py

# Temporary files
*.pyc
*condaenv.*
.coverage
.coverage.*
.ipynb_checkpoints/
Expand All @@ -38,7 +37,6 @@ prof/
.pixi/
.tox/
*venv/
pixi.lock
pyvenv*/

# Settings
Expand All @@ -53,6 +51,5 @@ pyvenv*/
!.readthedocs.yml
!.vscode/*.json
!codecov.yml
!environment.yml
!pyrightconfig.json
.jupyter_ystore.db
Loading

0 comments on commit 10900e8

Please sign in to comment.