Skip to content

Commit b4f2c26

Browse files
committed
Switch from pip to uv
1 parent 82c77bc commit b4f2c26

File tree

8 files changed

+1981
-84
lines changed

8 files changed

+1981
-84
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,19 @@ name: Run CI/CD pipeline
22

33
on:
44
push:
5-
branches: "*"
5+
branches: ["*"]
66
pull_request:
77
workflow_dispatch:
88

99
permissions:
1010
contents: read
1111

1212
jobs:
13-
setup:
14-
runs-on: ubuntu-latest
15-
outputs:
16-
is-main-branch: |-
17-
${{
18-
github.event_name != 'pull_request' && contains(
19-
fromJson('["main", "1.19"]'),
20-
(github.head_ref || github.ref_name)
21-
)
22-
}}
23-
steps:
24-
- name: Print message so the workflow isn't invalid
25-
run: 'echo "HexDebug <3 HexBug"'
26-
2713
build-docs:
28-
needs: setup
29-
uses: hexdoc-dev/actions/.github/workflows/hexdoc.yml@v1
14+
uses: ./.github/workflows/docs.yml
3015
permissions:
3116
contents: write
3217
pages: read
33-
secrets:
34-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3518
with:
36-
python-version: 3.11
37-
deploy-pages: ${{ needs.setup.outputs.is-main-branch == 'true' }}
19+
deploy-pages: ${{ github.event_name != 'pull_request' && contains(fromJson(vars.HEXDOC_BRANCHES), github.ref_name) }}
3820
release: false

.github/workflows/docs.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: "[Reusable] Build and push the web book"
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
deploy-pages:
7+
type: boolean
8+
required: true
9+
release:
10+
type: boolean
11+
required: true
12+
description: Whether the book should be built in preparation for a release.
13+
14+
jobs:
15+
build-hexdoc:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
pages: read
20+
outputs:
21+
pages-url: ${{ steps.build.outputs.pages-url }}
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- uses: actions/setup-python@v6
26+
with:
27+
python-version-file: .python-version
28+
29+
- uses: astral-sh/setup-uv@v6
30+
with:
31+
activate-environment: true
32+
enable-cache: true
33+
34+
- name: Sync dependencies
35+
run: uv sync --frozen --no-dev
36+
37+
- id: build
38+
uses: hexdoc-dev/actions/build@v1
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
with:
42+
release: ${{ inputs.release }}
43+
44+
deploy-pages:
45+
needs: build-hexdoc
46+
if: inputs.deploy-pages
47+
runs-on: ubuntu-latest
48+
concurrency:
49+
group: hexdoc-deploy-pages
50+
cancel-in-progress: false
51+
permissions:
52+
contents: write
53+
steps:
54+
- uses: actions/checkout@v4
55+
56+
- uses: actions/setup-python@v6
57+
with:
58+
python-version-file: .python-version
59+
60+
- uses: astral-sh/setup-uv@v6
61+
with:
62+
activate-environment: true
63+
enable-cache: true
64+
65+
- name: Sync dependencies
66+
run: uv sync --frozen --no-dev
67+
68+
- name: Merge new hexdoc build into existing book
69+
uses: hexdoc-dev/actions/merge@v1
70+
with:
71+
release: ${{ inputs.release }}
72+
site-url: ${{ needs.build-hexdoc.outputs.pages-url }}
73+
74+
# if you want to add extra things to your website (eg. Javadoc/Dokka), add it to _site/dst/docs here
75+
76+
- name: Deploy to Pages
77+
uses: hexdoc-dev/actions/deploy-pages@v1
78+
with:
79+
merge: false
80+
release: ${{ inputs.release }}

.github/workflows/release.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ name: Release
22

33
on:
44
push:
5-
tags: 'v[0-9]+.[0-9]+.[0-9]+*'
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+*'
67
workflow_dispatch:
78
inputs:
8-
publish-docs:
9-
description: Publish the web book
10-
type: boolean
11-
default: false
129
dry-run:
1310
description: Perform a dry run
1411
type: boolean
@@ -22,20 +19,17 @@ permissions:
2219

