Skip to content

Commit cab5638

Browse files
authored
Update packaging following uv advancements (#106)
* update packaging * fix stubgen * update pre-commit
1 parent 2ed859c commit cab5638

21 files changed

Lines changed: 2215 additions & 143 deletions

.github/workflows/doc.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ jobs:
1313
timeout-minutes: 10
1414
runs-on: ubuntu-latest
1515
steps:
16+
- run: sudo apt update && sudo apt install -y optipng
1617
- uses: actions/checkout@v4
1718
with:
1819
fetch-depth: 0
19-
- uses: actions/setup-python@v5
20-
with:
21-
python-version: 3.11
22-
- run: sudo apt update && sudo apt install -y optipng
2320
- uses: astral-sh/setup-uv@v6
24-
- run: uv pip install --quiet --system .[doc]
21+
with:
22+
activate-environment: true
23+
- run: uv sync -q --locked --no-default-groups --group doc
2524
- run: template sys-info --developer
2625
- run: make -C doc html
2726
- name: Prune sphinx environment

.github/workflows/publish.yaml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
11
name: publish
22
on: # yamllint disable-line rule:truthy
3-
workflow_dispatch:
3+
workflow_dispatch: # remove in favor of release
4+
# release:
5+
# types: [published]
46

57
jobs:
68
pypi:
79
timeout-minutes: 10
810
runs-on: ubuntu-latest
11+
permissions:
12+
id-token: write
13+
contents: write
14+
environment:
15+
name: pypi
16+
url: https://pypi.org/p/template-python
917
steps:
1018
- uses: actions/checkout@v4
1119
with:
1220
fetch-depth: 0
13-
- uses: actions/setup-python@v5
14-
with:
15-
python-version: 3.11
1621
- uses: astral-sh/setup-uv@v6
17-
- run: uv pip install --quiet --system -e .[build,stubs]
22+
with:
23+
activate-environment: true
24+
- run: uv sync -q --locked --no-default-groups --group stubs
1825
- run: template sys-info --developer
1926
- run: python tools/stubgen.py
20-
- name: Build and publish
21-
env:
22-
TWINE_USERNAME: __token__
23-
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
24-
run: |
25-
python -m build
26-
twine check --strict dist/*
27-
twine upload dist/*
27+
- run: uv build
28+
- uses: softprops/action-gh-release@v2
29+
with:
30+
files: dist/*
31+
tag_name: ${{ github.event.release.tag_name }}
32+
- uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/pytest.yaml

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
os: [ubuntu, macos, windows]
20-
python-version: ["3.10", "3.11", "3.12", "3.13"]
20+
python-version: ["3.11", "3.12", "3.13"]
2121
name: ${{ matrix.os }} - py${{ matrix.python-version }}
2222
runs-on: ${{ matrix.os }}-latest
2323
defaults:
@@ -27,47 +27,39 @@ jobs:
2727
- uses: actions/checkout@v4
2828
with:
2929
fetch-depth: 0
30-
- uses: actions/setup-python@v5
30+
- uses: astral-sh/setup-uv@v6
3131
with:
32+
activate-environment: true
3233
python-version: ${{ matrix.python-version }}
33-
- uses: astral-sh/setup-uv@v6
34-
- run: uv pip install --quiet --system .[test]
34+
- run: uv sync -q --locked --no-default-groups --group test
3535
- run: template sys-info --developer
3636
- run: pytest template --cov=template --cov-report=xml --cov-config=pyproject.toml
3737
- uses: codecov/codecov-action@v5
3838
with:
39-
files: ./coverage.xml
40-
flags: unittests # optional
41-
name: codecov-umbrella # optional
4239
token: ${{ secrets.CODECOV_TOKEN }}
43-
verbose: true # optional (default = false)
4440

4541
pytest-pip-pre:
4642
timeout-minutes: 30
4743
strategy:
4844
fail-fast: false
4945
matrix:
50-
python-version: ["3.11"]
46+
python-version: ["3.13"]
5147
name: pip pre-release - py${{ matrix.python-version }}
5248
runs-on: ubuntu-latest
5349
steps:
5450
- uses: actions/checkout@v4
5551
with:
5652
fetch-depth: 0
57-
- uses: actions/setup-python@v5
53+
- uses: astral-sh/setup-uv@v6
5854
with:
55+
activate-environment: true
5956
python-version: ${{ matrix.python-version }}
60-
- uses: astral-sh/setup-uv@v6
6157
- name: Install package
6258
run: |
63-
uv pip install --quiet --system .[test]
64-
uv pip install --quiet --system --upgrade --prerelease allow --only-binary :all: -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
59+
uv sync -q --locked --no-default-groups --group test
60+
uv pip install -q --upgrade --prerelease allow --only-binary :all: -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
6561
- run: template sys-info --developer
6662
- run: pytest template --cov=template --cov-report=xml --cov-config=pyproject.toml
6763
- uses: codecov/codecov-action@v5
6864
with:
69-
files: ./coverage.xml
70-
flags: unittests # optional
71-
name: codecov-umbrella # optional
7265
token: ${{ secrets.CODECOV_TOKEN }}
73-
verbose: true # optional (default = false)

.github/workflows/stubs.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ jobs:
1616
- uses: actions/checkout@v4
1717
with:
1818
fetch-depth: 0
19-
- uses: actions/setup-python@v5
20-
with:
21-
python-version: 3.11
2219
- uses: astral-sh/setup-uv@v6
23-
- run: uv pip install --quiet --system -e .[stubs]
20+
with:
21+
activate-environment: true
22+
- run: uv sync -q --locked --no-default-groups --group stubs
2423
- run: template sys-info --developer
2524
- run: python tools/stubgen.py
2625
- name: Push stub files

.pre-commit-config.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
repos:
2+
- repo: https://github.com/astral-sh/uv-pre-commit
3+
rev: 0.7.3
4+
hooks:
5+
- id: uv-lock
6+
27
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.11.10
8+
rev: v0.11.11
49
hooks:
510
- id: ruff
611
name: ruff linter

doc/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@
9898
],
9999
}
100100

101-
# -- autosummary -----------------------------------------------------------------------
101+
# -- autosummary / autodoc--------------------------------------------------------------
102102
autosummary_generate = True
103-
104-
# -- autodoc ---------------------------------------------------------------------------
103+
autodoc_pydantic_model_show_config_summary = False
104+
autodoc_pydantic_model_show_json = False
105105
autodoc_typehints = "none"
106106
autodoc_member_order = "groupwise"
107107
autodoc_warningiserror = True

pyproject.toml

Lines changed: 43 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,44 @@
22
build-backend = 'setuptools.build_meta'
33
requires = ['setuptools >= 64.0.0', 'setuptools_scm>=8']
44

5+
[dependency-groups]
6+
doc = [
7+
'autodoc_pydantic',
8+
'furo',
9+
'intersphinx_registry',
10+
'matplotlib',
11+
'memory-profiler',
12+
'numpydoc',
13+
'sphinx',
14+
'sphinx-copybutton',
15+
'sphinx-design',
16+
'sphinx-gallery',
17+
'sphinx-issues',
18+
'sphinxcontrib-bibtex',
19+
]
20+
ide = [
21+
'ipykernel',
22+
'ipython',
23+
]
24+
stubs = [
25+
'mypy',
26+
'ruff>=0.6.0',
27+
]
28+
style = [
29+
'bibclean',
30+
'codespell[toml]>=2.2.4',
31+
'pre-commit',
32+
'ruff>=0.6.0',
33+
'toml-sort',
34+
'yamllint',
35+
]
36+
test = [
37+
'pytest-cov',
38+
'pytest-randomly',
39+
'pytest-timeout',
40+
'pytest>=8.0',
41+
]
42+
543
[project]
644
authors = [
745
{email = 'mathieu.scheltienne@gmail.com', name = 'Mathieu Scheltienne'},
@@ -12,7 +50,6 @@ classifiers = [
1250
'Operating System :: Microsoft :: Windows',
1351
'Operating System :: Unix',
1452
'Programming Language :: Python :: 3 :: Only',
15-
'Programming Language :: Python :: 3.10',
1653
'Programming Language :: Python :: 3.11',
1754
'Programming Language :: Python :: 3.12',
1855
'Programming Language :: Python :: 3.13',
@@ -36,56 +73,10 @@ maintainers = [
3673
]
3774
name = 'template'
3875
readme = 'README.md'
39-
requires-python = '>=3.10'
40-
41-
[project.optional-dependencies]
42-
all = [
43-
'template[build]',
44-
'template[doc]',
45-
'template[stubs]',
46-
'template[style]',
47-
'template[test]',
48-
]
49-
build = [
50-
'build',
51-
'twine',
52-
]
53-
doc = [
54-
'furo',
55-
'intersphinx_registry',
56-
'matplotlib',
57-
'memory-profiler',
58-
'numpydoc',
59-
'sphinx',
60-
'sphinx-copybutton',
61-
'sphinx-design',
62-
'sphinx-gallery',
63-
'sphinx-issues',
64-
'sphinxcontrib-bibtex',
65-
]
66-
full = [
67-
'template[all]',
68-
]
69-
stubs = [
70-
'mypy',
71-
'ruff>=0.6.0',
72-
]
73-
style = [
74-
'bibclean',
75-
'codespell[toml]>=2.2.4',
76-
'pre-commit',
77-
'ruff>=0.6.0',
78-
'toml-sort',
79-
'yamllint',
80-
]
81-
test = [
82-
'pytest-cov',
83-
'pytest-timeout',
84-
'pytest>=8.0',
85-
]
76+
requires-python = '>=3.11'
8677

8778
[project.scripts]
88-
template = 'template.commands.main:run'
79+
template = 'template._commands.main:run'
8980

9081
[project.urls]
9182
documentation = 'https://github.com/mscheltienne/template-python'
@@ -166,3 +157,6 @@ all = true
166157
ignore_case = true
167158
spaces_before_inline_comment = 2
168159
trailing_comma_inline_array = true
160+
161+
[tool.uv]
162+
default-groups = "all"

template/_commands/sys_info.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from __future__ import annotations
2+
3+
import click
4+
5+
from .. import sys_info
6+
7+
8+
@click.command(name="sys-info")
9+
@click.option(
10+
"--extra",
11+
help="Display information for optional dependencies.",
12+
is_flag=True,
13+
)
14+
@click.option(
15+
"--developer",
16+
help="Display information for developer dependencies.",
17+
is_flag=True,
18+
)
19+
@click.option(
20+
"--package",
21+
help="The package to display information about.",
22+
type=str,
23+
)
24+
def run(extra: bool, developer: bool, package: str | None) -> None:
25+
"""Run sys_info() command."""
26+
sys_info(extra=extra, developer=developer, package=package)

0 commit comments

Comments
 (0)