Skip to content

Commit 49bae86

Browse files
committed
fix: Stop exposing dev tasks as published entry points for uv
The uv variant declared formatting, checks, tests, docs, changelog, release and clean under [project.scripts], so anyone who pip-installed the package would have those generic commands in their PATH. Drop the [project.scripts] block, delete the test_repo.cli proxy that backed it, and set nox.options (uv backend, error_on_external_run, reuse_existing_virtualenvs) at the top of the noxfile so plain uv run nox -s <session> reproduces the previous behavior. Update the GitHub Actions, GitLab, Azure DevOps and Bitbucket CI configs, the pre-commit hook and CONTRIBUTING.md to use uv run nox -s <session> instead.
1 parent 9e058bd commit 49bae86

33 files changed

Lines changed: 91 additions & 142 deletions

project/.pre-commit-config.yaml.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ repos:
2727
hooks:
2828
- id: pytest
2929
name: Check pytest unit tests pass
30-
entry: '{{ "pdm" if package_manager == "PDM" else "uv" }} run tests'
30+
entry: '{{ "pdm tests" if package_manager == "PDM" else "uv run nox -s tests" }}'
3131
pass_filenames: false
3232
language: system
3333
types: [python]

project/CONTRIBUTING.md.jinja

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,43 @@ the project for more details. You can run any of the following commands and subc
99

1010
### Documentation
1111

12-
- `{%- if package_manager == "PDM" -%}pdm docs serve` or `pdm docs{%- else -%}uv run docs{%- endif -%}`: Serve the documentation.
13-
- `{%- if package_manager == "PDM" -%}pdm docs build{%- else -%}uv run docs -- build{%- endif -%}`: Build locally the documentation.
12+
- `{%- if package_manager == "PDM" -%}pdm docs serve` or `pdm docs{%- else -%}uv run nox -s docs{%- endif -%}`: Serve the documentation.
13+
- `{%- if package_manager == "PDM" -%}pdm docs build{%- else -%}uv run nox -s docs -- build{%- endif -%}`: Build locally the documentation.
1414

1515
### Formatting
1616

17-
- `{%- if package_manager == "PDM" -%}pdm formatting all` or `pdm formatting{%- else -%}uv run formatting{%- endif -%}`: Format both the code and docstrings.
18-
- `{%- if package_manager == "PDM" -%}pdm formatting code{%- else -%}uv run formatting -- code{%- endif -%}`: Format only the code.
19-
- `{%- if package_manager == "PDM" -%}pdm formatting docstrings{%- else -%}uv run formatting -- docstrings{%- endif -%}`: Format only the docstrings.
17+
- `{%- if package_manager == "PDM" -%}pdm formatting all` or `pdm formatting{%- else -%}uv run nox -s formatting{%- endif -%}`: Format both the code and docstrings.
18+
- `{%- if package_manager == "PDM" -%}pdm formatting code{%- else -%}uv run nox -s formatting -- code{%- endif -%}`: Format only the code.
19+
- `{%- if package_manager == "PDM" -%}pdm formatting docstrings{%- else -%}uv run nox -s formatting -- docstrings{%- endif -%}`: Format only the docstrings.
2020

2121
### Checks
2222

23-
- `{%- if package_manager == "PDM" -%}pdm checks all` or `pdm checks{%- else -%}uv run checks{%- endif -%}`: Run all checks.
24-
- `{%- if package_manager == "PDM" -%}pdm checks quality{%- else -%}uv run checks -- quality{%- endif -%}`: Check only code quality.
25-
- `{%- if package_manager == "PDM" -%}pdm checks types{%- else -%}uv run checks -- types{%- endif -%}`: Check only type annotations.
26-
- `{%- if package_manager == "PDM" -%}pdm checks dependencies{%- else -%}uv run checks -- dependencies{%- endif -%}`: Check only for vulnerabilities in dependencies.
23+
- `{%- if package_manager == "PDM" -%}pdm checks all` or `pdm checks{%- else -%}uv run nox -s checks{%- endif -%}`: Run all checks.
24+
- `{%- if package_manager == "PDM" -%}pdm checks quality{%- else -%}uv run nox -s checks -- quality{%- endif -%}`: Check only code quality.
25+
- `{%- if package_manager == "PDM" -%}pdm checks types{%- else -%}uv run nox -s checks -- types{%- endif -%}`: Check only type annotations.
26+
- `{%- if package_manager == "PDM" -%}pdm checks dependencies{%- else -%}uv run nox -s checks -- dependencies{%- endif -%}`: Check only for vulnerabilities in dependencies.
2727

2828
### Tests
2929

30-
- `{%- if package_manager == "PDM" -%}pdm tests{%- else -%}uv run tests{%- endif -%}`: Run the tests.
30+
- `{%- if package_manager == "PDM" -%}pdm tests{%- else -%}uv run nox -s tests{%- endif -%}`: Run the tests.
3131