2320
jobs:
2421
build-docs:
25-
uses: hexdoc-dev/actions/.github/workflows/hexdoc.yml@v1
22+
uses: ./.github/workflows/docs.yml
2623
permissions:
2724
contents: write
2825
pages: read
29-
secrets:
30-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3126
with:
32-
python-version: 3.11
33-
deploy-pages: ${{ github.event_name == 'push' || inputs.publish-docs && !inputs.dry-run }}
27+
deploy-pages: ${{ github.event_name == 'push' || !inputs.dry-run }}
3428
release: true
3529

36-
publish-docs:
30+
publish-pypi:
3731
needs: build-docs
38-
if: github.event_name == 'push' || inputs.publish-docs && !inputs.dry-run
32+
if: github.event_name == 'push' || !inputs.dry-run
3933
runs-on: ubuntu-latest
4034
environment:
4135
name: pypi

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

doc/README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,14 @@ For example:
1515

1616
## Setup
1717

18-
Install Python 3.11 and Node 18 (20+ is **not** currently supported).
18+
Install [uv](https://docs.astral.sh/uv/getting-started/installation/), then:
1919

2020
```sh
21-
python3.11 -m venv venv
21+
uv sync
2222

23-
.\venv\Scripts\activate # Windows
24-
. venv/bin/activate.fish # fish
25-
source venv/bin/activate # everything else
26-
27-
# run from the repo root, not doc/
28-
pip install -e .[dev]
23+
.\.venv\Scripts\activate # Windows
24+
. .venv/bin/activate.fish # fish
25+
source .venv/bin/activate # everything else
2926
```
3027

3128
## Usage
@@ -39,6 +36,9 @@ GITHUB_PAGES_URL=https://hexdebug.hexxy.media
3936

4037
Useful commands:
4138
```sh
39+
# update your Python environment and lockfile if you added new dependencies
40+
uv sync
41+
4242
# show help
4343
hexdoc -h
4444

@@ -48,9 +48,8 @@ nodemon --config doc/nodemon.json
4848
# render and serve the web book
4949
hexdoc serve
5050

51-
# export, render, and merge the web book
52-
hexdoc export
53-
hexdoc render
51+
# build and merge the web book
52+
hexdoc build
5453
hexdoc merge
5554

5655
# start the Python interpreter with some extra local variables

doc/nodemon.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
],
88
"ignore": ["**/generated/**"],
99
"ext": "jinja,html,css,js,ts,toml,json,json5,py",
10-
"exec": "hexdoc serve"
10+
"exec": "uv run hexdoc serve"
1111
}

pyproject.toml

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ authors = [
1515
{ name="object-Object" },
1616
]
1717
keywords = ["hexdoc"]
18-
requires-python = ">=3.11"
18+
requires-python = ">=3.12"
1919
dynamic = ["version", "dependencies", "optional-dependencies"]
2020

2121
[project.urls]
2222
Homepage = "https://hexdebug.hexxy.media"
2323
Source = "https://github.com/object-Object/HexDebug"
2424

25-
# Gradle version/deps
25+
# project version
2626

2727
[tool.hatch.version]
2828
scheme = "gradle"
@@ -31,16 +31,20 @@ py-path = "doc/src/hexdoc_hexdebug/__version__.py"
3131
key = "modVersion"
3232
gradle-version-regex = { regex='^(.+?)(-.+)?$', repl='\1.{minecraftVersion}\2' }
3333

34+
# Python dependencies
35+
36+
# required
3437
[tool.hatch.metadata.hooks.version-catalog]
3538
dependencies = [
3639
"hexdoc>=1!0.1.0a34",
3740
{ package="hexdoc-hexcasting", op="~=", py-version="1.0", key="hexcasting" },
3841
{ package="hexdoc-ioticblocks", op=">=", py-version="1.0", key="ioticblocks" },
3942
]
4043

41-
[tool.hatch.metadata.hooks.version-catalog.optional-dependencies]
44+
# dev-only
45+
[dependency-groups]
4246
dev = [
43-
"ruff~=0.13.1",
47+
"ruff",
4448
]
4549

4650
# directory inclusion
@@ -58,26 +62,26 @@ artifacts = [
5862
[tool.hatch.build.targets.wheel]
5963
sources = ["doc/src"]
6064

61-
# hexdoc entry points
65+
# hexdoc entry point
6266

6367
[project.entry-points.hexdoc]
6468
hexdebug = "hexdoc_hexdebug._hooks:HexDebugPlugin"
6569

6670
# linting/formatting
6771

6872
[tool.ruff]
73+
preview = true
6974
extend-exclude = [
70-
"venv",
75+
"**/venv",
7176
"**/.*",
72-
"**/node_modules",
7377
"**/__pycache__",
7478
]
7579

7680
[tool.ruff.lint]
77-
preview = true
7881
extend-select = [
7982
"I", # import sorting
8083
"RUF022", # __all__ sorting
84+
"TID252", # ban relative imports
8185
]
8286
extend-ignore = [
8387
# covered by Pyright
@@ -89,62 +93,50 @@ extend-ignore = [
8993
[tool.ruff.lint.isort]
9094
combine-as-imports = true
9195

96+
[tool.ruff.lint.flake8-tidy-imports]
97+
ban-relative-imports = "parents"
98+
99+
# type checking
100+
92101
[tool.pyright]
93-
pythonVersion = "3.11"
102+
pythonVersion = "3.12"
94103
pythonPlatform = "All"
95104

96105
include = ["doc/src"]
97106
extraPaths = ["doc/src"]
98-
exclude = [
99-
"noxfile.py",
100-
"**/venv",
101-
"**/.*",
102-
"**/node_modules",
103-
"**/__pycache__",
104-
]
105107

106108
typeCheckingMode = "standard"
107109

108110
strictDictionaryInference = true
109111
strictListInference = true
110112
strictSetInference = true
111113

112-
reportAssertAlwaysTrue = "error"
113114
reportConstantRedefinition = "error"
114-
reportDeprecated = "error"
115-
reportDuplicateImport = "error"
116-
reportFunctionMemberAccess = "error"
117-
reportIncompatibleMethodOverride = "error"
118-
reportIncompatibleVariableOverride = "error"
119115
reportIncompleteStub = "error"
120116
reportInconsistentConstructor = "error"
121-
reportInvalidStringEscapeSequence = "error"
122117
reportInvalidStubStatement = "error"
123-
reportInvalidTypeVarUse = "error"
124-
reportMatchNotExhaustive = "error"
125-
reportMissingParameterType = "error"
126-
reportMissingTypeStubs = "error"
127-
reportOverlappingOverload = "error"
128-
reportSelfClsParameterName = "error"
129-
reportTypeCommentUsage = "error"
130-
reportUnknownParameterType = "error"
131-
reportUnnecessaryCast = "error"
132-
reportUnnecessaryContains = "error"
133-
reportUnsupportedDunderAll = "error"
134-
reportUntypedBaseClass = "error"
135-
reportUntypedClassDecorator = "error"
136-
reportUntypedFunctionDecorator = "error"
137-
reportUntypedNamedTuple = "error"
138-
reportWildcardImportFromLibrary = "error"
139118

119+
reportDeprecated = "warning"
120+
reportDuplicateImport = "warning"
121+
reportMatchNotExhaustive = "warning"
122+
reportMissingParameterType = "warning"
140123
reportMissingTypeArgument = "warning"
124+
reportMissingTypeStubs = "warning"
141125
reportPrivateUsage = "warning"
126+
reportTypeCommentUsage = "warning"
142127
reportUnknownArgumentType = "warning"
143128
reportUnknownLambdaType = "warning"
144129
reportUnknownMemberType = "warning"
130+
reportUnknownParameterType = "warning"
145131
reportUnknownVariableType = "warning"
132+
reportUnnecessaryCast = "warning"
146133
reportUnnecessaryComparison = "warning"
134+
reportUnnecessaryContains = "warning"
147135
reportUnnecessaryIsInstance = "warning"
136+
reportUntypedBaseClass = "warning"
137+
reportUntypedClassDecorator = "warning"
138+
reportUntypedFunctionDecorator = "warning"
139+
reportUntypedNamedTuple = "warning"
148140
reportUnusedClass = "warning"
149141
reportUnusedExpression = "warning"
150142
reportUnusedFunction = "warning"

0 commit comments

Comments
 (0)