Skip to content

Commit

Permalink
Merge pull request #25 from Ouranosinc/modernize
Browse files Browse the repository at this point in the history
Modernize library
  • Loading branch information
Zeitsperre authored Sep 18, 2024
2 parents 8046090 + b80d3c4 commit d6d46ef
Show file tree
Hide file tree
Showing 25 changed files with 318 additions and 3,116 deletions.
13 changes: 13 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[flake8]
exclude =
.eggs,
.git,
build,
docs,
tests
ignore =
C,
D,
E,
F,
W503
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@ updates:
directory: /
schedule:
interval: monthly
groups:
actions:
patterns:
- "*"

- package-ecosystem: pip
directory: /
schedule:
interval: monthly
groups:
python:
patterns:
- "*"
50 changes: 50 additions & 0 deletions .github/workflows/cache-cleaner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Example taken from https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#managing-caches
name: Cleanup Caches on Pull Request Merge
on:
pull_request:
types:
- closed

permissions: # added using https://github.com/step-security/secure-repo
contents: read

jobs:
cleanup:
name: Cleanup
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
github.com:443
objects.githubusercontent.com:443
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27 changes: 13 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- README.rst
- setup.cfg
- setup.py
- lmoments3/__init__.py
- src/lmoments3/__init__.py
pull_request:

concurrency:
Expand All @@ -18,7 +18,8 @@ concurrency:
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
black:
lint:
name: Linting Suite
runs-on: ubuntu-latest
steps:
- name: Harden Runner
Expand All @@ -28,24 +29,21 @@ jobs:
egress-policy: audit
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Python${{ matrix.python-version }}
- name: Set up Python3
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: "3.8"
- name: Install black
run: |
pip install black>=24.8.0
- name: Run linting suite
run: |
black --check lmoments3
python-version: "3.x"
cache: "pip"
- name: Run pre-commit hooks
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1

test:
name: Pip with Python${{ matrix.python-version }}
needs: black
needs: lint
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13.0-rc.1"]
steps:
- name: Harden Runner
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
Expand All @@ -58,9 +56,10 @@ jobs:
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install lmoments3
run: |
pip install -e .
python -m pip install --editable .
- name: Test
run: |
python -m unittest discover -v
python -m unittest discover src/lmoments3 -v
4 changes: 2 additions & 2 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ jobs:
python-version: "3.x"
- name: Install packaging libraries
run: |
pip install build>=1.0 wheel>=0.42.0
python -m pip install --require-hashes -r CI/requirements_ci.txt
- name: Build a binary wheel and a source tarball
run: |
python -m build --sdist --wheel .
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
uses: pypa/gh-action-pypi-publish@0ab0b79471669eb3a4d647e625009c62f9f3b241 # v1.10.1
4 changes: 2 additions & 2 deletions .github/workflows/tag-testpypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:
python-version: "3.x"
- name: Install packaging libraries
run: |
pip install build>=1.0 wheel>=0.42.0
python -m pip install --require-hashes -r CI/requirements_ci.txt
- name: Build a binary wheel and a source tarball
run: |
python -m build --sdist --wheel .
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
uses: pypa/gh-action-pypi-publish@0ab0b79471669eb3a4d647e625009c62f9f3b241 # v1.10.1
with:
repository_url: https://test.pypi.org/legacy/
skip_existing: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ var/
.installed.cfg
*.egg

