Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DX: define developer environment with uv #301

Merged
merged 29 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0f95dfd
MAINT: simplify `tox.ini` with `base`
redeboer Oct 11, 2024
fd1ed06
MAINT: move `description` on one line
redeboer Oct 11, 2024
a265c89
MAINT: remove `passenv` from `[tox]`
redeboer Oct 11, 2024
a9ea1fd
MAINT: remove `FORCE_COLOR` from `tox`
redeboer Oct 11, 2024
5550303
DX: remove `jcache` job
redeboer Oct 11, 2024
e9a7a90
MAINT: write CLI flags with `=` sign and quotation marks
redeboer Oct 11, 2024
30eb830
DX: run `docnb-force`, `linkcheck`, and `sty` in `tox`
redeboer Oct 11, 2024
7440cfa
FIX: start `sphinx-autobuild` on random available port
redeboer Oct 11, 2024
28c5860
MAINT: use `--ignore` instead of `--re-ignore` where possible
redeboer Oct 11, 2024
fab60da
DOC: improve Tox job descriptions
redeboer Oct 11, 2024
e0aaafc
DOC: group doc jobs for `tox list`
redeboer Oct 11, 2024
8c66253
MAINT: generalize `--re-ignore` patterns
redeboer Oct 11, 2024
b12db3d
FIX: allow `sphinx-autobuild`
redeboer Oct 11, 2024
922157f
MAINT: move `--all-files` before `{posargs}`
redeboer Oct 16, 2024
5b1c0cd
BREAK: rename PyPI package to `compwa-github-io`
redeboer Oct 16, 2024
2cf2782
DX: modernize dev environment with `uv`
redeboer Oct 16, 2024
38eedd9
MAINT: update lock files and developer environment
redeboer Oct 18, 2024
45969a7
FIX: instal notebook packages with `uv`
redeboer Oct 18, 2024
9732b6a
DOC: update Binder links
redeboer Oct 18, 2024
f2e28b2
MAINT: remove outdated `pytest` deprecation warning
redeboer Oct 21, 2024
91414e6
MAINT: commit `uv.lock` file
redeboer Oct 21, 2024
afdd11b
DX: only support Python 3.12
redeboer Oct 21, 2024
fa1da3b
FIX: remove `pre-commit-uv` from environment
redeboer Oct 21, 2024
14837e5
FIX: remove `tox` from environment
redeboer Oct 21, 2024
6a6d337
FIX: install notebook dependencies in environment
redeboer Oct 21, 2024
29417c5
FIX: install `graphviz` in dependencies
redeboer Oct 21, 2024
1166cde
FIX: remove links to `tox.ini`
redeboer Oct 21, 2024
0a4d3dd
FIX: remove links to `environment.yml`
redeboer Oct 21, 2024
541a272
FIX: ignore `github.com/search`
redeboer Oct 21, 2024
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
1 change: 1 addition & 0 deletions .binder/apt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
graphviz
12 changes: 12 additions & 0 deletions .binder/postBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -ex
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.cargo/env
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
4 changes: 1 addition & 3 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"*.svg",
".editorconfig",
".envrc",
".gitattributes",
".gitignore",
".pre-commit-config.yaml",
".prettierignore",
Expand All @@ -36,8 +35,7 @@
"CITATION.cff",
"docs/adr/*/*",
"docs/conf.py",
"pyproject.toml",
"tox.ini"
"pyproject.toml"
],
"language": "en-US",
"words": [
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
12 changes: 2 additions & 10 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
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
uv sync --all-extras --quiet
source .venv/bin/activate
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ on:
jobs:
milestone:
if: startsWith(github.ref, 'refs/tags')
uses: ComPWA/actions/.github/workflows/close-milestone.yml@v1
uses: ComPWA/actions/.github/workflows/close-milestone.yml@v2
push:
if: startsWith(github.ref, 'refs/tags') && !github.event.release.prerelease
secrets: inherit
uses: ComPWA/actions/.github/workflows/push-to-version-branches.yml@v1
uses: ComPWA/actions/.github/workflows/push-to-version-branches.yml@v2
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,16 @@ 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 }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Requirements
name: Update

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -12,12 +12,11 @@ on:
- epic/*
paths:
- .pre-commit-config.yaml
schedule:
- cron: "0 3 7 */2 *"
- uv.lock
workflow_dispatch:

jobs:
requirements:
uses: ComPWA/actions/.github/workflows/requirements.yml@v1
lock:
uses: ComPWA/actions/.github/workflows/lock.yml@v2
secrets:
token: ${{ secrets.PAT }}
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
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
update_release_draft:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: release-drafter/release-drafter@v6
env:
Expand Down
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 @@ -36,7 +35,6 @@ prof/

# Virtual environments
*venv/
.pixi/
.tox/
pyvenv*/

