Skip to content

Commit 0531a1a

Browse files
authored
Initial commit
0 parents  commit 0531a1a

29 files changed

+2306
-0
lines changed

.github/workflows/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Workflows
2+
3+
## cicd
4+
5+
Basic continuous integration and deployment (CI/CD) workflow for Python packages.
6+
7+
- checks formatting (black, isort)
8+
- checks linting (ruff)
9+
- run unit tests (pytest)
10+
- optional: add c extensions to a package
11+
- if all checks pass, build and deploy to PyPI if `tag` triggered the workflow

.github/workflows/cicd.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Python application
5+
6+
on:
7+
push:
8+
branches: ["main"]
9+
pull_request:
10+
branches: ["main"]
11+
schedule:
12+
- cron: "0 2 * * 3"
13+
release:
14+
types: [published]
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
format:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: psf/black@stable
25+
- uses: isort/isort-action@v1
26+
lint:
27+
name: Lint with ruff
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- uses: actions/setup-python@v5
33+
with:
34+
python-version: "3.11"
35+
- name: Install ruff
36+
run: |
37+
pip install ruff
38+
- name: Lint with ruff
39+
run: |
40+
# stop the build if there are Python syntax errors or undefined names
41+
ruff check src
42+
test:
43+
name: Test
44+
runs-on: ubuntu-latest
45+
strategy:
46+
matrix:
47+
python-version: ["3.10", "3.11", "3.12", "3.13"]
48+
steps:
49+
- uses: actions/checkout@v4
50+
- name: Set up Python ${{ matrix.python-version }}
51+
uses: actions/setup-python@v5
52+
with:
53+
python-version: ${{ matrix.python-version }}
54+
cache: "pip" # caching pip dependencies
55+
cache-dependency-path: "**/pyproject.toml"
56+
- name: Install dependencies
57+
run: |
58+
python -m pip install --upgrade pip
59+
pip install pytest
60+
pip install -e .
61+
- name: Run tests
62+
run: python -m pytest tests
63+
64+
build_source_dist:
65+
name: Build source distribution
66+
if: startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/tags')
67+
runs-on: ubuntu-latest
68+
steps:
69+
- uses: actions/checkout@v4
70+
71+
- uses: actions/setup-python@v5
72+
with:
73+
python-version: "3.10"
74+
75+
- name: Install build
76+
run: python -m pip install build
77+
78+
- name: Run build
79+
run: python -m build --sdist
80+
81+
- uses: actions/upload-artifact@v4
82+
with:
83+
path: ./dist/*.tar.gz
84+
# Needed in case of building packages with external binaries (e.g. Cython, RUst-extensions, etc.)
85+
# build_wheels:
86+
# name: Build wheels on ${{ matrix.os }}
87+
# if: startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/tags')
88+
# runs-on: ${{ matrix.os }}
89+
# strategy:
90+
# matrix:
91+
# os: [ubuntu-20.04, windows-2019, macOS-10.15]
92+
93+
# steps:
94+
# - uses: actions/checkout@v4
95+
96+
# - uses: actions/setup-python@v5
97+
# with:
98+
# python-version: "3.10"
99+
100+
# - name: Install cibuildwheel
101+
# run: python -m pip install cibuildwheel==2.3.1
102+
103+
# - name: Build wheels
104+
# run: python -m cibuildwheel --output-dir wheels
105+
106+
# - uses: actions/upload-artifact@v4
107+
# with:
108+
# path: ./wheels/*.whl
109+
110+
publish:
111+
name: Publish package
112+
if: startsWith(github.ref, 'refs/tags')
113+
permissions:
114+
id-token: write
115+
needs:
116+
- format
117+
- lint
118+
- test
119+
- build_source_dist
120+
# - build_wheels
121+
runs-on: ubuntu-latest
122+
123+
steps:
124+
- uses: actions/download-artifact@v4
125+
with:
126+
name: artifact
127+
path: ./dist
128+
# register PyPI integration:
129+
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
130+
- uses: pypa/gh-action-pypi-publish@release/v1
131+
with:
132+
# remove repository key to set the default to pypi (not test.pypi.org)
133+
repository-url: https://test.pypi.org/legacy/

.gitignore

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# find more examples here:
2+
# https://github.com/github/gitignore/blob/main/Python.gitignore
3+
# Binaries (object files) produced by a compiler
4+
*.so
5+
*.o
6+
7+
# Python/Jupyter uses these cache directories
8+
__pycache__
9+
.ipynb_checkpoints
10+
11+
# Produced when measuring code coverage
12+
.coverage
13+
14+
# These files are produced during the Python build process
15+
build/
16+
.eggs
17+
dist/
18+
**.egg-info
19+
20+
# Sphinx documenter creates these
21+
_build
22+
_static
23+
_templates
24+
/docs/reference
25+
/docs/jupyter_execute
26+
27+
# MacOS automatically creates these files
28+
.DS_Store
29+
30+
# VSCode may create a config file with this name
31+
**.vscode
32+
33+
# Ruff stuff:
34+
.ruff_cache/
35+
36+
# Environments
37+
.env
38+
.envrc
39+
.venv
40+
env/
41+
venv/
42+
43+
# Unit test / coverage reports
44+
htmlcov/
45+
.tox/
46+
.nox/
47+
.coverage
48+
.coverage.*
49+
.cache
50+
nosetests.xml
51+
coverage.xml
52+
*.cover
53+
*.py.cover
54+
.hypothesis/
55+
.pytest_cache/
56+
cover/

.readthedocs.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# .readthedocs.yaml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Set the OS, Python version and other tools you might need
9+
build:
10+
os: ubuntu-24.04
11+
tools:
12+
python: "3.13"
13+
# You can also specify other tool versions:
14+
# nodejs: "19"
15+
# rust: "1.64"
16+
# golang: "1.19"
17+
# apt_packages:
18+
# - some_package
19+
20+
21+
# Build documentation in the "docs/" directory with Sphinx
22+
sphinx:
23+
configuration: docs/conf.py
24+
25+
# Optionally build your docs in additional formats such as PDF and ePub
26+
# formats:
27+
# - pdf
28+
# - epub
29+
30+
# Optional but recommended, declare the Python requirements required
31+
# to build your documentation
32+
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
33+
python:
34+
install:
35+
- method: pip
36+
path: .
37+
extra_requirements:
38+
- docs

CITATION.cff

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-citation-files
2+
cff-version: 1.2.0
3+
message: "If you use this software, please cite it as below."
4+
authors:
5+
- family-names: "Last"
6+
given-names: "First"
7+
orcid: "https://orcid.org/0000-0000-0000-0000"
8+
title: "Python Package Template repository"
9+
version: 0.0.1
10+
doi: 10.5281/zenodo.1234
11+
date-released: 2025-07-23
12+
url: "https://github.com/biosustain/python_package"

Contributing.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Contributing code
2+
3+
Install the code with development dependencies:
4+
5+
```bash
6+
pip install -e '.[dev]'
7+
```
8+
9+
## Format code and sort imports
10+
11+
```bash
12+
black .
13+
isort .
14+
```
15+
16+
## lint code
17+
18+
```bash
19+
ruff check .
20+
```
21+
22+
## Run tests
23+
24+
```bash
25+
pytest
26+
```
27+
28+
## Sync notebooks with jupytext
29+
30+
For easier diffs, you can use jupytext to sync notebooks in the `docs/tutorial` directory with the percent format.
31+
32+
```bash
33+
jupytext --sync docs/tutorial/*.ipynb
34+
```
35+
36+
This is configured in the [`.jupytext`](docs/tutorial/.jupytext) file in that directory.

0 commit comments

Comments
 (0)