Skip to content

Commit a420284

Browse files
authored
Use uv as installer (#300)
1 parent 49a89ef commit a420284

File tree

4 files changed

+94
-77
lines changed

4 files changed

+94
-77
lines changed

.github/workflows/check.yml

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,39 +28,39 @@ jobs:
2828
- "3.9"
2929
- "3.8"
3030
os:
31-
- ubuntu-22.04
32-
- windows-2022
33-
- macos-12
31+
- ubuntu-latest
32+
- windows-latest
33+
- macos-latest
3434

3535
steps:
36-
- name: Setup python for tox
36+
- name: Setup python for test ${{ matrix.py }}
3737
uses: actions/setup-python@v5
3838
with:
39-
python-version: "3.12"
39+
python-version: ${{ matrix.py }}
40+
allow-prereleases: true
41+
- name: Install the latest version of uv
42+
uses: astral-sh/setup-uv@v2
43+
with:
44+
enable-cache: true
45+
github-token: ${{ secrets.GITHUB_TOKEN }}
46+
- name: install hatch
47+
run: uv pip install hatch --system
48+
- uses: actions/checkout@v4
49+
with:
50+
fetch-depth: 0
4051
- name: Pick environment to run
4152
run: |
4253
import codecs; import os
4354
py = "${{ matrix.py }}"
4455
py = "test.{}".format(py if py.startswith("pypy") else f"py{py}")
4556
print(f"Picked {py}")
4657
with codecs.open(os.environ["GITHUB_ENV"], mode="a", encoding="utf-8") as file_handler:
47-
file_handler.write("FORCE_COLOR=1\n")
48-
file_handler.write(f"ENV={py}\n")
58+
file_handler.write(f"FORCE_COLOR=1\nENV={py}\n")
4959
shell: python
50-
- name: Install Hatch
51-
uses: pypa/hatch@install
52-
- uses: actions/checkout@v4
53-
with:
54-
fetch-depth: 0
55-
- name: Setup python for test ${{ matrix.py }}
56-
uses: actions/setup-python@v5
57-
with:
58-
python-version: ${{ matrix.py }}
59-
allow-prereleases: true
6060
- name: Setup test environment
6161
run: |
6262
hatch -v env create ${ENV}
63-
hatch run ${ENV}:pip freeze
63+
hatch run ${ENV}:uv pip tree
6464
shell: bash
6565
- name: Run test suite
6666
run: hatch -v run ${ENV}:run
@@ -83,19 +83,24 @@ jobs:
8383

8484
coverage:
8585
name: Combine coverage
86-
runs-on: ubuntu-22.04
86+
runs-on: ubuntu-latest
8787
needs: test
8888
steps:
89-
- uses: actions/checkout@v4
90-
with:
91-
fetch-depth: 0
89+
- name: Let us have colors
90+
run: echo "FORCE_COLOR=true" >> "$GITHUB_ENV"
9291
- uses: actions/setup-python@v5
9392
with:
9493
python-version: "3.12"
95-
- name: Let us have colors
96-
run: echo "FORCE_COLOR=true" >> "$GITHUB_ENV"
97-
- name: Install Hatch
98-
uses: pypa/hatch@install
94+
- name: Install the latest version of uv
95+
uses: astral-sh/setup-uv@v2
96+
with:
97+
enable-cache: true
98+
github-token: ${{ secrets.GITHUB_TOKEN }}
99+
- name: install hatch
100+
run: uv pip install hatch --system
101+
- uses: actions/checkout@v4
102+
with:
103+
fetch-depth: 0
99104
- name: Setup coverage tool
100105
run: |
101106
hatch -v env create coverage
@@ -121,23 +126,28 @@ jobs:
121126
fail-fast: false
122127
matrix:
123128
os:
124-
- ubuntu-22.04
125-
- windows-2022
129+
- ubuntu-latest
130+
- windows-latest
126131
env:
127-
- {"name": "default", "target": "show"}
128-
- {"name": "type", "target": "run"}
129-
- {"name": "docs", "target": "build"}
130-
- {"name": "readme", "target": "run"}
132+
- { "name": "default", "target": "show" }
133+
- { "name": "type", "target": "run" }
134+
- { "name": "docs", "target": "build" }
135+
- { "name": "readme", "target": "run" }
131136
steps:
132-
- uses: actions/checkout@v4
133-
with:
134-
fetch-depth: 0
135137
- name: Setup Python "3.12"
136138
uses: actions/setup-python@v5
137139
with:
138140
python-version: "3.12"
139-
- name: Install Hatch
140-
uses: pypa/hatch@install
141+
- name: Install the latest version of uv
142+
uses: astral-sh/setup-uv@v2
143+
with:
144+
enable-cache: true
145+
github-token: ${{ secrets.GITHUB_TOKEN }}
146+
- name: install hatch
147+
run: uv pip install hatch --system
148+
- uses: actions/checkout@v4
149+
with:
150+
fetch-depth: 0
141151
- name: Setup ${{ matrix.env.name }}
142152
run: |
143153
hatch -v env create ${{ matrix.env.name }}

.github/workflows/release.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55

66
jobs:
77
release:
8-
runs-on: ubuntu-22.04
8+
runs-on: ubuntu-latest
99
environment:
1010
name: release
1111
url: https://pypi.org/p/platformdirs
@@ -16,12 +16,14 @@ jobs:
1616
uses: actions/setup-python@v5
1717
with:
1818
python-version: "3.12"
19+
- name: setup uv for tox
20+
uses: yezz123/setup-uv@v4
1921
- name: Install build
20-
run: python -m pip install build
22+
run: uv pip install build[uv] --system
2123
- uses: actions/checkout@v4
2224
with:
2325
fetch-depth: 0
2426
- name: Build package
25-
run: pyproject-build -s -w . -o dist
27+
run: pyproject-build --installer uv --sdist --wheel . --outdir dist
2628
- name: Publish to PyPI
2729
uses: pypa/[email protected]

.pre-commit-config.yaml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,31 @@ repos:
44
hooks:
55
- id: end-of-file-fixer
66
- id: trailing-whitespace
7+
- repo: https://github.com/python-jsonschema/check-jsonschema
8+
rev: 0.29.2
9+
hooks:
10+
- id: check-github-workflows
11+
args: ["--verbose"]
712
- repo: https://github.com/codespell-project/codespell
813
rev: v2.3.0
914
hooks:
1015
- id: codespell
11-
additional_dependencies: [ "tomli>=2.0.1" ]
12-
- repo: https://github.com/PyCQA/docformatter
13-
rev: v1.7.5
16+
additional_dependencies: ["tomli>=2.0.1"]
17+
- repo: https://github.com/tox-dev/pyproject-fmt
18+
rev: "2.2.3"
1419
hooks:
15-
- id: docformatter
16-
additional_dependencies: [ "tomli>=2.0.1" ]
17-
args: [ "--in-place", "--config", "./pyproject.toml" ]
20+
- id: pyproject-fmt
1821
- repo: https://github.com/astral-sh/ruff-pre-commit
19-
rev: "v0.6.3"
22+
rev: "v0.6.4"
2023
hooks:
2124
- id: ruff-format
2225
- id: ruff
23-
args: [ "--fix", "--unsafe-fixes", "--exit-non-zero-on-fix" ]
24-
- repo: https://github.com/tox-dev/pyproject-fmt
25-
rev: "2.2.1"
26+
args: ["--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"]
27+
- repo: https://github.com/rbubley/mirrors-prettier
28+
rev: "v3.3.3"
2629
hooks:
27-
- id: pyproject-fmt
28-
additional_dependencies: ["tox>=4.14.2"]
30+
- id: prettier
31+
args: ["--print-width=120", "--prose-wrap=always"]
2932
- repo: meta
3033
hooks:
3134
- id: check-hooks-apply

pyproject.toml

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
build-backend = "hatchling.build"
33
requires = [
44
"hatch-vcs>=0.4",
5-
"hatchling>=1.18",
5+
"hatchling>=1.25",
66
]
77

88
[project]
@@ -46,20 +46,20 @@ dynamic = [
4646
"version",
4747
]
4848
optional-dependencies.docs = [
49-
"furo>=2023.9.10",
50-
"proselint>=0.13",
51-
"sphinx>=7.2.6",
52-
"sphinx-autodoc-typehints>=1.25.2",
49+
"furo>=2024.8.6",
50+
"proselint>=0.14",
51+
"sphinx>=8.0.2",
52+
"sphinx-autodoc-typehints>=2.4",
5353
]
5454
optional-dependencies.test = [
5555
"appdirs==1.4.4",
5656
"covdefaults>=2.3",
57-
"pytest>=7.4.3",
58-
"pytest-cov>=4.1",
59-
"pytest-mock>=3.12",
57+
"pytest>=8.3.2",
58+
"pytest-cov>=5",
59+
"pytest-mock>=3.14",
6060
]
6161
optional-dependencies.type = [
62-
"mypy>=1.8",
62+
"mypy>=1.11.2",
6363
]
6464
urls.Documentation = "https://platformdirs.readthedocs.io"
6565
urls.Homepage = "https://github.com/platformdirs/platformdirs"
@@ -76,19 +76,21 @@ build.targets.sdist.include = [
7676
version.source = "vcs"
7777

7878
[tool.hatch.envs.default]
79+
installer = "uv"
7980
description = "Development environment"
8081
features = [
8182
"test",
8283
"docs",
8384
"type",
8485
]
8586
scripts = { show = [
86-
"python -m pip list --format=columns",
87+
"uv pip tree",
8788
'python -c "import sys; print(sys.executable)"',
8889
] }
8990

9091
[tool.hatch.envs.test]
9192
template = "test"
93+
installer = "uv"
9294
# dev-mode = false # cannot enable this until https://github.com/pypa/hatch/issues/1237
9395
description = "Run the test suite"
9496
matrix = [
@@ -105,7 +107,9 @@ matrix = [
105107
features = [
106108
"test",
107109
]
108-
env-vars = { COVERAGE_FILE = "report/.coverage.{matrix:python}", COVERAGE_PROCESS_START = "pyproject.toml", _COVERAGE_SRC = "src/platformdirs" }
110+
env-vars.COVERAGE_FILE = "report/.coverage.{matrix:python}"
111+
env-vars.COVERAGE_PROCESS_START = "pyproject.toml"
112+
env-vars._COVERAGE_SRC = "src/platformdirs"
109113
[tool.hatch.envs.test.scripts]
110114
run = [
111115
"""
@@ -118,11 +122,12 @@ run = [
118122

119123
[tool.hatch.envs.coverage]
120124
template = "coverage"
125+
installer = "uv"
121126
description = "combine coverage files and generate diff"
122127
dependencies = [
123128
"covdefaults>=2.3",
124-
"coverage[toml]>=7.3.2",
125-
"diff-cover>=8.0.1",
129+
"coverage[toml]>=7.6.1",
130+
"diff-cover>=9.2",
126131
]
127132
env-vars = { COVERAGE_FILE = "report/.coverage" }
128133
[tool.hatch.envs.coverage.scripts]
@@ -136,6 +141,7 @@ run = [
136141

137142
[tool.hatch.envs.type]
138143
template = "type"
144+
installer = "uv"
139145
description = "Run the type checker"
140146
python = "3.12"
141147
dev-mode = false
@@ -150,18 +156,20 @@ scripts = { run = [
150156

151157
[tool.hatch.envs.fix]
152158
template = "fix"
159+
installer = "uv"
153160
description = "Run the pre-commit tool to lint and autofix issues"
154161
python = "3.12"
155162
detached = true
156163
dependencies = [
157-
"pre-commit>=3.6",
164+
"pre-commit-uv>=4.1",
158165
]
159166
scripts = { "run" = [
160167
"pre-commit run --all-files --show-diff-on-failure",
161168
] }
162169

163170
[tool.hatch.envs.docs]
164171
template = "docs"
172+
installer = "uv"
165173
description = "Build documentation using Sphinx"
166174
python = "3.12"
167175
dev-mode = false
@@ -178,15 +186,16 @@ build = [
178186

179187
[tool.hatch.envs.readme]
180188
template = "readme"
189+
installer = "uv"
181190
description = "check that the long description is valid"
182191
python = "3.12"
183192
dependencies = [
184-
"build[virtualenv]>=1.0.3",
185-
"twine>=4.0.2",
186-
"check-wheel-contents>=0.6.0",
193+
"build[uv]>=1.2.2",
194+
"twine>=5.1.1",
195+
"check-wheel-contents>=0.6",
187196
]
188197
scripts = { "run" = [
189-
"python -m build -o dist",
198+
"pyproject-build --installer uv -o dist",
190199
"twine check dist/*.whl dist/*.tar.gz",
191200
"check-wheel-contents dist",
192201
] }
@@ -232,13 +241,6 @@ builtin = "clear,usage,en-GB_to_en-US"
232241
count = true
233242
quiet-level = 3
234243

235-
[tool.docformatter]
236-
blank = true
237-
recursive = true
238-
pre-summary-newline = true
239-
wrap-descriptions = 120
240-
wrap-summaries = 120
241-
242244
[tool.pyproject-fmt]
243245
max_supported_python = "3.13"
244246

0 commit comments

Comments
 (0)