Skip to content

Commit aa2f154

Browse files
Merge pull request #98 from remarkablemark/build/uv
build(pyproject): migrate to uv
2 parents ff05038 + 58bba92 commit aa2f154

File tree

10 files changed

+102
-140
lines changed

10 files changed

+102
-140
lines changed

.github/CONTRIBUTING.md

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,22 @@ cd python-cli-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+
brew install uv
2424
```
2525

26-
Create the virtual environment:
26+
Install 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,38 +62,38 @@ Things that will improve the chance that your pull request will be accepted:
7462

7563
## Test
7664

77-
Install the dependencies:
65+
Install test dependencies:
7866

7967
```sh
80-
pip install -e '.[test]'
68+
uv sync --extra test
8169
```
8270

8371
Run the tests:
8472

8573
```sh
86-
pytest
74+
uv run pytest
8775
```
8876

8977
Run the tests with [coverage](https://coverage.readthedocs.io/):
9078

9179
```sh
92-
coverage run -m pytest
80+
uv run coverage run -m pytest
9381
```
9482

9583
Generate a coverage report:
9684

9785
```sh
98-
coverage report
86+
uv run coverage report
9987
```
10088

10189
```sh
102-
coverage html
90+
uv run coverage html
10391
```
10492

105-
Install the package with [pipx](https://pipx.pypa.io/):
93+
Install the package with [uv](https://docs.astral.sh/uv/):
10694

10795
```sh
108-
pipx install . --force
96+
uv tool install . --force
10997
```
11098

11199
Test the command:
@@ -116,80 +104,88 @@ python-cli-template --help
116104

117105
## Lint
118106

119-
Install the dependencies:
107+
Install lint dependencies:
120108

121109
```sh
122-
pip install -e '.[lint]'
110+
uv sync --extra lint
123111
```
124112

125113
Update pre-commit hooks to the latest version:
126114

127115
```sh
128-
pre-commit autoupdate
116+
uv run pre-commit autoupdate
129117
```
130118

131119
Run all pre-commit hooks:
132120

133121
```sh
134-
pre-commit run --all-files
122+
uv run pre-commit run --all-files
123+
```
124+
125+
Lint all files:
126+
127+
```sh
128+
uv run ruff check # --fix
135129
```
136130

137-
Lint all files in the current directory:
131+
Format all files:
138132

139133
```sh
140-
ruff check
134+
uv run ruff format
141135
```
142136

143-
Format all files in the current directory:
137+
## Run
138+
139+
Run the CLI:
144140

145141
```sh
146-
ruff format
142+
uv run python-cli-template
147143
```
148144

149145
## Build
150146

151-
Install the dependencies:
147+
Install build dependencies:
152148

153149
```sh
154-
pip install -e '.[build]'
150+
uv sync --extra build
155151
```
156152

157153
Generate the distribution packages:
158154

159155
```sh
160-
python3 -m build
156+
uv build
161157
```
162158

163159
Upload all of the archives under `dist`:
164160

165161
```sh
166-
twine upload --repository testpypi dist/*
162+
uv publish --repository testpypi
167163
```
168164

169165
Install the package:
170166

171167
```sh
172-
pip install --index-url https://test.pypi.org/simple/ --no-deps python-cli-template
168+
uv tool install --index-url testpypi python-cli-template
173169
```
174170

175171
Bundle the package with [PyInstaller](https://pyinstaller.org/):
176172

177173
```sh
178-
pyinstaller src/python-cli-template/cli.py --name python-cli-template
174+
uv run pyinstaller python_cli_template.cli --name python-cli-template
179175
```
180176

181177
## Docs
182178

183-
Install the dependencies:
179+
Install docs dependencies:
184180

185181
```sh
186-
pip install -e '.[docs]'
182+
uv sync --extra docs
187183
```
188184

189185
Generate the docs with [pdoc](https://pdoc.dev/):
190186

191187
```sh
192-
pdoc src/python_cli_template/
188+
uv run pdoc src/python_cli_template/
193189
```
194190

195191
## Release

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
version: 2
77
updates:
8-
- package-ecosystem: 'pip'
8+
- package-ecosystem: 'uv'
99
directory: '/'
1010
schedule:
1111
interval: 'daily'

.github/workflows/docs.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,14 @@ 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 .[docs]
18+
run: uv sync --extra docs
2219

2320
- name: Build docs
24-
run: pdoc src/python_cli_template/ -o docs
21+
run: uv run pdoc src/python_cli_template/ -o docs
2522

2623
- name: Deploy
2724
if: github.ref_name == 'master'

.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
33-
run: pre-commit run --all-files
30+
run: uv run pre-commit run --all-files

.github/workflows/release-please.yml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,14 @@ jobs:
3636
- name: Checkout repository
3737
uses: actions/checkout@v6
3838

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

4742
- name: Build package
48-
run: python -m build
43+
run: uv build
4944

5045
- name: Publish package to PyPI
51-
uses: pypa/gh-action-pypi-publish@release/v1
46+
run: uv publish
5247

5348
upload:
5449
needs: release
@@ -64,16 +59,14 @@ jobs:
6459
- name: Checkout repository
6560
uses: actions/checkout@v6
6661

67-
- name: Use Python
68-
uses: actions/setup-python@v6
69-
with:
70-
python-version-file: pyproject.toml
62+
- name: Install uv
63+
uses: astral-sh/setup-uv@v7
7164

7265
- name: Install dependencies
73-
run: pip install -e '.[build]'
66+
run: uv sync --extra build
7467

7568
- name: Build executable
76-
run: pyinstaller src/python_cli_template/cli.py --name python-cli-template --onefile --clean
69+
run: uv run pyinstaller python_cli_template.cli --name python-cli-template --onefile --clean
7770

7871
- name: Compress executable
7972
shell: bash

.github/workflows/test.yml

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,53 +11,23 @@ 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

2320
- name: Run tests and collect 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
3128
with:
3229
token: ${{ secrets.CODECOV_TOKEN }}
3330

34-
install:
35-
runs-on: ubuntu-latest
36-
steps:
37-
- name: Checkout repository
38-
uses: actions/checkout@v6
39-
40-
- name: Use Python
41-
uses: actions/setup-python@v6
42-
with:
43-
cache: pip
44-
python-version-file: pyproject.toml
45-
46-
- name: Install package
47-
run: pipx install .
48-
49-
- name: Check version
50-
run: |
51-
version=$(grep version src/python_cli_template/__init__.py | cut -d'"' -f 2)
52-
echo $version
53-
python-cli-template --version
54-
set -e
55-
[[ $(python-cli-template --version) == $version ]]
56-
[[ $(python-cli-template -v) == $version ]]
57-
58-
- name: Get help
59-
run: python-cli-template --help
60-
6131
integration:
6232
runs-on: ubuntu-latest
6333
strategy:
@@ -69,14 +39,22 @@ jobs:
6939
- name: Checkout repository
7040
uses: actions/checkout@v6
7141

72-
- name: Use Python
73-
uses: actions/setup-python@v6
74-
with:
75-
cache: pip
76-
python-version-file: pyproject.toml
42+
- name: Install uv
43+
uses: astral-sh/setup-uv@v7
7744

78-
- name: Install package
79-
run: pipx install .
45+
- name: Install tool
46+
run: uv tool install .
8047

8148
- name: Run command
8249
run: ${{ matrix.command }}
50+
51+
- name: Get version
52+
run: |
53+
VERSION=$(grep version src/python_cli_template/__init__.py | cut -d'"' -f 2)
54+
echo "VERSION=$VERSION" >> $GITHUB_ENV
55+
56+
- name: Check version
57+
run: |
58+
set -e
59+
[[ $(python-cli-template --version) == "$VERSION" ]]
60+
[[ $(python-cli-template -v) == "$VERSION" ]]

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ ipython_config.py
9898
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
9999
# This is especially recommended for binary packages to ensure reproducibility, and is more
100100
# commonly ignored for libraries.
101-
#uv.lock
101+
uv.lock
102102

103103
# poetry
104104
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.

0 commit comments

Comments
 (0)