Skip to content

Commit 41bd4e8

Browse files
authored
Merge pull request #13 from Parskatt/johan/pypi
add actions for pypi publishing and some simple tests
2 parents c21f42b + 565b6b0 commit 41bd4e8

File tree

7 files changed

+214
-2
lines changed

7 files changed

+214
-2
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: uv-build
2+
description: Build the project with uv and run smoke tests
3+
inputs:
4+
python-version:
5+
description: Python version to install
6+
required: true
7+
runs:
8+
using: composite
9+
steps:
10+
- name: Install uv
11+
uses: astral-sh/setup-uv@v6
12+
- name: Install Python
13+
shell: bash
14+
run: uv python install ${{ inputs.python-version }}
15+
- name: Build
16+
shell: bash
17+
run: uv build
18+
- name: Smoke test (wheel)
19+
shell: bash
20+
run: uv run --isolated --no-project --with dist/*.whl tests/smoke_test.py
21+
- name: Smoke test (source distribution)
22+
shell: bash
23+
run: uv run --isolated --no-project --with dist/*.tar.gz tests/smoke_test.py

.github/workflows/build.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
jobs:
11+
run:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v5
19+
- name: Build and smoke test
20+
uses: ./.github/actions/uv-build
21+
with:
22+
python-version: ${{ matrix.python-version }}

.github/workflows/publish.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: PyPI Publish
2+
3+
on:
4+
push:
5+
tags:
6+
# Publish on any tag starting with a `v`, e.g., v0.1.0
7+
- v*
8+
workflow_dispatch:
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v5
18+
- name: Build and smoke test
19+
uses: ./.github/actions/uv-build
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
23+
publish:
24+
runs-on: ubuntu-latest
25+
needs: build
26+
environment:
27+
name: pypi
28+
permissions:
29+
id-token: write
30+
contents: read
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v5
34+
- name: Build and smoke test
35+
uses: ./.github/actions/uv-build
36+
with:
37+
python-version: '3.12'
38+
- name: Publish
39+
run: uv publish

pyproject.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,18 @@ dev = [
2323
"ruff>=0.9.10",
2424
"tqdm>=4.67.1",
2525
"wandb>=0.19.8",
26+
"pytest>=8.4.2",
2627
]
2728

2829

2930
[build-system]
30-
requires = ["hatchling"]
31-
build-backend = "hatchling.build"
31+
requires = ["uv_build>=0.8.14,<0.9.0"]
32+
build-backend = "uv_build"
33+
34+
35+
[tool.uv.build-backend]
36+
module-name = "dad"
37+
module-root = ""
3238

3339

3440
[tool.uv.sources]

tests/smoke_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import dad
2+
3+
4+
def test_smoke():
5+
model = dad.load_DaD()
6+
assert model is not None

tests/vis_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import dad
2+
from dad.utils import visualize_keypoints
3+
4+
5+
def test_vis():
6+
detector = dad.load_DaD()
7+
img_path = "assets/0015_A.jpg"
8+
vis_path = "vis/0015_A_dad.jpg"
9+
visualize_keypoints(img_path, vis_path, detector, num_keypoints = 512)

uv.lock

Lines changed: 107 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)