Skip to content

Commit 0988c5a

Browse files
build: migrate to uv
1 parent c87ea73 commit 0988c5a

7 files changed

Lines changed: 883 additions & 87 deletions

File tree

.github/CONTRIBUTING.md

Lines changed: 17 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,22 @@ cd python-package-template
1717

1818
## Install
1919

20-
Install [Python](https://www.python.org/):
20+
Install [uv](https://docs.astral.sh/uv/):
2121

2222
```sh
23-
brew install python
23+
curl -LsSf https://astral.sh/uv/install.sh | sh
2424
```
2525

26-
Create the virtual environment:
26+
Install with development dependencies:
2727

2828
```sh
29-
python3 -m venv .venv
30-
```
31-
32-
Activate the virtual environment:
33-
34-
```sh
35-
source .venv/bin/activate
36-
```
37-
38-
Install the dependencies:
39-
40-
```sh
41-
pip install -e '.[build,docs,lint,test]'
29+
uv sync --all-extras
4230
```
4331

4432
Install pre-commit into your git hooks:
4533

4634
```sh
47-
pre-commit install
35+
uv run pre-commit install
4836
```
4937

5038
## Develop
@@ -74,104 +62,80 @@ Things that will improve the chance that your pull request will be accepted:
7462

7563
## Test
7664

77-
Install the dependencies:
78-
79-
```sh
80-
pip install -e '.[test]'
81-
```
82-
8365
Run the tests:
8466

8567
```sh
86-
pytest
68+
uv run pytest
8769
```
8870

8971
Run the tests with [coverage](https://coverage.readthedocs.io/):
9072

9173
```sh
92-
coverage run -m pytest
74+
uv run coverage run -m pytest
9375
```
9476

9577
Generate a coverage report:
9678

9779
```sh
98-
coverage report
80+
uv run coverage report
9981
```
10082

10183
```sh
102-
coverage html
84+
uv run coverage html
10385
```
10486

10587
## Lint
10688

107-
Install the dependencies:
108-
109-
```sh
110-
pip install -e '.[lint]'
111-
```
112-
11389
Update pre-commit hooks to the latest version:
11490

11591
```sh
116-
pre-commit autoupdate
92+
uv run pre-commit autoupdate
11793
```
11894

11995
Run all pre-commit hooks:
12096

12197
```sh
122-
pre-commit run --all-files
98+
uv run pre-commit run --all-files
12399
```
124100

125101
Lint all files in the current directory:
126102

127103
```sh
128-
ruff check
104+
uv run ruff check --fix
129105
```
130106

131107
Format all files in the current directory:
132108

133109
```sh
134-
ruff format
110+
uv run ruff format
135111
```
136112

137113
## Build
138114

139-
Install the dependencies:
140-
141-
```sh
142-
pip install -e '.[build]'
143-
```
144-
145115
Generate distribution packages:
146116

147117
```sh
148-
python3 -m build
118+
uv build
149119
```
150120

151121
Upload all of the archives under `dist`:
152122

153123
```sh
154-
twine upload --repository testpypi dist/*
124+
uv publish --publish-url https://test.pypi.org/legacy/
155125
```
156126

157127
Install the package:
158128

159129
```sh
160-
pip install --index-url https://test.pypi.org/simple/ --no-deps python-package-template
130+
uv add --index-url https://test.pypi.org/simple/ --no-deps python-package-template
161131
```
162132

163133
## Docs
164134

165-
Install the dependencies:
166-
167-
```sh
168-
pip install -e '.[docs]'
169-
```
170-
171135
Generate the docs with [pdoc](https://pdoc.dev/):
172136

173137
```sh
174-
pdoc src/python_package_template/
138+
uv run pdoc src/python_package_template/
175139
```
176140

177141
## Release

.github/workflows/lint.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,20 @@ jobs:
1111
- name: Checkout repository
1212
uses: actions/checkout@v6
1313

14-
- name: Use Python
15-
uses: actions/setup-python@v6
16-
with:
17-
cache: pip
18-
python-version-file: pyproject.toml
14+
- name: Install uv
15+
uses: astral-sh/setup-uv@v7
1916

2017
- name: Install dependencies
21-
run: pip install -e .[lint]
18+
run: uv sync --extra lint
2219

2320
- name: Type check
24-
run: mypy .
21+
run: uv run mypy .
2522

2623
- name: Run Black
27-
run: black --check .
24+
run: uv run black --check .
2825

2926
- name: Run Ruff
30-
run: ruff check
27+
run: uv run ruff check
3128

3229
- name: Run pre-commit hooks
33-
run: pre-commit run --all-files
30+
run: uv run pre-commit run --all-files

.github/workflows/release-please.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,11 @@ jobs:
3535
- name: Checkout repository
3636
uses: actions/checkout@v6
3737

38-
- name: Use Python
39-
uses: actions/setup-python@v6
40-
with:
41-
python-version-file: pyproject.toml
42-
43-
- name: Install build
44-
run: python -m pip install build
38+
- name: Install uv
39+
uses: astral-sh/setup-uv@v7
4540

4641
- name: Build package
47-
run: python -m build
42+
run: uv build
4843

4944
- name: Publish package to PyPI
50-
uses: pypa/gh-action-pypi-publish@release/v1
45+
run: uv publish

.github/workflows/test.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,17 @@ jobs:
1111
- name: Checkout repository
1212
uses: actions/checkout@v6
1313

14-
- name: Use Python
15-
uses: actions/setup-python@v6
16-
with:
17-
cache: pip
18-
python-version-file: pyproject.toml
14+
- name: Install uv
15+
uses: astral-sh/setup-uv@v7
1916

2017
- name: Install dependencies
21-
run: pip install -e .[test]
18+
run: uv sync --extra test
2219

23-
- name: Run tests and collect coverage
20+
- name: Run tests with coverage
2421
run: |
25-
coverage run -m pytest
26-
coverage report
27-
coverage xml
22+
uv run coverage run -m pytest
23+
uv run coverage report
24+
uv run coverage xml
2825
2926
- name: Upload coverage to Codecov
3027
uses: codecov/codecov-action@v5

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@
99
## Prerequisites
1010

1111
- [Python](https://www.python.org/)
12+
- [uv](https://docs.astral.sh/uv/) or pip
1213

1314
## Install
1415

15-
Install the package:
16+
Install with uv:
17+
18+
```sh
19+
uv add python-package-template
20+
```
21+
22+
Install with pip:
1623

1724
```sh
1825
pip install python-package-template

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ license-files = ["LICENSE"]
1616
dependencies = []
1717

1818
[project.optional-dependencies]
19-
build = [
20-
"build==1.4.0",
21-
"twine==6.2.0",
22-
]
2319
docs = [
2420
"pdoc==16.0.0",
2521
]
@@ -39,6 +35,10 @@ test = [
3935
Homepage = "https://github.com/remarkablemark/python-package-template"
4036
Issues = "https://github.com/remarkablemark/python-package-template/issues"
4137

38+
[build-system]
39+
requires = ["hatchling"]
40+
build-backend = "hatchling.build"
41+
4242
[tool.black]
4343
fast = true
4444

0 commit comments

Comments
 (0)