3232
### Changelog
3333

34-
- `{%- if package_manager == "PDM" -%}pdm changelog{%- else -%}uv run changelog{%- endif -%}`: Build the changelog.
34+
- `{%- if package_manager == "PDM" -%}pdm changelog{%- else -%}uv run nox -s changelog{%- endif -%}`: Build the changelog.
3535

3636
### Release
3737

38-
- `{%- if package_manager == "PDM" -%}pdm release{%- else -%}uv run release{%- endif -%}`: Release a new Python package with an updated version.
38+
- `{%- if package_manager == "PDM" -%}pdm release{%- else -%}uv run nox -s release{%- endif -%}`: Release a new Python package with an updated version.
3939

4040
## Development
4141

4242
The next steps should be followed during development:
4343

4444
- `git checkout -b new-branch-name` to create a new branch and then modify the code.
45-
- `{%- if package_manager == "PDM" -%}pdm formatting{%- else -%}uv run formatting{%- endif -%}` to auto-format the code and docstrings.
46-
- `{%- if package_manager == "PDM" -%}pdm checks{%- else -%}uv run checks{%- endif -%}` to apply all checks.
47-
- `{%- if package_manager == "PDM" -%}pdm tests{%- else -%}uv run tests{%- endif -%}` to run the tests.
48-
- `{%- if package_manager == "PDM" -%}pdm docs serve{%- else -%}uv run docs{%- endif -%}` if you updated the documentation or the project dependencies to check that everything looks as expected.
45+
- `{%- if package_manager == "PDM" -%}pdm formatting{%- else -%}uv run nox -s formatting{%- endif -%}` to auto-format the code and docstrings.
46+
- `{%- if package_manager == "PDM" -%}pdm checks{%- else -%}uv run nox -s checks{%- endif -%}` to apply all checks.
47+
- `{%- if package_manager == "PDM" -%}pdm tests{%- else -%}uv run nox -s tests{%- endif -%}` to run the tests.
48+
- `{%- if package_manager == "PDM" -%}pdm docs serve{%- else -%}uv run nox -s docs{%- endif -%}` if you updated the documentation or the project dependencies to check that everything looks as expected.
4949

5050
## Commit message convention
5151

