Skip to content

Commit 9850ede

Browse files
authored
build(ci,packaging): migrate to pyproject.toml, adopt src layout, and streamline workflows (#104)
build(ci,packaging): migrate to pyproject.toml, adopt src layout, and streamline workflows * Switch to PEP 621-compatible `pyproject.toml` for metadata and builds * Move package into `src/` layout * Remove legacy Conda workflow and rename CI files * Update GitHub Actions and pull-request template ref: #105
1 parent 52cbd10 commit 9850ede

23 files changed

+200
-197
lines changed

.flake8

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

.github/pull_request_template.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- List any dependencies that are required for this change.
66

77

8+
# Issues
89
- Fixes # (issue)
910
## Type of change
1011

@@ -14,6 +15,7 @@ Check relevant points.
1415
- [ ] New feature (non-breaking change which adds functionality)
1516
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
1617
- [ ] This change requires a documentation update
18+
- [ ] Dev changes (CI/pyproject.toml/docs/examples/testing)
1719

1820
# How Has This Been Tested?
1921

@@ -26,8 +28,7 @@ Check relevant points.
2628

2729
# Checklist:
2830

29-
- [ ] updated version number in setup.py/pyproject.toml
30-
- [ ] updated environment.yml and the lock file
31+
- [ ] updated version number in pyproject.toml
3132
- [ ] added changes to History.rst
3233
- [ ] updated the latest version in README file
3334
- [ ] I have added tests that prove my fix is effective or that my feature works

.github/workflows/conda-deployment.yml

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

.github/workflows/pypi-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ jobs:
2424
- name: Install tools
2525
run: |
2626
python -m pip install --upgrade pip
27-
pip install setuptools wheel twine
27+
pip install wheel twine build
2828
- name: Build and publish
2929
run: |
30-
python setup.py sdist bdist_wheel
30+
python -m build --sdist --wheel
3131
twine upload dist/*
3232
env:
3333
TWINE_USERNAME: ${{ secrets.PYPI_USERS }}
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
name: pypi-deployment
1+
name: tests
2+
3+
on: [push]
24

3-
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
branches:
9-
- main
105
jobs:
11-
Run:
6+
main-package:
127
runs-on: ${{ matrix.os }}
138
strategy:
149
matrix:
15-
os: [ubuntu-latest, windows-latest] # , macos-latest
16-
python-version: ["3.10", "3.11", "3.12"]
10+
os: [ubuntu-latest]
11+
python-version: ["3.11", "3.12", "3.13"]
12+
env:
13+
OS: ${{ matrix.os }}
1714

1815
steps:
1916
- uses: actions/checkout@v3
20-
- name: Set up Python ${{ matrix.python-version }} ${{ matrix.os }}
17+
- name: Set up Python ${{ matrix.python-version }}
2118
uses: actions/setup-python@v4
2219
with:
2320
python-version: ${{ matrix.python-version }}
@@ -27,9 +24,13 @@ jobs:
2724
run: |
2825
pip install .[dev]
2926
30-
- name: Generate coverage report
27+
- name: Run Tests
3128
run: |
32-
python -m pytest -vvv --cov=statista --cov-report=xml
29+
pytest -vvv --cov=statista --cov-report=xml
3330
3431
- name: Upload coverage reports to Codecov with GitHub Action
3532
uses: codecov/codecov-action@v3
33+
34+
- name: test Jupyter notebook
35+
run: |
36+
pytest --nbval --nbval-lax --verbose

.pre-commit-config.yaml

Lines changed: 80 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
fail_fast: true
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.6.0
4+
rev: v5.0.0
55
hooks:
6+
- id: check-toml
7+
name: "[py - check] check toml"
68
- id: end-of-file-fixer
79
name: "[py - check] validate yaml"
10+
- id: no-commit-to-branch
11+
name: "[git - check] no commit to branch"
12+
args: [ --branch=main ]
813
- id: trailing-whitespace
914
name: "[file - format] trim trailing whitespace"
1015
args: [ --markdown-linebreak-ext=md ]
1116
- id: check-added-large-files
1217
name: "[file - check] large file"
13-
args: [ --maxkb=5000 ]
18+
args: [ --maxkb=2000 ]
1419
- id: check-docstring-first
1520
name: "[py - check] docstring first"
1621
files: /examples
@@ -38,50 +43,45 @@ repos:
3843
name: "[reqs - format] fix requirements.txt"
3944
- id: check-yaml
4045
name: "[yaml - check] validate yaml"
41-
# - repo: https://github.com/pre-commit/mirrors-isort
42-
# rev: v5.10.1
43-
# hooks:
44-
# - id: isort
45-
# name: "[py - format] isort"
46-
# - repo: https://github.com/PyCQA/docformatter
47-
# rev: v1.4
48-
# hooks:
49-
# - id: docformatter
50-
# name: "[py - format] docformatter"
51-
# args: [ -i, --wrap-summaries, "0" ]
52-
53-
- repo: https://github.com/PyCQA/pydocstyle
54-
rev: 6.3.0
55-
hooks:
56-
- id: pydocstyle
57-
name: "[py - check] pydocstyle"
58-
files: ^Hapi/
59-
46+
exclude: '^mkdocs\.yml$'
6047
- repo: https://github.com/pycqa/flake8
61-
rev: 7.1.0
48+
rev: 7.2.0
6249
hooks:
6350
- id: flake8
51+
additional_dependencies: [Flake8-pyproject]
6452
name: "[py - check] flake8"
65-
# language_version: python3.9
6653
exclude: ^(examples/|tests/)
67-
68-
#- repo: https://github.com/psf/black
69-
# rev: 22.8.0
70-
# hooks:
71-
# - id: black
72-
- repo: https://github.com/ambv/black
73-
rev: 24.8.0
54+
# - repo: https://github.com/pycqa/docformatter
55+
# rev: v1.4
56+
# hooks:
57+
# - id: docformatter
58+
# name: "[py - format] docformatter"
59+
# description: 'Formats docstrings to follow PEP 257.'
60+
# entry: docformatter
61+
# args: [-i]
62+
# language: python
63+
# types: [python]
64+
# - repo: https://github.com/pycqa/pydocstyle
65+
# rev: 6.3.0
66+
# hooks:
67+
# - id: pydocstyle
68+
# name: "[py - check] pydocstyle"
69+
# files: ^hydrolib/.*\.py$
70+
- repo: https://github.com/pycqa/isort
71+
rev: 6.0.1
72+
hooks:
73+
- id: isort
74+
name: "[py - format] isort"
75+
- repo: https://github.com/psf/black
76+
rev: 25.1.0
7477
hooks:
7578
- id: black
76-
name: "[py - format] black"
77-
# language_version: python3.9
7879
- repo: https://github.com/lovesegfault/beautysh
7980
rev: v6.2.1
8081
hooks:
8182
- id: beautysh
8283
name: "[bash - format] beautysh"
8384

84-
# pre-commit-shell: Checks shell scripts against shellcheck.
8585
- repo: https://github.com/detailyang/pre-commit-shell
8686
rev: 1.0.5
8787
hooks:
@@ -104,27 +104,69 @@ repos:
104104
- id: check-summary-punctuation
105105
name: "[bash - format] check-summary-punctuation"
106106

107+
- repo: https://github.com/PyCQA/bandit
108+
rev: 1.8.3
109+
hooks:
110+
- id: bandit
111+
args: ["--skip=B101"]
112+
113+
- repo: https://github.com/gitleaks/gitleaks
114+
rev: v8.25.1
115+
hooks:
116+
- id: gitleaks
117+
118+
- repo: https://github.com/Yelp/detect-secrets
119+
rev: v1.5.0
120+
hooks:
121+
- id: detect-secrets
122+
- repo: https://github.com/bridgecrewio/checkov
123+
rev: 3.2.416
124+
hooks:
125+
- id: checkov
126+
127+
- repo: https://github.com/trufflesecurity/truffleHog
128+
rev: v3.88.29
129+
hooks:
130+
- id: trufflehog
131+
132+
# - repo: local
133+
# hooks:
134+
# - id: safety
135+
# name: Safety Check
136+
# entry: safety scan --full-report
137+
# language: system
138+
# types: [python]
139+
# pass_filenames: false
140+
141+
- repo: https://github.com/commitizen-tools/commitizen
142+
rev: v4.6.3
143+
hooks:
144+
- id: commitizen
145+
stages: [commit-msg]
146+
107147
- repo: local
108148
hooks:
109149
- id: pytest-check
110150
name: pytest-check
111-
entry: pytest -vvv --cov=statista
151+
entry: pytest -v --cov=src/statista --cov-report term-missing
112152
language: system
113153
pass_filenames: false
114154
always_run: true
115155

116156
- repo: local
117157
hooks:
118-
- id: examples-notebook-check
158+
- id: notebook-check
119159
name: nbval
120-
entry: pytest --nbval
160+
entry: pytest --nbval-lax
121161
language: system
122162
files: \.ipynb$
163+
always_run: true
123164

124165
- repo: local
125166
hooks:
126167
- id: doctest
127168
name: doctest
128-
entry: pytest --doctest-modules
169+
entry: python -c "import matplotlib; matplotlib.use('Agg'); import pytest; pytest.main(['--doctest-modules'])"
129170
language: system
130-
files: statista\.py$
171+
files: ^src/statista/.*\.py$
172+
always_run: true

HISTORY.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,9 @@ distributions
7474
descriptors
7575
"""""""""""
7676
* rename the `metrics` module to `descriptors`.
77+
78+
0.6.1 (2025-06-**)
79+
------------------
80+
Dev
81+
"""
82+
* replace the setup.py with pyproject.toml.

environment.yml

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

0 commit comments

Comments
 (0)