Skip to content

Commit 12d62ee

Browse files
Migrate from hatch to uv (#665)
1 parent d85517a commit 12d62ee

File tree

6 files changed

+2712
-53
lines changed

6 files changed

+2712
-53
lines changed

.github/workflows/release.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ jobs:
1616
- uses: actions/checkout@v3
1717
with:
1818
fetch-depth: 0
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v6
1921
- name: Build package
20-
run: pipx install hatch && hatch build
22+
run: uv build
2123
- name: Publish kr8s
2224
uses: pypa/gh-action-pypi-publish@release/v1
2325
publish-kubectl-ng:

.github/workflows/test-kr8s.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ jobs:
4343
- uses: actions/setup-python@v2
4444
with:
4545
python-version: ${{ matrix.python-version }}
46-
- name: Install hatch
47-
run: pip install hatch
46+
- name: Install uv
47+
uses: astral-sh/setup-uv@v6
4848
- name: Run tests
4949
env:
5050
KUBERNETES_VERSION: ${{ matrix.kubernetes-version }}
51-
run: hatch run test:ci
51+
run: uv run task test-ci
5252
- name: Upload coverage reports to Codecov
5353
uses: codecov/codecov-action@v4
5454
env:

.readthedocs.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ build:
44
os: "ubuntu-22.04"
55
tools:
66
python: "3.10"
7-
commands:
8-
- pip install hatch
9-
- hatch run docs:rtd
7+
jobs:
8+
pre_create_environment:
9+
- asdf plugin add uv
10+
- asdf install uv latest
11+
- asdf global uv latest
12+
create_environment:
13+
- uv venv "${READTHEDOCS_VIRTUALENV_PATH}"
14+
install:
15+
- UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv sync --frozen --dev
16+
build:
17+
html:
18+
- UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv run task docs-rtd

docs/contributing.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ Contributions are very welcome. Check out our [open issues on GitHub](https://gi
44

55
## Development environment
66

7-
We recommend you develop `kr8s` inside a virtual environment. We use [hatch](https://hatch.pypa.io/) for builds, virtual environments and task running, but you can use whatever you prefer.
7+
We recommend you develop `kr8s` inside a virtual environment. We use [uv](https://github.com/astral-sh/uv) for builds, virtual environments and task running, but you can use whatever you prefer.
88

99
```bash
10-
pip install hatch
11-
hatch shell # Creates the hatch venv and activates it
10+
pip install uv
11+
uv sync --dev
1212
```
1313

1414
But there are many different tools out there so feel free to use whichever you prefer and install `kr8s` in development mode.
@@ -23,7 +23,7 @@ pip install -e .
2323
Tests in `kr8s` are run with `pytest`. To handle testing again Kubernetes we also use [kind](https://kind.sigs.k8s.io/) via the [`pytest-kind`](https://pypi.org/project/pytest-kind/) plugin. Kind launches a Kubernetes cluster inside a single Docker container which is great for local development. All setup is handles via fixtures so as long as you have `docker` you can run the tests.
2424

2525
```bash
26-
hatch run test:run
26+
uv run task test
2727
```
2828

2929
Or you can install the test dependencies and invoke `pytest` yourself.
@@ -38,7 +38,7 @@ pytest kr8s
3838
Documentation is built with [Sphinx](https://www.sphinx-doc.org/en/master/). You can build the docs locally.
3939

4040
```bash
41-
hatch run docs:serve
41+
uv run task docs-serve
4242
```
4343

4444
Or you can install the docs dependencies and invoke `sphinx-build` or `sphinx-autobuild` yourself.

pyproject.toml

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,6 @@ dependencies = [
2020
"python-box>=7.0.1",
2121
"typing_extensions>=4.12.2",
2222
]
23-
[project.optional-dependencies]
24-
test = [
25-
"pytest>=7.2.2",
26-
"pytest-asyncio>=0.20.3",
27-
"pytest-kind>=22.11.1",
28-
"pytest-timeout>=2.1.0",
29-
"pytest-rerunfailures>=11.1.2",
30-
"pytest-cov>=4.0.0",
31-
"trio>=0.22.0",
32-
"types-pyyaml>=6.0",
33-
"lightkube>=0.13.0",
34-
"kubernetes>=26.1.0",
35-
"pykube-ng>=23.6.0",
36-
"kubernetes-asyncio>=24.2.3",
37-
"kubernetes-validate>=1.28.0",
38-
]
39-
docs = [
40-
"sphinx>=5.3.0",
41-
"sphinx-autobuild>=2021.3.14",
42-
"myst-parser>=1.0.0",
43-
"furo>=2023.3.27",
44-
"sphinx-copybutton>=0.5.1",
45-
"sphinx-design>=0.3.0",
46-
"sphinxcontrib-mermaid>=0.8.1",
47-
"sphinx-autoapi>=2.1.0",
48-
]
4923

5024
[project.urls]
5125
Documentation = "https://docs.kr8s.org/en/stable"
@@ -61,21 +35,12 @@ reruns = 0
6135
reruns_delay = 1
6236
asyncio_mode = "auto"
6337

64-
[tool.hatch.envs.test]
65-
features = ["test"]
66-
67-
[tool.hatch.envs.test.scripts]
68-
default = "pytest kr8s"
69-
run = "pytest kr8s"
70-
ci = "pytest kr8s --reruns=3"
71-
72-
[tool.hatch.envs.docs]
73-
features = ["docs"]
74-
75-
[tool.hatch.envs.docs.scripts]
76-
build = "sphinx-build docs/ docs/_build/"
77-
rtd = "sphinx-build docs/ _readthedocs/html/"
78-
serve = "sphinx-autobuild docs docs/_build --ignore 'docs/autoapi/**/*' --host 0.0.0.0"
38+
[tool.taskipy.tasks]
39+
test = "pytest kr8s"
40+
test-ci = "pytest kr8s --reruns=3"
41+
docs = "sphinx-build docs/ docs/_build/"
42+
docs-rtd = "sphinx-build docs/ _readthedocs/html/"
43+
docs-serve = "sphinx-autobuild docs docs/_build --ignore 'docs/autoapi/**/*' --host 0.0.0.0"
7944

8045
[tool.hatch.build.hooks.vcs]
8146
version-file = "kr8s/_version.py"
@@ -90,6 +55,32 @@ source = "vcs"
9055
requires = ["hatchling", "hatch-vcs"]
9156
build-backend = "hatchling.build"
9257

58+
[dependency-groups]
59+
dev = [
60+
"pytest>=7.2.2",
61+
"pytest-asyncio>=0.20.3",
62+
"pytest-kind>=22.11.1",
63+
"pytest-timeout>=2.1.0",
64+
"pytest-rerunfailures>=11.1.2",
65+
"pytest-cov>=4.0.0",
66+
"trio>=0.22.0",
67+
"types-pyyaml>=6.0",
68+
"lightkube>=0.13.0",
69+
"kubernetes>=26.1.0",
70+
"pykube-ng>=23.6.0",
71+
"kubernetes-asyncio>=24.2.3",
72+
"kubernetes-validate>=1.28.0",
73+
"sphinx>=5.3.0",
74+
"sphinx-autobuild>=2021.3.14",
75+
"myst-parser>=1.0.0",
76+
"furo>=2023.3.27",
77+
"sphinx-copybutton>=0.5.1",
78+
"sphinx-design>=0.3.0",
79+
"sphinxcontrib-mermaid>=0.8.1",
80+
"sphinx-autoapi>=2.1.0",
81+
"taskipy>=1.14.1",
82+
]
83+
9384
[tool.ruff]
9485
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
9586
select = ["D", "E", "W", "F", "I", "N", "B"]

0 commit comments

Comments
 (0)