Skip to content

Commit e7d8920

Browse files
committed
Create template based on cookiecutter
1 parent c470bf5 commit e7d8920

File tree

20 files changed

+948
-1
lines changed

20 files changed

+948
-1
lines changed

.git_archival.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node: $Format:%H$
2+
node-date: $Format:%cI$
3+
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.git_archival.txt export-subst

.github/CONTRIBUTING.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
See the [Scientific Python Developer Guide][spc-dev-intro] for a detailed
2+
description of best practices for developing scientific packages.
3+
4+
[spc-dev-intro]: https://learn.scientific-python.org/development/
5+
6+
# Quick development
7+
8+
The fastest way to start with development is to use nox. If you don't have nox,
9+
you can use `uvx nox` to run it without installing, or `uv tool install nox`. If
10+
you don't have uv, you can
11+
[install it a variety of ways](https://docs.astral.sh/uv/getting-started/installation/),
12+
including with pip, pipx, brew, and just downloading the binary (single file).
13+
14+
To use, run `nox`. This will lint and test using every installed version of
15+
Python on your system, skipping ones that are not installed. You can also run
16+
specific jobs:
17+
18+
```console
19+
$ nox -s lint # Lint only
20+
$ nox -s tests # Python tests
21+
$ nox -s docs # Build and serve the docs
22+
$ nox -s build # Make an SDist and wheel
23+
```
24+
25+
Nox handles everything for you, including setting up an temporary virtual
26+
environment for each run.
27+
28+
# Setting up a development environment manually
29+
30+
You can set up a development environment by running:
31+
32+
```bash
33+
uv sync
34+
```
35+
36+
# Pre-commit
37+
38+
You should prepare pre-commit, which will help you by checking that commits pass
39+
required checks:
40+
41+
```bash
42+
uv tool install pre-commit # or brew install pre-commit on macOS
43+
pre-commit install # Will install a pre-commit hook into the git repo
44+
```
45+
46+
You can also/alternatively run `pre-commit run` (changes only) or
47+
`pre-commit run --all-files` to check even without installing the hook.
48+
49+
# Testing
50+
51+
Use pytest to run the unit checks:
52+
53+
```bash
54+
uv run pytest
55+
```
56+
57+
# Coverage
58+
59+
Use pytest-cov to generate coverage reports:
60+
61+
```bash
62+
uv run pytest --cov=save-and-restore-api
63+
```
64+
65+
# Building docs
66+
67+
You can build and serve the docs using:
68+
69+
```bash
70+
nox -s docs
71+
```
72+
73+
You can build the docs only with:
74+
75+
```bash
76+
nox -s docs --non-interactive
77+
```

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
# Maintain dependencies for GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
groups:
9+
actions:
10+
patterns:
11+
- "*"

.github/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
changelog:
2+
exclude:
3+
authors:
4+
- dependabot[bot]
5+
- pre-commit-ci[bot]

.github/workflows/cd.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: CD
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
release:
10+
types:
11+
- published
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
env:
18+
# Many color libraries just need this to be set to any value, but at least
19+
# one distinguishes color depth, where "3" -> "256-bit color".
20+
FORCE_COLOR: 3
21+
22+
jobs:
23+
dist:
24+
name: Distribution build
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- uses: actions/checkout@v5
29+
with:
30+
fetch-depth: 0
31+
32+
- uses: hynek/build-and-inspect-python-package@v2
33+
34+
publish:
35+
needs: [dist]
36+
name: Publish to PyPI
37+
environment: pypi
38+
permissions:
39+
id-token: write
40+
attestations: write
41+
contents: read
42+
runs-on: ubuntu-latest
43+
if: github.event_name == 'release' && github.event.action == 'published'
44+
45+
steps:
46+
- uses: actions/download-artifact@v5
47+
with:
48+
name: Packages
49+
path: dist
50+
51+
- name: Generate artifact attestation for sdist and wheel
52+
uses: actions/attest-build-provenance@v3
53+
with:
54+
subject-path: "dist/*"
55+
56+
- uses: pypa/gh-action-pypi-publish@release/v1
57+
with:
58+
# Remember to tell (test-)pypi about this repo before publishing
59+
# Remove this line to publish to PyPI
60+
repository-url: https://test.pypi.org/legacy/

.github/workflows/ci.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
env:
15+
# Many color libraries just need this variable to be set to any value.
16+
# Set it to 3 to support 8-bit color graphics (256 colors per channel)
17+
# for libraries that care about the value set.
18+
FORCE_COLOR: 3
19+
20+
jobs:
21+
pre-commit:
22+
name: Format
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v5
26+
with:
27+
fetch-depth: 0
28+
- uses: actions/setup-python@v6
29+
with:
30+
python-version: "3.x"
31+
32+
- uses: astral-sh/setup-uv@v6
33+
34+
- uses: pre-commit/[email protected]
35+
with:
36+
extra_args: --hook-stage manual --all-files
37+
- name: Run Pylint
38+
run: uvx nox -s pylint -- --output-format=github
39+
40+
checks:
41+
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
42+
runs-on: ${{ matrix.runs-on }}
43+
needs: [pre-commit]
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
python-version: ["3.9", "3.13"]
48+
runs-on: [ubuntu-latest, windows-latest, macos-14]
49+
50+
include:
51+
- python-version: "pypy-3.10"
52+
runs-on: ubuntu-latest
53+
54+
steps:
55+
- uses: actions/checkout@v5
56+
with:
57+
fetch-depth: 0
58+
59+
- uses: actions/setup-python@v6
60+
with:
61+
python-version: ${{ matrix.python-version }}
62+
allow-prereleases: true
63+
64+
- uses: astral-sh/setup-uv@v6
65+
66+
- name: Install package
67+
run: uv sync
68+
69+
- name: Test package
70+
run: >-
71+
uv run pytest -ra --cov --cov-report=xml --cov-report=term
72+
--durations=20
73+
74+
- name: Upload coverage report
75+
uses: codecov/codecov-action@v5
76+
with:
77+
token: ${{ secrets.CODECOV_TOKEN }}

0 commit comments

Comments
 (0)