Skip to content

Commit 1223b48

Browse files
DiamondJosephZohebShaikh
authored andcommitted
chore: Update to copier template 5.0.0 and uv (#1290)
Closes #957, #1108, #1014, duplicates #1214, #1089
1 parent d188b7b commit 1223b48

26 files changed

Lines changed: 6059 additions & 506 deletions

.copier-answers.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier
2-
_commit: 4.3.0
2+
_commit: 5.0.0
33
_src_path: https://github.com/DiamondLightSource/python-copier-template
44
author_email: [email protected]
55
author_name: Callum Forrester
@@ -10,7 +10,7 @@ description: Lightweight bluesky-as-a-service wrapper application. Also usable a
1010
a library.
1111
distribution_name: blueapi
1212
docker: true
13-
docker_debug: true
13+
docker_debug: false
1414
docs_type: sphinx
1515
git_platform: github.com
1616
github_org: DiamondLightSource

.devcontainer/devcontainer.json

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,29 @@
1111
},
1212
"remoteEnv": {
1313
// Allow X11 apps to run inside the container
14-
"DISPLAY": "${localEnv:DISPLAY}"
14+
"DISPLAY": "${localEnv:DISPLAY}",
15+
// Put things that allow it in the persistent cache
16+
"PRE_COMMIT_HOME": "/cache/pre-commit",
17+
"UV_CACHE_DIR": "/cache/uv",
18+
"UV_PYTHON_CACHE_DIR": "/cache/uv-python",
19+
// Make a venv that is specific for this workspace path as the cache is shared
20+
"UV_PROJECT_ENVIRONMENT": "/cache/venv-for${localWorkspaceFolder}",
21+
// Do the equivalent of "activate" the venv so we don't have to "uv run" everything
22+
"VIRTUAL_ENV": "/cache/venv-for${localWorkspaceFolder}",
23+
"PATH": "/cache/venv-for${localWorkspaceFolder}/bin:${containerEnv:PATH}"
1524
},
1625
"customizations": {
1726
"vscode": {
1827
// Set *default* container specific settings.json values on container create.
1928
"settings": {
20-
"python.defaultInterpreterPath": "/venv/bin/python"
29+
// Use the container's python by default
30+
"python.defaultInterpreterPath": "/cache/venv-for${localWorkspaceFolder}/bin/python",
31+
// Don't activate the venv as it is already in the PATH
32+
"python.terminal.activateEnvInCurrentTerminal": false,
33+
"python.terminal.activateEnvironment": false,
34+
// Workaround to prevent garbled python REPL in the terminal
35+
// https://github.com/microsoft/vscode-python/issues/25505
36+
"python.terminal.shellIntegration.enabled": false
2137
},
2238
// Add the IDs of extensions you want installed when the container is created.
2339
"extensions": [
@@ -33,20 +49,30 @@
3349
]
3450
}
3551
},
36-
"features": {
37-
// add in eternal history and other bash features
38-
"ghcr.io/diamondlightsource/devcontainer-features/bash-config:1": {}
39-
},
40-
// Create the config folder for the bash-config feature
41-
"initializeCommand": "mkdir -p ${localEnv:HOME}/.config/bash-config",
52+
// Create the config folder for the bash-config feature and uv cache
53+
"initializeCommand": "mkdir -p ${localEnv:HOME}/.config/terminal-config",
4254
"runArgs": [
4355
// Allow the container to access the host X11 display and EPICS CA
4456
"--net=host",
4557
// Make sure SELinux does not disable with access to host filesystems like tmp
4658
"--security-opt=label=disable"
4759
],
60+
"mounts": [
61+
// Mount in the user terminal config folder so it can be edited
62+
{
63+
"source": "${localEnv:HOME}/.config/terminal-config",
64+
"target": "/user-terminal-config",
65+
"type": "bind"
66+
},
67+
// Keep a persistent cross container cache for uv, pre-commit, and the venvs
68+
{
69+
"source": "devcontainer-shared-cache",
70+
"target": "/cache",
71+
"type": "volume"
72+
}
73+
],
4874
// Mount the parent as /workspaces so we can pip install peers as editable
4975
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
50-
// After the container is created, install the python project in editable form
51-
"postCreateCommand": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pre-commit install"
76+
// After the container is created, recreate the venv then make pre-commit first run faster
77+
"postCreateCommand": "uv venv --clear && uv sync && pre-commit install --install-hooks"
5278
}

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ It is recommended that developers use a [vscode devcontainer](https://code.visua
2424

2525
This project was created using the [Diamond Light Source Copier Template](https://github.com/DiamondLightSource/python-copier-template) for Python projects.
2626

27-
For more information on common tasks like setting up a developer environment, running the tests, and setting a pre-commit hook, see the template's [How-to guides](https://diamondlightsource.github.io/python-copier-template/4.3.0/how-to.html).
27+
For more information on common tasks like setting up a developer environment, running the tests, and setting a pre-commit hook, see the template's [How-to guides](https://diamondlightsource.github.io/python-copier-template/5.0.0/how-to.html).

.github/actions/install_requirements/action.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/_container.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
15+
uses: actions/checkout@v5
1616
with:
1717
# Need this to get version number from last tag
1818
fetch-depth: 0
@@ -63,7 +63,7 @@ jobs:
6363
tags: |
6464
type=ref,event=tag
6565
type=raw,value=latest
66-
66+
6767
- name: Push cached image to container registry
6868
if: github.ref_type == 'tag'
6969
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6

.github/workflows/_dist.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@ jobs:
77

88
steps:
99
- name: Checkout
10-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
10+
uses: actions/checkout@v5
1111
with:
1212
# Need this to get version number from last tag
1313
fetch-depth: 0
1414

15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v7
17+
1518
- name: Build sdist and wheel
1619
run: >
1720
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) &&
18-
pipx run build
21+
uvx --from build pyproject-build
1922
2023
- name: Upload sdist and wheel as artifacts
2124
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
@@ -24,12 +27,10 @@ jobs:
2427
path: dist
2528

2629
- name: Check for packaging errors
27-
run: pipx run twine check --strict dist/*
30+
run: uvx twine check --strict dist/*
2831

2932
- name: Install produced wheel
30-
uses: ./.github/actions/install_requirements
31-
with:
32-
pip-install: dist/*.whl
33+
run: python -m pip install dist/*.whl
3334

3435
- name: Test module --version works using the installed wheel
3536
# If more than one module in src/ replace with module name to test

.github/workflows/_docs.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
on:
22
workflow_call:
33

4-
54
jobs:
65
build:
76
runs-on: ubuntu-latest
@@ -12,19 +11,19 @@ jobs:
1211
run: sleep 60
1312

1413
- name: Checkout
15-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
14+
uses: actions/checkout@v5
1615
with:
1716
# Need this to get version number from last tag
1817
fetch-depth: 0
1918

2019
- name: Install system packages
2120
run: sudo apt-get install graphviz
2221

23-
- name: Install python packages
24-
uses: ./.github/actions/install_requirements
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v7
2524

2625
- name: Build docs
27-
run: tox -e docs
26+
run: uv run --locked tox -e docs
2827

2928
- name: Remove environment.pickle
3029
run: rm build/html/.doctrees/environment.pickle

.github/workflows/_pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88

99
steps:
1010
- name: Download dist artifact
11-
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
11+
uses: actions/download-artifact@v5
1212
with:
1313
name: dist
1414
path: dist

.github/workflows/_release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77

88
steps:
99
- name: Download artifacts
10-
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
10+
uses: actions/download-artifact@v5
1111
with:
1212
merge-multiple: true
1313

@@ -23,7 +23,7 @@ jobs:
2323
- name: Create GitHub Release
2424
# We pin to the SHA, not the tag, for security reasons.
2525
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
26-
uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2.2.2
26+
uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # v2.4.1
2727
with:
2828
prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }}
2929
files: "*"

.github/workflows/_system_test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ jobs:
1919
# Check out example services
2020
submodules: true
2121

22-
- name: Install python packages
23-
uses: ./.github/actions/install_requirements
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v7
2424

2525
- name: Compose services
2626
uses: hoverkraft-tech/compose-action@3846bcd61da338e9eaaf83e7ed0234a12b099b72 # v2.4.1
@@ -31,7 +31,7 @@ jobs:
3131
env:
3232
EPICS_CA_NAME_SERVERS: 127.0.0.1:9064
3333
EPICS_PVA_NAME_SERVERS: 127.0.0.1:9075
34-
run: blueapi -c ${{ github.workspace }}/tests/system_tests/config.yaml serve &
34+
run: uv run blueapi -c ${{ github.workspace }}/tests/system_tests/config.yaml serve &
3535

3636
- name: Run tests
37-
run: tox -e system-test
37+
run: uv run --locked tox -e system-test

0 commit comments

Comments
 (0)