Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ jobs:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- run: sudo apt update && sudo apt install -y optipng
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: 3.11
- run: sudo apt update && sudo apt install -y optipng
- uses: astral-sh/setup-uv@v6
- run: uv pip install --quiet --system .[doc]
with:
activate-environment: true
- run: uv sync -q --locked --no-default-groups --group doc
- run: template sys-info --developer
- run: make -C doc html
- name: Prune sphinx environment
Expand Down
31 changes: 18 additions & 13 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
name: publish
on: # yamllint disable-line rule:truthy
workflow_dispatch:
workflow_dispatch: # remove in favor of release
# release:
# types: [published]

jobs:
pypi:
timeout-minutes: 10
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
environment:
name: pypi
url: https://pypi.org/p/template-python
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: 3.11
- uses: astral-sh/setup-uv@v6
- run: uv pip install --quiet --system -e .[build,stubs]
with:
activate-environment: true
- run: uv sync -q --locked --no-default-groups --group stubs
- run: template sys-info --developer
- run: python tools/stubgen.py
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python -m build
twine check --strict dist/*
twine upload dist/*
- run: uv build
- uses: softprops/action-gh-release@v2
with:
files: dist/*
tag_name: ${{ github.event.release.tag_name }}
- uses: pypa/gh-action-pypi-publish@release/v1
26 changes: 9 additions & 17 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
python-version: ["3.10", "3.11", "3.12", "3.13"]
python-version: ["3.11", "3.12", "3.13"]
name: ${{ matrix.os }} - py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}-latest
defaults:
Expand All @@ -27,47 +27,39 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
- uses: astral-sh/setup-uv@v6
with:
activate-environment: true
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@v6
- run: uv pip install --quiet --system .[test]
- run: uv sync -q --locked --no-default-groups --group test
- run: template sys-info --developer
- run: pytest template --cov=template --cov-report=xml --cov-config=pyproject.toml
- uses: codecov/codecov-action@v5
with:
files: ./coverage.xml
flags: unittests # optional
name: codecov-umbrella # optional
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true # optional (default = false)

pytest-pip-pre:
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
python-version: ["3.11"]
python-version: ["3.13"]
name: pip pre-release - py${{ matrix.python-version }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
- uses: astral-sh/setup-uv@v6
with:
activate-environment: true
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@v6
- name: Install package
run: |
uv pip install --quiet --system .[test]
uv pip install --quiet --system --upgrade --prerelease allow --only-binary :all: -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
uv sync -q --locked --no-default-groups --group test
uv pip install -q --upgrade --prerelease allow --only-binary :all: -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
- run: template sys-info --developer
- run: pytest template --cov=template --cov-report=xml --cov-config=pyproject.toml
- uses: codecov/codecov-action@v5
with:
files: ./coverage.xml
flags: unittests # optional
name: codecov-umbrella # optional
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true # optional (default = false)
7 changes: 3 additions & 4 deletions .github/workflows/stubs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: 3.11
- uses: astral-sh/setup-uv@v6
- run: uv pip install --quiet --system -e .[stubs]
with:
activate-environment: true
- run: uv sync -q --locked --no-default-groups --group stubs
- run: template sys-info --developer
- run: python tools/stubgen.py
- name: Push stub files
Expand Down
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
repos:
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.7.3
hooks:
- id: uv-lock

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.10
rev: v0.11.11
hooks:
- id: ruff
name: ruff linter
Expand Down
6 changes: 3 additions & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@
],
}

# -- autosummary -----------------------------------------------------------------------
# -- autosummary / autodoc--------------------------------------------------------------
autosummary_generate = True

# -- autodoc ---------------------------------------------------------------------------
autodoc_pydantic_model_show_config_summary = False
autodoc_pydantic_model_show_json = False
autodoc_typehints = "none"
autodoc_member_order = "groupwise"
autodoc_warningiserror = True
Expand Down
92 changes: 43 additions & 49 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,44 @@
build-backend = 'setuptools.build_meta'
requires = ['setuptools >= 64.0.0', 'setuptools_scm>=8']

[dependency-groups]
doc = [
'autodoc_pydantic',
'furo',
'intersphinx_registry',
'matplotlib',
'memory-profiler',
'numpydoc',
'sphinx',
'sphinx-copybutton',
'sphinx-design',
'sphinx-gallery',
'sphinx-issues',
'sphinxcontrib-bibtex',
]
ide = [
'ipykernel',
'ipython',
]
stubs = [
'mypy',
'ruff>=0.6.0',
]
style = [
'bibclean',
'codespell[toml]>=2.2.4',
'pre-commit',
'ruff>=0.6.0',
'toml-sort',
'yamllint',
]
test = [
'pytest-cov',
'pytest-randomly',
'pytest-timeout',
'pytest>=8.0',
]

[project]
authors = [
{email = 'mathieu.scheltienne@gmail.com', name = 'Mathieu Scheltienne'},
Expand All @@ -12,7 +50,6 @@ classifiers = [
'Operating System :: Microsoft :: Windows',
'Operating System :: Unix',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
Expand All @@ -36,56 +73,10 @@ maintainers = [
]
name = 'template'
readme = 'README.md'
requires-python = '>=3.10'

[project.optional-dependencies]
all = [
'template[build]',
'template[doc]',
'template[stubs]',
'template[style]',
'template[test]',
]
build = [
'build',
'twine',
]
doc = [
'furo',
'intersphinx_registry',
'matplotlib',
'memory-profiler',
'numpydoc',
'sphinx',
'sphinx-copybutton',
'sphinx-design',
'sphinx-gallery',
'sphinx-issues',
'sphinxcontrib-bibtex',
]
full = [
'template[all]',
]
stubs = [
'mypy',
'ruff>=0.6.0',
]
style = [
'bibclean',
'codespell[toml]>=2.2.4',
'pre-commit',
'ruff>=0.6.0',
'toml-sort',
'yamllint',
]
test = [
'pytest-cov',
'pytest-timeout',
'pytest>=8.0',
]
requires-python = '>=3.11'

[project.scripts]
template = 'template.commands.main:run'
template = 'template._commands.main:run'

[project.urls]
documentation = 'https://github.com/mscheltienne/template-python'
Expand Down Expand Up @@ -166,3 +157,6 @@ all = true
ignore_case = true
spaces_before_inline_comment = 2
trailing_comma_inline_array = true

[tool.uv]
default-groups = "all"
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions template/_commands/sys_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from __future__ import annotations

import click

from .. import sys_info


@click.command(name="sys-info")
@click.option(
"--extra",
help="Display information for optional dependencies.",
is_flag=True,
)
@click.option(
"--developer",
help="Display information for developer dependencies.",
is_flag=True,
)
@click.option(
"--package",
help="The package to display information about.",
type=str,
)
def run(extra: bool, developer: bool, package: str | None) -> None:
"""Run sys_info() command."""
sys_info(extra=extra, developer=developer, package=package)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


@pytest.mark.parametrize("developer", [False, True])
def test_sys_info(developer: bool):
def test_sys_info(developer: bool) -> None:
"""Test the system information entry-point."""
runner = CliRunner()
result = runner.invoke(run, ["--developer"] if developer else [])
Expand All @@ -15,6 +15,5 @@ def test_sys_info(developer: bool):
assert "Executable:" in result.output
assert "Core dependencies" in result.output
if developer:
assert "Optional 'build' dependencies" in result.output
assert "Optional 'style' dependencies" in result.output
assert "Optional 'test' dependencies" in result.output
assert "Developer 'style' dependencies" in result.output
assert "Developer 'test' dependencies" in result.output
16 changes: 0 additions & 16 deletions template/commands/sys_info.py

This file was deleted.

9 changes: 7 additions & 2 deletions template/utils/_checks.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ def ensure_int(item: Any, item_name: str | None = None) -> int:
item_name : str | None
Name of the item to show inside the error message.

Returns
-------
item : int
Item validated and converted to a Python integer.

Raises
------
TypeError
Expand Down Expand Up @@ -76,8 +81,8 @@ def check_value(
When the value of the item is not one of the valid options.
"""

def check_verbose(verbose: Any) -> int:
"""Check that the value of verbose is valid.
def ensure_verbose(verbose: Any) -> int:
"""Ensure that the value of verbose is valid.

Parameters
----------
Expand Down
Loading