Skip to content

Commit 87224d4

Browse files
committed
tox-uv tweaks
1 parent 3d617c6 commit 87224d4

15 files changed

Lines changed: 157 additions & 614 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,7 @@
1919
"settings": {
2020
"python.defaultInterpreterPath": "/workspaces/${localWorkspaceFolderBasename}/.venv/bin/python",
2121
"python.terminal.activateEnvInCurrentTerminal": false,
22-
"python.terminal.activateEnvironment": false,
23-
"python.testing.unittestEnabled": false,
24-
"python.testing.pytestEnabled": true,
25-
"editor.formatOnSave": true,
26-
"editor.codeActionsOnSave": {
27-
"source.organizeImports": "explicit"
28-
},
29-
"remote.autoForwardPorts": false,
30-
"[python]": {
31-
"editor.defaultFormatter": "charliermarsh.ruff"
32-
}
22+
"python.terminal.activateEnvironment": false
3323
},
3424
// Add the IDs of extensions you want installed when the container is created.
3525
"extensions": [
@@ -73,5 +63,5 @@
7363
// Mount the parent as /workspaces so we can pip install peers as editable
7464
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
7565
// After the container is created, install the python project in editable form
76-
"postCreateCommand": "uv sync && uv run pre-commit install"
66+
"postCreateCommand": "uv sync && uv run pre-commit install --install-hooks"
7767
}

.github/actions/install_requirements/action.yml

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

.github/workflows/_dist.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ jobs:
1212
# Need this to get version number from last tag
1313
fetch-depth: 0
1414

15-
- name: Build sdist and wheel
16-
run: >
17-
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) &&
18-
pipx run build
19-
2015
- name: Install uv
2116
uses: astral-sh/setup-uv@v6
2217

.github/workflows/_test.yml

Lines changed: 2 additions & 2 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

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ jobs:
1818
uses: ./.github/workflows/_test.yml
1919
with:
2020
runs-on: ubuntu-latest
21-
python-version: ""
2221
secrets:
2322
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2423

.github/workflows/periodic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ jobs:
1010
linkcheck:
1111
uses: ./.github/workflows/_tox.yml
1212
with:
13-
tox: docs build -- -b linkcheck
13+
tox: docs -- build -b linkcheck

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ repos:
2626
types: [python]
2727
require_serial: true
2828

29-
# Make sure lock file is up to date.
29+
# Make sure lock file satisfies dependencies in pyproject.toml.
3030
- id: uv-lock
3131
name: update uv.lock
3232
pass_filenames: false
3333
language: system
3434
entry: uv lock
35-
files: ^(uv\.lock|pyproject\.toml|uv\.toml)$
35+
files: ^(uv\.lock|pyproject\.toml)$

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
# The developer stage is used as a devcontainer including dev versions
22
# of the build dependencies
33
FROM ghcr.io/diamondlightsource/ubuntu-devcontainer:noble AS developer
4+
5+
# Add any system dependencies for the developer/build environment here
6+
RUN apt-get update && apt-get install -y --no-install-recommends \
7+
graphviz

docs/how-to/build-docs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ $ firefox build/html/index.html
2323
You can also run an autobuild process, which will watch your `docs` directory for changes and rebuild whenever it sees changes, reloading any browsers watching the pages:
2424

2525
```
26-
$ tox -e docs autobuild
26+
$ tox -e docs -- autobuild
2727
```
2828

2929
You can view the pages at localhost:
@@ -35,5 +35,5 @@ $ firefox http://localhost:8000
3535
If you are making changes to source code too, you can tell it to watch changes in this directory too:
3636

3737
```
38-
$ tox -e docs autobuild -- --watch src
38+
$ tox -e docs -- autobuild --watch src
3939
```

pyproject.toml

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ dev = [
1818
"sphinx-autobuild",
1919
"sphinx-copybutton",
2020
"sphinx-design",
21-
"tox-direct",
22-
"twine>=6.1.0",
21+
"tox-uv",
2322
]
2423

2524
[tool.setuptools_scm]
@@ -32,51 +31,21 @@ addopts = """
3231
# Doctest python code in docs, python code in src docstrings, test functions in tests
3332
testpaths = "tests"
3433

35-
34+
# tox must be configured via an embedded ini string to support
35+
# using positional args as parts of command arguments
3636
[tool.tox]
37-
skipsdist = true
38-
requires = ["tox-uv>=1.25.0"]
39-
# envs to runs automatically with tox -p
40-
env_list = ["pre-commit", "tests", "docs"]
41-
42-
[tool.tox.env]
43-
passenv = { "*" = "" }
44-
# Include setuptools, pip, ... in the tox envs
45-
uv_seed = { enabled = true }
46-
47-
[tool.tox.env.pre-commit]
48-
description = "Run pre-commit"
49-
allowlist_externals = ["pre-commit"]
50-
commands = [
51-
[
52-
"pre-commit",
53-
"run",
54-
#"--all-files",
55-
"--show-diff-on-failure",
56-
{ replace = "posargs", default = [], extend = true },
57-
],
58-
]
59-
60-
[tool.tox.env.tests]
61-
description = "Run tests"
62-
allowlist_externals = ["pytest"]
63-
commands = [["pytest", { replace = "posargs", default = [], extend = true }]]
37+
legacy_tox_ini = """
38+
[tox]
39+
skipsdist=True
40+
env_list = pre-commit,tests,docs
6441
65-
[tool.tox.env.docs]
66-
description = "Run docs"
67-
allowlist_externals = ["sphinx-build", "sphinx-autobuild"]
68-
commands = [
69-
[
70-
"sphinx-build",
71-
"-T",
72-
"docs",
73-
"build/html",
74-
{ replace = "posargs", default = [
75-
"-EW",
76-
"--keep-going",
77-
], extend = true },
78-
],
79-
]
42+
[testenv:{pre-commit,tests,docs}]
43+
passenv = *
44+
commands =
45+
pre-commit: pre-commit run --all-files --show-diff-on-failure {posargs}
46+
tests: pytest {posargs}
47+
docs: sphinx-{posargs:build -EW --keep-going} -T docs build/html
48+
"""
8049

8150
[tool.ruff]
8251
src = ["src", "tests"]

0 commit comments

Comments
 (0)