Skip to content

Commit ac8b316

Browse files
authored
DX: define developer environment with uv (#301)
1 parent 8298ef0 commit ac8b316

33 files changed

+2849
-401
lines changed

.binder/apt.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
graphviz

.binder/postBuild

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -ex
3+
curl -LsSf https://astral.sh/uv/install.sh | sh
4+
source $HOME/.cargo/env
5+
uv export \
6+
--extra jupyter \
7+
--extra notebooks \
8+
> requirements.txt
9+
uv pip install \
10+
--requirement requirements.txt \
11+
--system
12+
uv cache clean

.binder/runtime.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python-3.12

.cspell.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"*.svg",
2828
".editorconfig",
2929
".envrc",
30-
".gitattributes",
3130
".gitignore",
3231
".pre-commit-config.yaml",
3332
".prettierignore",
@@ -36,8 +35,7 @@
3635
"CITATION.cff",
3736
"docs/adr/*/*",
3837
"docs/conf.py",
39-
"pyproject.toml",
40-
"tox.ini"
38+
"pyproject.toml"
4139
],
4240
"language": "en-US",
4341
"words": [

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ indent_size = 4
1515

1616
[LICENSE]
1717
indent_size = unset
18+
19+
[uv.lock]
20+
indent_size = 4

.envrc

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
1-
if [ -e .venv ]; then
2-
source .venv/bin/activate
3-
elif [ -e venv ]; then
4-
source venv/bin/activate
5-
elif [ -e .pixi ]; then
6-
watch_file pixi.lock
7-
eval "$(pixi shell-hook)"
8-
else
9-
layout anaconda
10-
fi
1+
uv sync --all-extras --quiet
2+
source .venv/bin/activate

.gitattributes

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/cd.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ on:
99
jobs:
1010
milestone:
1111
if: startsWith(github.ref, 'refs/tags')
12-
uses: ComPWA/actions/.github/workflows/close-milestone.yml@v1
12+
uses: ComPWA/actions/.github/workflows/close-milestone.yml@v2
1313
push:
1414
if: startsWith(github.ref, 'refs/tags') && !github.event.release.prerelease
1515
secrets: inherit
16-
uses: ComPWA/actions/.github/workflows/push-to-version-branches.yml@v1
16+
uses: ComPWA/actions/.github/workflows/push-to-version-branches.yml@v2

.github/workflows/ci.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,16 @@ on:
2828

2929
jobs:
3030
doc:
31-
uses: ComPWA/actions/.github/workflows/ci-docs.yml@v1
31+
uses: ComPWA/actions/.github/workflows/ci-docs.yml@v2
3232
permissions:
3333
pages: write
3434
id-token: write
3535
with:
3636
apt-packages: graphviz
3737
gh-pages: true
38-
python-version: "3.12"
3938
specific-pip-packages: ${{ inputs.specific-pip-packages }}
4039
style:
4140
if: inputs.specific-pip-packages == ''
4241
secrets:
4342
token: ${{ secrets.PAT }}
44-
uses: ComPWA/actions/.github/workflows/pre-commit.yml@v1
45-
with:
46-
python-version: "3.12"
43+
uses: ComPWA/actions/.github/workflows/pre-commit.yml@v2

.github/workflows/clean-caches.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ on:
1414
jobs:
1515
cleanup:
1616
name: Remove caches
17-
runs-on: ubuntu-22.04
17+
runs-on: ubuntu-24.04
1818
steps:
19-
- uses: ComPWA/actions/clean-caches@v1
19+
- uses: ComPWA/actions/clean-caches@v2
2020
with:
2121
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2222
ref: ${{ inputs.ref }}

.github/workflows/requirements.yml renamed to .github/workflows/lock.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Requirements
1+
name: Update
22

33
concurrency:
44
group: ${{ github.workflow }}-${{ github.ref }}
@@ -12,12 +12,11 @@ on:
1212
- epic/*
1313
paths:
1414
- .pre-commit-config.yaml
15-
schedule:
16-
- cron: "0 3 7 */2 *"
15+
- uv.lock
1716
workflow_dispatch:
1817

1918
jobs:
20-
requirements:
21-
uses: ComPWA/actions/.github/workflows/requirements.yml@v1
19+
lock:
20+
uses: ComPWA/actions/.github/workflows/lock.yml@v2
2221
secrets:
2322
token: ${{ secrets.PAT }}

.github/workflows/pr-linting.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ on:
1111

1212
jobs:
1313
lint-pr:
14-
uses: ComPWA/actions/.github/workflows/pr-linting.yml@v1
14+
uses: ComPWA/actions/.github/workflows/pr-linting.yml@v2

.github/workflows/release-drafter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
update_release_draft:
12-
runs-on: ubuntu-22.04
12+
runs-on: ubuntu-24.04
1313
steps:
1414
- uses: release-drafter/release-drafter@v6
1515
env:

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ version.py
2121

2222
# Temporary files
2323
*.pyc
24-
*condaenv.*
2524
.coverage
2625
.coverage.*
2726
.ipynb_checkpoints/
@@ -36,7 +35,6 @@ prof/
3635

3736
# Virtual environments
3837
*venv/
39-
.pixi/
4038
.tox/
4139
pyvenv*/
4240

@@ -53,6 +51,5 @@ pyvenv*/
5351
!.vscode/*.json
5452
!.zenodo.json
5553
!codecov.yml
56-
!environment.yml
5754
!pyrightconfig.json
5855
.jupyter_ystore.db

.pre-commit-config.yaml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
ci:
2-
autoupdate_commit_msg: "MAINT: autoupdate pre-commit hooks"
2+
autoupdate_commit_msg: "MAINT: update lock files"
33
autoupdate_schedule: quarterly
44
skip:
55
- check-jsonschema
66
- pyright
7+
- uv-lock
78

89
repos:
910
- repo: meta
@@ -12,14 +13,13 @@ repos:
1213
- id: check-useless-excludes
1314

1415
- repo: https://github.com/ComPWA/policy
15-
rev: 0.4.1
16+
rev: 0.5.0
1617
hooks:
1718
- id: check-dev-files
1819
args:
1920
- --doc-apt-packages=graphviz
2021
- --dev-python-version=3.12
2122
- --github-pages
22-
- --no-prettierrc
2323
- --no-pypi
2424
- --repo-name=compwa.github.io
2525
- --repo-title=ComPWA Organization
@@ -56,7 +56,7 @@ repos:
5656
metadata.vscode
5757
5858
- repo: https://github.com/astral-sh/ruff-pre-commit
59-
rev: v0.6.4
59+
rev: v0.7.0
6060
hooks:
6161
- id: ruff
6262
args: [--fix]
@@ -65,7 +65,7 @@ repos:
6565
types_or: [python, pyi, jupyter]
6666

6767
- repo: https://github.com/pre-commit/pre-commit-hooks
68-
rev: v4.6.0
68+
rev: v5.0.0
6969
hooks:
7070
- id: check-ast
7171
- id: check-case-conflict
@@ -106,7 +106,7 @@ repos:
106106
args: [--in-place]
107107

108108
- repo: https://github.com/python-jsonschema/check-jsonschema
109-
rev: 0.29.2
109+
rev: 0.29.4
110110
hooks:
111111
- id: check-jsonschema
112112
name: Check CITATION.cff
@@ -119,7 +119,7 @@ repos:
119119
pass_filenames: false
120120

121121
- repo: https://github.com/streetsidesoftware/cspell-cli
122-
rev: v8.13.3
122+
rev: v8.15.2
123123
hooks:
124124
- id: cspell
125125

@@ -144,7 +144,12 @@ repos:
144144
docs/_static/favicon.ico
145145
)$
146146
147-
- repo: https://github.com/ComPWA/mirrors-pyright
148-
rev: v1.1.379
147+
- repo: https://github.com/ComPWA/pyright-pre-commit
148+
rev: v1.1.385
149149
hooks:
150150
- id: pyright
151+
152+
- repo: https://github.com/astral-sh/uv-pre-commit
153+
rev: 0.4.25
154+
hooks:
155+
- id: uv-lock

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

.readthedocs.yml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
version: 2
22

3-
sphinx:
4-
builder: html
5-
configuration: docs/conf.py
6-
fail_on_warning: true
7-
8-
formats:
9-
- htmlzip
10-
113
build:
12-
os: ubuntu-22.04
13-
apt_packages:
14-
- graphviz
4+
os: ubuntu-24.04
155
tools:
166
python: "3.12"
17-
jobs:
18-
post_install:
19-
- python -m pip install 'uv>=0.2.0'
20-
- python -m uv pip install -e .[doc]
7+
commands:
8+
- |-
9+
export PIXI_HOME=$READTHEDOCS_VIRTUALENV_PATH
10+
curl -fsSL https://pixi.sh/install.sh | bash
11+
pixi global install graphviz uv
12+
- |-
13+
export UV_LINK_MODE=copy
14+
uv run --extra doc --locked --with tox \
15+
tox -e doc
16+
mkdir -p $READTHEDOCS_OUTPUT
17+
mv docs/_build/html $READTHEDOCS_OUTPUT

.vscode/settings.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
"\u03bd": true,
3131
"\u03c3": true
3232
},
33-
"files.associations": {
34-
"**/pixi.lock": "yaml"
35-
},
3633
"files.watcherExclude": {
3734
"**/*_cache/**": true,
3835
"**/.eggs/**": true,
@@ -63,6 +60,9 @@
6360
"ruff.enable": true,
6461
"ruff.importStrategy": "fromEnvironment",
6562
"ruff.organizeImports": true,
63+
"search.exclude": {
64+
"**/uv.lock": true
65+
},
6666
"telemetry.telemetryLevel": "off",
6767
"yaml.schemas": {
6868
"https://citation-file-format.github.io/1.2.0/schema.json": "CITATION.cff",

CONTRIBUTING.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# How to contribute?
22

3-
[![Open in Visual Studio Code](https://img.shields.io/badge/vscode-open-blue?logo=visualstudiocode)](https://open.vscode.dev/ComPWA/compwa.github.io)
3+
[![Open in Visual Studio Code](https://img.shields.io/badge/vscode-open-blue?logo=visualstudiocode)](https://github.dev/ComPWA/compwa.github.io)
44

5-
This repository is part of the [ComPWA Organization](https://github.com/ComPWA). For more information about how to contribute to the packages, go to **[compwa.github.io/develop](https://compwa.github.io/develop)**!
5+
> [!TIP]
6+
> This package is part of the [ComPWA Organization](https://github.com/ComPWA). For more information about how to contribute to the packages, go to **[compwa.github.io/develop](https://compwa.github.io/develop)**!
7+
8+
To contribute to the project, you need to install the package in a virtual environment. This can be done best with [`uv`](https://docs.astral.sh/uv) (see installation instructions [here](https://docs.astral.sh/uv/getting-started/installation)). For this, you first need to get the source code with [Git](https://git-scm.com):
9+
10+
```shell
11+
git clone https://github.com/ComPWA/compwa.github.io
12+
cd compwa.github.io
13+
```
14+
15+
Now it's simply a matter of creating and activating the [virtual environment](https://docs.astral.sh/uv/pip/environments) with [`uv sync`](https://docs.astral.sh/uv/reference/cli/#uv-sync). The dependencies for the project are 'pinned' in each commit through the [`uv.lock` file](https://docs.astral.sh/uv/concepts/projects/#project-lockfile).
16+
17+
```shell
18+
uv sync
19+
source .venv/bin/activate
20+
```
21+
22+
Formatting and linting checks are automatically performed when committing changes. This is done with [pre-commit](https://pre-commit.com). To install the hooks in your local repository, run [`pre-commit install`](https://pre-commit.com/#3-install-the-git-hook-scripts) **once**:
23+
24+
```shell
25+
pre-commit install --install-hooks
26+
```

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
[![Spelling checked](https://img.shields.io/badge/cspell-checked-brightgreen.svg)](https://github.com/streetsidesoftware/cspell/tree/master/packages/cspell)
1212
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
1313
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
14+
[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
1415

1516
This repository contains the source code for the [compwa.github.io](https://compwa.github.io) pages.

docs/adr/001/operators.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"outputs": [],
1919
"source": [
20-
"%pip install -q expertsystem==0.6.10 graphviz==0.16"
20+
"!uv pip install -q expertsystem==0.6.10 graphviz==0.16"
2121
]
2222
},
2323
{

docs/adr/001/sympy.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
"outputs": [],
3737
"source": [
38-
"%pip install -q jax==0.2.13 jaxlib==0.1.67 matplotlib==3.4.2 numpy==1.19.5 protobuf==3.20.* sympy==1.8 tensorflow==2.4.*"
38+
"!uv pip install -q jax==0.2.13 jaxlib==0.1.67 matplotlib==3.4.2 numpy==1.19.5 protobuf==3.20.* sympy==1.8 tensorflow==2.4.*"
3939
]
4040
},
4141
{

docs/adr/002/composition.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
"outputs": [],
3737
"source": [
38-
"%pip install -q matplotlib==3.4.2 sympy==1.8"
38+
"!uv pip install -q matplotlib==3.4.2 sympy==1.8"
3939
]
4040
},
4141
{
@@ -65,7 +65,7 @@
6565
"try:\n",
6666
" from typing import Protocol\n",
6767
"except ImportError:\n",
68-
" from typing_extensions import Protocol"
68+
" from typing import Protocol"
6969
]
7070
},
7171
{
@@ -190,7 +190,7 @@
190190
") -> DynamicsExpression:\n",
191191
" edge_ids = determine_attached_final_state(graph, edge_id)\n",
192192
" final_state_ids = map(str, edge_ids)\n",
193-
" mass = sp.Symbol(f\"m_{{{'+'.join(final_state_ids)}}}\")\n",
193+
" mass = sp.Symbol(f\"m_{{{\"+\".join(final_state_ids)}}}\")\n",
194194
" particle, _ = graph.get_edge_props(edge_id)\n",
195195
" mass0 = sp.Symbol(f\"m_{{{particle.latex}}}\")\n",
196196
" gamma0 = sp.Symbol(Rf\"\\Gamma_{{{particle.latex}}}\")\n",
@@ -212,7 +212,7 @@
212212
") -> DynamicsExpression:\n",
213213
" edge_ids = determine_attached_final_state(graph, edge_id)\n",
214214
" final_state_ids = map(str, edge_ids)\n",
215-
" mass = sp.Symbol(f\"m_{{{'+'.join(final_state_ids)}}}\")\n",
215+
" mass = sp.Symbol(f\"m_{{{\"+\".join(final_state_ids)}}}\")\n",
216216
" particle, _ = graph.get_edge_props(edge_id)\n",
217217
" mass0 = sp.Symbol(f\"m_{{{particle.latex}}}\")\n",
218218
" gamma0 = sp.Symbol(Rf\"\\Gamma_{{{particle.latex}}}\")\n",

0 commit comments

Comments
 (0)