Skip to content

Commit 56f8b8c

Browse files
committed
update to copier template branch fix-dockerfile (uv)
1 parent 2e8def5 commit 56f8b8c

File tree

13 files changed

+2924
-146
lines changed

13 files changed

+2924
-146
lines changed

.copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier
2-
_commit: 4.2.0
2+
_commit: 5.0.0a1-3-g470d4fc
33
_src_path: https://github.com/diamondlightsource/python-copier-template
44
author_email: [email protected]
55
author_name: Giles Knap

.devcontainer/devcontainer.json

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@
77
},
88
"remoteEnv": {
99
// Allow X11 apps to run inside the container
10-
"DISPLAY": "${localEnv:DISPLAY}"
10+
"DISPLAY": "${localEnv:DISPLAY}",
11+
// Do the equivalent of "activate" the venv so we don't have to "uv run" everything
12+
"PATH": "/workspaces/${localWorkspaceFolderBasename}/.venv/bin:${containerEnv:PATH}"
1113
},
1214
"customizations": {
1315
"vscode": {
1416
// Set *default* container specific settings.json values on container create.
1517
"settings": {
16-
"python.defaultInterpreterPath": "/venv/bin/python"
18+
"python.defaultInterpreterPath": "/workspaces/${localWorkspaceFolderBasename}/.venv/bin/python",
19+
"python.terminal.activateEnvInCurrentTerminal": false,
20+
"python.terminal.activateEnvironment": false,
21+
"remote.autoForwardPorts": false
1722
},
1823
// Add the IDs of extensions you want installed when the container is created.
1924
"extensions": [
@@ -27,20 +32,35 @@
2732
]
2833
}
2934
},
30-
"features": {
31-
// add in eternal history and other bash features
32-
"ghcr.io/diamondlightsource/devcontainer-features/bash-config:1": {}
33-
},
34-
// Create the config folder for the bash-config feature
35-
"initializeCommand": "mkdir -p ${localEnv:HOME}/.config/bash-config",
35+
// Create the config folder for the bash-config feature and uv cache
36+
"initializeCommand": "mkdir -p ${localEnv:HOME}/.config/terminal-config ${localEnv:HOME}/.cache/uv",
3637
"runArgs": [
3738
// Allow the container to access the host X11 display and EPICS CA
3839
"--net=host",
3940
// Make sure SELinux does not disable with access to host filesystems like tmp
4041
"--security-opt=label=disable"
4142
],
43+
"mounts": [
44+
// Mount in the user terminal config folder so it can be edited
45+
{
46+
"source": "${localEnv:HOME}/.config/terminal-config",
47+
"target": "/user-terminal-config",
48+
"type": "bind"
49+
},
50+
// Keep a persistent cross container cache for uv
51+
{
52+
"source": "${localEnv:HOME}/.cache/uv",
53+
"target": "/root/.cache/uv",
54+
"type": "bind"
55+
},
56+
// Use a volume mount for the uv venv so it is local to the container
57+
{
58+
"target": "/workspaces/${localWorkspaceFolderBasename}/.venv",
59+
"type": "volume"
60+
}
61+
],
4262
// Mount the parent as /workspaces so we can pip install peers as editable
4363
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
4464
// After the container is created, install the python project in editable form
45-
"postCreateCommand": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pre-commit install"
65+
"postCreateCommand": "uv sync && uv run pre-commit install --install-hooks"
4666
}

.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.2.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.0a1/how-to.html).

.github/actions/install_requirements/action.yml

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

.github/workflows/_dist.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ jobs:
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@v6
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@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/_test.yml

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ on:
33
inputs:
44
python-version:
55
type: string
6-
description: The version of python to install
7-
required: true
6+
description: The version of python to install, default is from .python-version file
7+
default: ""
88
runs-on:
99
type: string
1010
description: The runner to run this job on
@@ -16,6 +16,7 @@ on:
1616
env:
1717
# https://github.com/pytest-dev/pytest/issues/2042
1818
PY_IGNORE_IMPORTMISMATCH: "1"
19+
UV_PYTHON: ${{ inputs.python-version }}
1920

2021
jobs:
2122
run:
@@ -28,30 +29,11 @@ jobs:
2829
# Need this to get version number from last tag
2930
fetch-depth: 0
3031

31-
- if: inputs.python-version == 'dev'
32-
name: Install dev versions of python packages
33-
uses: ./.github/actions/install_requirements
34-
35-
- if: inputs.python-version == 'dev'
36-
name: Write the requirements as an artifact
37-
run: pip freeze --exclude-editable > /tmp/dev-requirements.txt
38-
39-
- if: inputs.python-version == 'dev'
40-
name: Upload dev-requirements.txt
41-
uses: actions/upload-artifact@v4
42-
with:
43-
name: dev-requirements
44-
path: /tmp/dev-requirements.txt
45-
46-
- if: inputs.python-version != 'dev'
47-
name: Install latest versions of python packages
48-
uses: ./.github/actions/install_requirements
49-
with:
50-
python-version: ${{ inputs.python-version }}
51-
pip-install: ".[dev]"
32+
- name: Install uv
33+
uses: astral-sh/setup-uv@v5
5234

5335
- name: Run tests
54-
run: tox -e tests
36+
run: uv run --locked tox -e tests
5537

5638
- name: Upload coverage to Codecov
5739
uses: codecov/codecov-action@v5

.github/workflows/_tox.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
- name: Checkout
1616
uses: actions/checkout@v4
1717

18-
- name: Install python packages
19-
uses: ./.github/actions/install_requirements
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v5
2020

2121
- name: Run tox
22-
run: tox -e ${{ inputs.tox }}
22+
run: uv run --locked tox -e ${{ inputs.tox }}

.github/workflows/ci.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ jobs:
2020
matrix:
2121
runs-on: ["ubuntu-latest"] # can add windows-latest, macos-latest
2222
python-version: ["3.11", "3.12", "3.13"]
23-
include:
24-
# Include one that runs in the dev environment
25-
- runs-on: "ubuntu-latest"
26-
python-version: "dev"
2723
fail-fast: false
2824
uses: ./.github/workflows/_test.yml
2925
with:

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ repos:
33
rev: v5.0.0
44
hooks:
55
- id: check-added-large-files
6+
args: ["--maxkb=1000"] # uv.lock is more than 500kB
67
- id: check-yaml
78
exclude: ^helm\/.*\/templates\/.*|catalog-info.yaml
89
- id: check-merge-conflict
@@ -23,3 +24,10 @@ repos:
2324
entry: ruff format --force-exclude
2425
types: [python]
2526
require_serial: true
27+
28+
- id: uv-sync
29+
name: update uv.lock and venv
30+
pass_filenames: false
31+
language: system
32+
entry: uv sync
33+
files: ^(uv\.lock|pyproject\.toml)$

.python-version

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

0 commit comments

Comments
 (0)