Skip to content

Commit 8f8e9c5

Browse files
chore: configure uv for libraries
1 parent 09f0886 commit 8f8e9c5

10 files changed

Lines changed: 63 additions & 386 deletions

File tree

.github/workflows/publish.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Publish package
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
tests:
9+
uses: ./.github/workflows/test.yml
10+
secrets: inherit
11+
12+
deploy:
13+
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v6
21+
with:
22+
enable-cache: true
23+
24+
- name: Publish package to internal package index
25+
run: |
26+
uv build
27+
uv publish --index sevan-internal-package-index
28+
env:
29+
UV_PUBLISH_USERNAME: ${{ secrets.PACKAGR_USERNAME }}
30+
UV_PUBLISH_PASSWORD: ${{ secrets.PACKAGR_PASSWORD }}

.github/workflows/test.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,26 @@ jobs:
3535

3636
test:
3737

38-
name: Run tests
38+
name: Test with ${{matrix.python-version}} on Ubuntu
3939
runs-on: ubuntu-latest
40+
strategy:
41+
matrix:
42+
python-version: ["3.10", "3.11", "3.12", "3.13"]
4043

4144
steps:
4245
- uses: actions/checkout@v4
4346

44-
- name: Install the latest version of uv
47+
- name: Install the latest version of uv and set the python version
4548
uses: astral-sh/setup-uv@v6
4649
with:
50+
python-version: ${{ matrix.python-version }}
4751
enable-cache: true
4852

49-
- name: Run tests with pytest
50-
run: uv run pytest
53+
- name: Test with python ${{ matrix.python-version }}
54+
run: uv run coverage run -m pytest tests/unit
55+
56+
- name: Get Test Coverage score
57+
id: total
58+
if: matrix.python-version == '3.12'
59+
run: |
60+
uv run coverage report --include=src/\* --fail-under=95 -m

.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.

README.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# python-template
2-
A template repository for python projects in Sevan DWT.
1+
# python-library-template
2+
A template repository for python libraries made by Sevan DWT.
33

44
## Setup environment with uv
55

@@ -54,15 +54,6 @@ C:\Users\<your-username>\_netrc
5454

5555
Your setup should now be complete.
5656

57-
58-
## Run a script
59-
60-
To test your setup, you can try to run one of your scripts:
61-
62-
```console
63-
uv run .\src\main.py
64-
```
65-
6657
## Develop your own scripts
6758

6859
### Add a new package

pyproject.toml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
[project]
2-
name = "python-template" # Change this to your package name
2+
name = "python-library-template" # TODO: Change this to your package name
33
version = "0.1.0"
4-
description = "<Add your description here>"
4+
description = "Add your description here" # TODO: Update this description to match your library's purpose
55
readme = "README.md"
6+
license="MIT"
7+
classifiers = ["Private :: Do Not Upload"] # TODO: Remove this line if you want to publish your library
68
requires-python = ">=3.10, <4"
7-
dependencies = [
8-
]
9+
dependencies = []
10+
11+
[build-system]
12+
requires = ["uv_build>=0.7.19,<0.8.0"]
13+
build-backend = "uv_build"
914

1015
[dependency-groups]
1116
dev = [
@@ -18,6 +23,7 @@ dev = [
1823
[[tool.uv.index]]
1924
name = "sevan-internal-package-index"
2025
url = "https://api.repoforge.io/EYvhW6SyL/"
26+
publish-url = "https://api.repoforge.io/EYvhW6SyL/"
2127

2228
[tool.pytest.ini_options]
2329
pythonpath = ["src"]
@@ -40,3 +46,4 @@ select = [
4046

4147
[tool.ruff.lint.per-file-ignores]
4248
"__init__.py" = ["F401"]
49+

src/main.py

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# TODO Rename folder to your library name
2+
3+
def hello_world() -> str:
4+
return "Hello from python-library-template!"

tests/test_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from main import hello_world
1+
from python_library_template import hello_world
22

33

44
def test_hello_world():

uv.lock

Lines changed: 0 additions & 359 deletions
This file was deleted.

0 commit comments

Comments
 (0)