# setuptools-scm
src/lmoments3/_version.py

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
Expand Down
33 changes: 21 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ repos:
rev: v4.6.0
hooks:
- id: trailing-whitespace
exclude: setup.cfg
- id: end-of-file-fixer
- id: debug-statements
- id: check-toml
Expand All @@ -27,30 +26,40 @@ repos:
- id: yamllint
args: [ '--config-file=.yamllint.yaml' ]
exclude: conda-recipe/meta.yaml
- repo: https://github.com/psf/black
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-no-eval
- id: python-no-log-warn
# - id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
- id: flake8
args: [ '--config=setup.cfg' ]
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
args: [ '--config=.flake8' ]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.7
hooks:
- id: ruff
args: [ '--fix', '--show-fixes' ]
# - id: ruff-format
- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
hooks:
- id: isort
args: [ '--settings-file=pyproject.toml' ]
# - repo: https://github.com/pycqa/pydocstyle
# rev: 6.3.0
# hooks:
# - id: pydocstyle
# args: ['--config=setup.cfg']
- id: codespell
additional_dependencies: [ 'tomli' ]
- repo: https://github.com/keewis/blackdoc
rev: v0.3.9
hooks:
- id: blackdoc
additional_dependencies: [ 'black==24.8.0' ]
- id: blackdoc-autoupdate-black
- repo: meta
hooks:
- id: check-hooks-apply
Expand Down
2 changes: 2 additions & 0 deletions CI/requirements_ci.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build==1.2.2
wheel==0.44.0
34 changes: 34 additions & 0 deletions CI/requirements_ci.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# by the following command:
#
# pip-compile --generate-hashes --output-file=CI/requirements_ci.txt CI/requirements_ci.in
#
build==1.2.2 \
--hash=sha256:119b2fb462adef986483438377a13b2f42064a2a3a4161f24a0cca698a07ac8c \
--hash=sha256:277ccc71619d98afdd841a0e96ac9fe1593b823af481d3b0cea748e8894e0613
# via -r CI/requirements_ci.in
importlib-metadata==8.4.0 \
--hash=sha256:66f342cc6ac9818fc6ff340576acd24d65ba0b3efabb2b4ac08b598965a4a2f1 \
--hash=sha256:9a547d3bc3608b025f93d403fdd1aae741c24fbb8314df4b155675742ce303c5
# via build
packaging==24.1 \
--hash=sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002 \
--hash=sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124
# via build
pyproject-hooks==1.1.0 \
--hash=sha256:4b37730834edbd6bd37f26ece6b44802fb1c1ee2ece0e54ddff8bfc06db86965 \
--hash=sha256:7ceeefe9aec63a1064c18d939bdc3adf2d8aa1988a510afec15151578b232aa2
# via build
tomli==2.0.1 \
--hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \
--hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f
# via build
wheel==0.44.0 \
--hash=sha256:2376a90c98cc337d18623527a97c31797bd02bad0033d41547043a1cbfbe448f \
--hash=sha256:a29c3f2817e95ab89aa4660681ad547c0e9547f20e75b0562fe7723c9a2a9d49
# via -r CI/requirements_ci.in
zipp==3.20.1 \
--hash=sha256:9960cd8967c8f85a56f920d5d507274e74f9ff813a0ab8889a5b5be2daf44064 \
--hash=sha256:c22b14cc4763c5a5b04134207736c107db42e9d3ef2d9779d465f5f1bcba572b
# via importlib-metadata
34 changes: 0 additions & 34 deletions conda-build.ps1

This file was deleted.

4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import os
import sys
from datetime import date
from importlib.metadata import version as get_version

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
os.chdir("../..") # Versioneer requires us to work from the root of the project

sys.path.insert(0, os.getcwd())
import versioneer # noqa: E402

# -- General configuration ------------------------------------------------

Expand Down Expand Up @@ -43,7 +43,7 @@
"William Asquith, "
"J. R. M. Hosking"
)
release = versioneer.get_version()
release = get_version("lmoments3")
version = ".".join(release.split(".")[:2])

# The language for content autogenerated by Sphinx. Refer to documentation
Expand Down
2 changes: 1 addition & 1 deletion docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Example: Calculate the Negative Log Likelihood of a Gamma distribution with par
Other statistical methods
-------------------------

The :mod:`lmoments3.stats` module provides some additional statistical parametes to evaluate fitting of data to
The :mod:`lmoments3.stats` module provides some additional statistical parameters to evaluate fitting of data to
distribution function.

:func:`AIC(data, distr_name, distr_paras)`
Expand Down
5 changes: 4 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ name: lmoments3
channels:
- conda-forge
dependencies:
- python >=3.9,<3.13
- python >=3.9,<3.14
- numpy
- scipy
- black >=24.8.0
- blackdoc >=0.3.9
- python-build >=1.0
- flake8 >=7.0.0
- pydocstyle >=6.3.0
- ruff >=0.5.7
- setuptools
- setuptools-scm >=8.0
- sphinx >=6.0.0
- sphinx-rtd-theme >=1.0
- wheel >=0.42.0
Loading

0 comments on commit d6d46ef

Please sign in to comment.