Skip to content

Commit 0a90172

Browse files
authored
Merge pull request #76 from DiamondLightSource/copier-update
Copier update
2 parents e55068b + 801ff39 commit 0a90172

File tree

22 files changed

+3477
-175
lines changed

22 files changed

+3477
-175
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.1.0
2+
_commit: 5.0.0a5
33
_src_path: gh:DiamondLightSource/python-copier-template
44
author_email: [email protected]
55
author_name: Tom Cobb

.devcontainer/devcontainer.json

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,29 @@
77
},
88
"remoteEnv": {
99
// Allow X11 apps to run inside the container
10-
"DISPLAY": "${localEnv:DISPLAY}"
10+
"DISPLAY": "${localEnv:DISPLAY}",
11+
// Put things that allow it in the persistent cache
12+
"PRE_COMMIT_HOME": "/cache/pre-commit",
13+
"UV_CACHE_DIR": "/cache/uv",
14+
"UV_PYTHON_CACHE_DIR": "/cache/uv-python",
15+
// Make a venv that is specific for this workspace path as the cache is shared
16+
"UV_PROJECT_ENVIRONMENT": "/cache/venv-for${localWorkspaceFolder}",
17+
// Do the equivalent of "activate" the venv so we don't have to "uv run" everything
18+
"VIRTUAL_ENV": "/cache/venv-for${localWorkspaceFolder}",
19+
"PATH": "/cache/venv-for${localWorkspaceFolder}/bin:${containerEnv:PATH}"
1120
},
1221
"customizations": {
1322
"vscode": {
1423
// Set *default* container specific settings.json values on container create.
1524
"settings": {
16-
"python.defaultInterpreterPath": "/venv/bin/python"
25+
// Use the container's python by default
26+
"python.defaultInterpreterPath": "/cache/venv-for${localWorkspaceFolder}/bin/python",
27+
// Don't activate the venv as it is already in the PATH
28+
"python.terminal.activateEnvInCurrentTerminal": false,
29+
"python.terminal.activateEnvironment": false,
30+
// Workaround to prevent garbled python REPL in the terminal
31+
// https://github.com/microsoft/vscode-python/issues/25505
32+
"python.terminal.shellIntegration.enabled": false
1733
},
1834
// Add the IDs of extensions you want installed when the container is created.
1935
"extensions": [
@@ -27,20 +43,30 @@
2743
]
2844
}
2945
},
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",
46+
// Create the config folder for the bash-config feature and uv cache
47+
"initializeCommand": "mkdir -p ${localEnv:HOME}/.config/terminal-config",
3648
"runArgs": [
3749
// Allow the container to access the host X11 display and EPICS CA
3850
"--net=host",
3951
// Make sure SELinux does not disable with access to host filesystems like tmp
4052
"--security-opt=label=disable"
4153
],
54+
"mounts": [
55+
// Mount in the user terminal config folder so it can be edited
56+
{
57+
"source": "${localEnv:HOME}/.config/terminal-config",
58+
"target": "/user-terminal-config",
59+
"type": "bind"
60+
},
61+
// Keep a persistent cross container cache for uv, pre-commit, and the venvs
62+
{
63+
"source": "devcontainer-shared-cache",
64+
"target": "/cache",
65+
"type": "volume"
66+
}
67+
],
4268
// Mount the parent as /workspaces so we can pip install peers as editable
4369
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
44-
// 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"
70+
// After the container is created, recreate the venv then make pre-commit first run faster
71+
"postCreateCommand": "uv venv --clear && uv sync && pre-commit install --install-hooks"
4672
}

.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.1.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.0a5/how-to.html).

.github/actions/install_requirements/action.yml

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

.github/dependabot.yml

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

.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@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@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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ jobs:
1212
run: sleep 60
1313

1414
- name: Checkout
15-
uses: actions/checkout@v4
15+
uses: actions/checkout@v5
1616
with:
1717
# Need this to get version number from last tag
1818
fetch-depth: 0
1919

2020
- name: Install system packages
2121
run: sudo apt-get install graphviz
2222

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

2626
- name: Build docs
27-
run: tox -e docs
27+
run: uv run --locked tox -e docs
2828

2929
- name: Remove environment.pickle
3030
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@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@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/_test.yml

Lines changed: 7 additions & 25 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,42 +16,24 @@ 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:
2223
runs-on: ${{ inputs.runs-on }}
2324

2425
steps:
2526
- name: Checkout
26-
uses: actions/checkout@v4
27+
uses: actions/checkout@v5
2728
with:
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@v7
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

0 commit comments

Comments
 (0)