project/noxfile.py.jinja

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ from git_changelog.cli import build_and_render
2525
{% if package_manager == "PDM" %}
2626
os.environ.update({'PDM_IGNORE_SAVED_PYTHON': '1'})
2727
{% endif %}
28-
{% if package_manager == "uv" -%}{% endif -%}
28+
{% if package_manager == "uv" -%}
29+
nox.options.default_venv_backend = 'uv'
30+
nox.options.error_on_external_run = True
31+
nox.options.reuse_existing_virtualenvs = True
32+
{% endif %}
2933
PYTHON_VERSIONS: list[str] = {{ versions }}
3034
FILES: list[str] = ['src', 'tests', 'docs', 'noxfile.py']
3135
CHANGELOG_ARGS: dict[str, Any] = {

project/pyproject.toml.jinja

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,6 @@ dev = [
223223
"nox[uv]>=2024.4.15",
224224
]
225225

226-
[project.scripts]
227-
formatting = "{{ python_package_import_name }}.cli:formatting"
228-
checks = "{{ python_package_import_name }}.cli:checks"
229-
tests = "{{ python_package_import_name }}.cli:tests"
230-
docs = "{{ python_package_import_name }}.cli:docs"
231-
changelog = "{{ python_package_import_name }}.cli:changelog"
232-
release = "{{ python_package_import_name }}.cli:release"
233-
clean = "{{ python_package_import_name }}.cli:clean"
234-
235226
[tool.hatch.version]
236227
source = "vcs"
237228

project/src/{{python_package_import_name}}/{% if package_manager == 'uv' %}cli.py{% endif %}

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

project/{% if git_provider == 'Azure DevOps' %}azure-pipelines.yml{% endif %}.jinja

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ stages:
3232
pdm run tests
3333
{% else -%}
3434
uv sync
35-
uv run tests
35+
uv run nox -s tests
3636
{% endif -%}
3737
displayName: 'Run tests'
3838

@@ -72,7 +72,7 @@ stages:
7272
pdm run checks
7373
{% else -%}
7474
uv sync
75-
uv run checks
75+
uv run nox -s checks
7676
{% endif -%}
7777
displayName: 'Run quality checks'
7878

@@ -102,7 +102,7 @@ stages:
102102
pdm run docs build
103103
{% else -%}
104104
uv sync
105-
uv run docs build
105+
uv run nox -s docs -- build
106106
{% endif -%}
107107
displayName: 'Build documentation'
108108

@@ -138,7 +138,7 @@ stages:
138138
pdm run release
139139
{% else -%}
140140
uv sync
141-
uv run release
141+
uv run nox -s release
142142
{% endif -%}
143143
displayName: 'Release to PyPI'
144144
env:

project/{% if git_provider == 'Bitbucket' %}bitbucket-pipelines.yml{% endif %}.jinja

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pipelines:
1414
{% else -%}
1515
- pip install uv
1616
- uv sync
17-
- uv run tests
17+
- uv run nox -s tests
1818
{% endif -%}
1919
artifacts:
2020
- coverage.xml
@@ -32,7 +32,7 @@ pipelines:
3232
{% else -%}
3333
- pip install uv
3434
- uv sync
35-
- uv run checks
35+
- uv run nox -s checks
3636
{% endif -%}
3737

3838
branches:
@@ -49,7 +49,7 @@ pipelines:
4949
{% else -%}
5050
- pip install uv
5151
- uv sync
52-
- uv run tests
52+
- uv run nox -s tests
5353
{% endif -%}
5454
artifacts:
5555
- coverage.xml
@@ -67,7 +67,7 @@ pipelines:
6767
{% else -%}
6868
- pip install uv
6969
- uv sync
70-
- uv run checks
70+
- uv run nox -s checks
7171
{% endif -%}
7272

7373
- step:
@@ -82,7 +82,7 @@ pipelines:
8282
{% else -%}
8383
- pip install uv
8484
- uv sync
85-
- uv run docs build
85+
- uv run nox -s docs -- build
8686
{% endif -%}
8787
artifacts:
8888
- site/**
@@ -101,7 +101,7 @@ pipelines:
101101
{% else -%}
102102
- pip install uv
103103
- uv sync
104-
- uv run tests
104+
- uv run nox -s tests
105105
{% endif -%}
106106

107107
- step:
@@ -116,7 +116,7 @@ pipelines:
116116
{% else -%}
117117
- pip install uv
118118
- uv sync
119-
- uv run checks
119+
- uv run nox -s checks
120120
{% endif -%}
121121

122122
{% if publish_pypi -%}
@@ -132,7 +132,7 @@ pipelines:
132132
{% else -%}
133133
- pip install uv
134134
- uv sync
135-
- uv run release
135+
- uv run nox -s release
136136
{% endif -%}
137137
trigger: manual
138138
{% endif -%}

project/{% if git_provider == 'GitHub' %}.github{% endif %}/workflows/ci.yml.jinja

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ jobs:
6868
run: uv sync --only-dev
6969

7070
- name: Check code quality
71-
run: uv run checks quality
71+
run: uv run nox -s checks -- quality
7272

7373
- name: Check type annotations
74-
run: uv run checks types
74+
run: uv run nox -s checks -- types
7575

7676
- name: Check vulnerabilities in dependencies
77-
run: uv run checks dependencies
77+
run: uv run nox -s checks -- dependencies
7878
{%- endif %}
7979

8080
tests:
@@ -123,7 +123,7 @@ jobs:
123123
run: uv sync
124124

125125
- name: Run the test suite
126-
run: uv run tests
126+
run: uv run nox -s tests
127127
{%- endif %}
128128

129129
doc:
@@ -164,5 +164,5 @@ jobs:
164164
run: uv sync
165165

166166
- name: Build documentation with Python {% raw %}${{ matrix.python-version }}{% endraw %}
167-
run: uv run docs build
167+
run: uv run nox -s docs -- build
168168
{%- endif %}

project/{% if git_provider == 'GitHub' %}.github{% endif %}/workflows/doc.yml.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
run: uv sync
5555

5656
- name: Build documentation
57-
run: uv run docs build
57+
run: uv run nox -s docs -- build
5858
{%- endif %}
5959

6060
- name: Upload artifact

project/{% if git_provider == 'GitLab' %}.gitlab-ci.yml{% endif %}.jinja

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ test:
3030
- pdm run tests
3131
{% else -%}
3232
- uv sync
33-
- uv run tests
33+
- uv run nox -s tests
3434
{% endif -%}
3535
coverage: '/TOTAL.*\s+(\d+%)$/'
3636
artifacts:
@@ -48,7 +48,7 @@ quality:
4848
- pdm run checks
4949
{% else -%}
5050
- uv sync
51-
- uv run checks
51+
- uv run nox -s checks
5252
{% endif -%}
5353

5454
docs:
@@ -60,7 +60,7 @@ docs:
6060
- pdm run docs build
6161
{% else -%}
6262
- uv sync
63-
- uv run docs build
63+
- uv run nox -s docs -- build
6464
{% endif -%}
6565
artifacts:
6666
paths:
@@ -90,7 +90,7 @@ release:
9090
- pdm run release
9191
{% else -%}
9292
- uv sync
93-
- uv run release
93+
- uv run nox -s release
9494
{% endif -%}
9595
only:
9696
- tags

0 commit comments

Comments
 (0)