Expand All @@ -53,6 +51,5 @@ pyvenv*/
!.vscode/*.json
!.zenodo.json
!codecov.yml
!environment.yml
!pyrightconfig.json
.jupyter_ystore.db
23 changes: 14 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
ci:
autoupdate_commit_msg: "MAINT: autoupdate pre-commit hooks"
autoupdate_commit_msg: "MAINT: update lock files"
autoupdate_schedule: quarterly
skip:
- check-jsonschema
- pyright
- uv-lock

repos:
- repo: meta
Expand All @@ -12,14 +13,13 @@ repos:
- id: check-useless-excludes

- repo: https://github.com/ComPWA/policy
rev: 0.4.1
rev: 0.5.0
hooks:
- id: check-dev-files
args:
- --doc-apt-packages=graphviz
- --dev-python-version=3.12
- --github-pages
- --no-prettierrc
- --no-pypi
- --repo-name=compwa.github.io
- --repo-title=ComPWA Organization
Expand Down Expand Up @@ -56,7 +56,7 @@ repos:
metadata.vscode

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.4
rev: v0.7.0
hooks:
- id: ruff
args: [--fix]
Expand All @@ -65,7 +65,7 @@ repos:
types_or: [python, pyi, jupyter]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-ast
- id: check-case-conflict
Expand Down Expand Up @@ -106,7 +106,7 @@ repos:
args: [--in-place]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.2
rev: 0.29.4
hooks:
- id: check-jsonschema
name: Check CITATION.cff
Expand All @@ -119,7 +119,7 @@ repos:
pass_filenames: false

- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.13.3
rev: v8.15.2
hooks:
- id: cspell

Expand All @@ -144,7 +144,12 @@ repos:
docs/_static/favicon.ico
)$

- repo: https://github.com/ComPWA/mirrors-pyright
rev: v1.1.379
- repo: https://github.com/ComPWA/pyright-pre-commit
rev: v1.1.385
hooks:
- id: pyright

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.4.25
hooks:
- id: uv-lock
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
27 changes: 12 additions & 15 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
version: 2

sphinx:
builder: html
configuration: docs/conf.py
fail_on_warning: true

formats:
- htmlzip

build:
os: ubuntu-22.04
apt_packages:
- graphviz
os: ubuntu-24.04
tools:
python: "3.12"
jobs:
post_install:
- python -m pip install 'uv>=0.2.0'
- python -m uv pip install -e .[doc]
commands:
- |-
export PIXI_HOME=$READTHEDOCS_VIRTUALENV_PATH
curl -fsSL https://pixi.sh/install.sh | bash
pixi global install graphviz uv
- |-
export UV_LINK_MODE=copy
uv run --extra doc --locked --with tox \
tox -e doc
mkdir -p $READTHEDOCS_OUTPUT
mv docs/_build/html $READTHEDOCS_OUTPUT
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
"\u03bd": true,
"\u03c3": true
},
"files.associations": {
"**/pixi.lock": "yaml"
},
"files.watcherExclude": {
"**/*_cache/**": true,
"**/.eggs/**": true,
Expand Down Expand Up @@ -63,6 +60,9 @@
"ruff.enable": true,
"ruff.importStrategy": "fromEnvironment",
"ruff.organizeImports": true,
"search.exclude": {
"**/uv.lock": true
},
"telemetry.telemetryLevel": "off",
"yaml.schemas": {
"https://citation-file-format.github.io/1.2.0/schema.json": "CITATION.cff",
Expand Down
25 changes: 23 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# How to contribute?

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

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)**!
> [!TIP]
> 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)**!

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):

```shell
git clone https://github.com/ComPWA/compwa.github.io
cd compwa.github.io
```

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).

```shell
uv sync
source .venv/bin/activate
```

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**:

```shell
pre-commit install --install-hooks
```
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
[![Spelling checked](https://img.shields.io/badge/cspell-checked-brightgreen.svg)](https://github.com/streetsidesoftware/cspell/tree/master/packages/cspell)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![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)

This repository contains the source code for the [compwa.github.io](https://compwa.github.io) pages.
2 changes: 1 addition & 1 deletion docs/adr/001/operators.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"outputs": [],
"source": [
"%pip install -q expertsystem==0.6.10 graphviz==0.16"
"!uv pip install -q expertsystem==0.6.10 graphviz==0.16"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/adr/001/sympy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"outputs": [],
"source": [
"%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.*"
"!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.*"
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions docs/adr/002/composition.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"outputs": [],
"source": [
"%pip install -q matplotlib==3.4.2 sympy==1.8"
"!uv pip install -q matplotlib==3.4.2 sympy==1.8"
]
},
{
Expand Down Expand Up @@ -65,7 +65,7 @@
"try:\n",
" from typing import Protocol\n",
"except ImportError:\n",
" from typing_extensions import Protocol"
" from typing import Protocol"
]
},
{
Expand Down Expand Up @@ -190,7 +190,7 @@
") -> DynamicsExpression:\n",
" edge_ids = determine_attached_final_state(graph, edge_id)\n",
" final_state_ids = map(str, edge_ids)\n",
" mass = sp.Symbol(f\"m_{{{'+'.join(final_state_ids)}}}\")\n",
" mass = sp.Symbol(f\"m_{{{\"+\".join(final_state_ids)}}}\")\n",
" particle, _ = graph.get_edge_props(edge_id)\n",
" mass0 = sp.Symbol(f\"m_{{{particle.latex}}}\")\n",
" gamma0 = sp.Symbol(Rf\"\\Gamma_{{{particle.latex}}}\")\n",
Expand All @@ -212,7 +212,7 @@
") -> DynamicsExpression:\n",
" edge_ids = determine_attached_final_state(graph, edge_id)\n",
" final_state_ids = map(str, edge_ids)\n",
" mass = sp.Symbol(f\"m_{{{'+'.join(final_state_ids)}}}\")\n",
" mass = sp.Symbol(f\"m_{{{\"+\".join(final_state_ids)}}}\")\n",
" particle, _ = graph.get_edge_props(edge_id)\n",
" mass0 = sp.Symbol(f\"m_{{{particle.latex}}}\")\n",
" gamma0 = sp.Symbol(Rf\"\\Gamma_{{{particle.latex}}}\")\n",
Expand Down
Loading
Loading