From 13217a6088fd06b2c378e5fe7f19f8a7b79a975b Mon Sep 17 00:00:00 2001 From: ric-evans Date: Mon, 18 Nov 2024 15:32:58 -0600 Subject: [PATCH 1/9] CI: Add Packaging --- .github/workflows/wipac-cicd.yaml | 41 +++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/.github/workflows/wipac-cicd.yaml b/.github/workflows/wipac-cicd.yaml index f43025e..3c291d6 100644 --- a/.github/workflows/wipac-cicd.yaml +++ b/.github/workflows/wipac-cicd.yaml @@ -9,6 +9,26 @@ on: jobs: + ########################################################################### + # PACKAGING + ########################################################################### + + py-setup: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + - uses: WIPACrepo/wipac-dev-py-setup-action@v4.2 + with: + python_min: 3.9 + pypi_name: icecube-simprod-histograms + author: IceCube + author_email: developers@icecube.wisc.edu + keywords: | + "histogram sampling" simulation statistics + + ########################################################################### # LINTERS ########################################################################### @@ -101,14 +121,25 @@ jobs: release: if: github.ref == 'refs/heads/main' - needs: [ flake8, mypy, code-format, unit-tests ] + needs: [ py-setup, flake8, mypy, code-format, unit-tests ] runs-on: ubuntu-latest + concurrency: release # prevent any possible race conditions steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - token: ${{ secrets.GITHUB_TOKEN }} - - name: Python Semantic Release - uses: python-semantic-release/python-semantic-release@v7.34.6 + # Python-Package Version Bump + - uses: python-semantic-release/python-semantic-release@v9.8.1 + id: psr-psr + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + # PyPI Release + - uses: pypa/gh-action-pypi-publish@v1.8.14 + if: steps.psr-psr.outputs.released == 'true' + with: + password: ${{ secrets.PYPI_TOKEN }} + # GitHub Release + - uses: python-semantic-release/upload-to-gh-release@v9.8.1 + if: steps.psr-psr.outputs.released == 'true' with: github_token: ${{ secrets.GITHUB_TOKEN }} From c068405de40b3ea0cf7a2f4f4c251098e1c4429f Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 18 Nov 2024 21:35:19 +0000 Subject: [PATCH 2/9] added pyproject.toml -- ALERT: user needs to set values for auto-added fields --- pyproject.toml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7e71345 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,12 @@ +# WIPACrepo/wipac-dev-py-setup-action@v4+ Migration Helper: + +# set these fields: +[project] +version = "0.0.0" +dependencies = [] # leave empty if there are no dependencies + +# optional sections: + +# [project.optional-dependencies] +# foo = [] +# bar = [] From ed61722ef04da7315da092998d93ccb5aa9d169c Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 18 Nov 2024 21:35:40 +0000 Subject: [PATCH 3/9] update pyproject.toml --- pyproject.toml | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7e71345..4aa44f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,43 @@ -# WIPACrepo/wipac-dev-py-setup-action@v4+ Migration Helper: +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" -# set these fields: [project] version = "0.0.0" -dependencies = [] # leave empty if there are no dependencies +dependencies = [] +name = "icecube-simprod-histograms" +description = "Utilities for working with histograms created for simprod" +readme = "README.md" +keywords = ["histogram sampling", "simulation", "statistics"] +classifiers = ["Development Status :: 3 - Alpha", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13"] +requires-python = ">=3.9, <3.14" -# optional sections: +[[project.authors]] +name = "IceCube" +email = "developers@icecube.wisc.edu" -# [project.optional-dependencies] -# foo = [] -# bar = [] +[project.license] +file = "LICENSE" + +[project.urls] +Homepage = "https://pypi.org/project/icecube-simprod-histograms/" +Tracker = "https://github.com/icecube/simprod-histogram/issues" +Source = "https://github.com/icecube/simprod-histogram" + +[tool.semantic_release] +version_toml = ["pyproject.toml:project.version"] +version_variables = [] +commit_parser = "emoji" +build_command = "pip install build && python -m build" + +[tool.semantic_release.commit_parser_options] +major_tags = ["[major]"] +minor_tags = ["[minor]", "[feature]"] +patch_tags = ["[patch]", "[fix]", " ", "!", "#", "$", "%", "&", "'", "(", ")", "*", "+", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "]", "^", "_", "`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~"] + +[tool.setuptools.package-data] +"*" = ["py.typed"] + +[tool.setuptools.packages.find] +namespaces = false +exclude = ["test", "tests", "doc", "docs", "resource", "resources", "example", "examples"] From 74845fe03c8d1d51c1c339e79b1c98d16717ee4a Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 18 Nov 2024 21:35:40 +0000 Subject: [PATCH 4/9] update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 7447e89..2c20cd0 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ + +[![PyPI](https://img.shields.io/pypi/v/icecube-simprod-histograms)](https://pypi.org/project/icecube-simprod-histograms/) [![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/icecube/simprod-histogram?include_prereleases)](https://github.com/icecube/simprod-histogram/) [![Versions](https://img.shields.io/pypi/pyversions/icecube-simprod-histograms.svg)](https://pypi.org/project/icecube-simprod-histograms) [![PyPI - License](https://img.shields.io/pypi/l/icecube-simprod-histograms)](https://github.com/icecube/simprod-histogram/blob/main/LICENSE) [![GitHub issues](https://img.shields.io/github/issues/icecube/simprod-histogram)](https://github.com/icecube/simprod-histogram/issues?q=is%3Aissue+sort%3Aupdated-desc+is%3Aopen) [![GitHub pull requests](https://img.shields.io/github/issues-pr/icecube/simprod-histogram)](https://github.com/icecube/simprod-histogram/pulls?q=is%3Apr+sort%3Aupdated-desc+is%3Aopen) + # simprod-histogram Utilities for working with histograms created for simprod From 96293a97b681e1e061499fec6b5760470039a4cd Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 18 Nov 2024 21:35:40 +0000 Subject: [PATCH 5/9] add py.typed file(s) --- scripts/py.typed | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 scripts/py.typed diff --git a/scripts/py.typed b/scripts/py.typed new file mode 100644 index 0000000..e69de29 From 489db4416d1e00e3db99215d6c21b1e61d38bf47 Mon Sep 17 00:00:00 2001 From: ric-evans Date: Mon, 18 Nov 2024 15:38:54 -0600 Subject: [PATCH 6/9] use toml --- .github/workflows/wipac-cicd.yaml | 2 +- pyproject.toml | 13 ++++++++++++- requirements-display.txt | 2 -- requirements-tests.txt | 3 --- requirements.txt | 1 - 5 files changed, 13 insertions(+), 8 deletions(-) delete mode 100644 requirements-display.txt delete mode 100644 requirements-tests.txt delete mode 100644 requirements.txt diff --git a/.github/workflows/wipac-cicd.yaml b/.github/workflows/wipac-cicd.yaml index 3c291d6..76c703a 100644 --- a/.github/workflows/wipac-cicd.yaml +++ b/.github/workflows/wipac-cicd.yaml @@ -110,7 +110,7 @@ jobs: with: python-version: ${{ matrix.py3 }} - run: | - pip install -r requirements-tests.txt + pip install .[tests] - name: Run unit tests run: | pytest -vvv tests/unit/ diff --git a/pyproject.toml b/pyproject.toml index 4aa44f4..f9a612c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] version = "0.0.0" -dependencies = [] +dependencies = ["h5py"] name = "icecube-simprod-histograms" description = "Utilities for working with histograms created for simprod" readme = "README.md" @@ -19,6 +19,17 @@ email = "developers@icecube.wisc.edu" [project.license] file = "LICENSE" +[project.optional-dependencies] +tests = [ + "h5py", + "pytest", + "matplotlib" +] +display = [ + "h5py", + "matplotlib" +] + [project.urls] Homepage = "https://pypi.org/project/icecube-simprod-histograms/" Tracker = "https://github.com/icecube/simprod-histogram/issues" diff --git a/requirements-display.txt b/requirements-display.txt deleted file mode 100644 index 5a23915..0000000 --- a/requirements-display.txt +++ /dev/null @@ -1,2 +0,0 @@ -h5py -matplotlib diff --git a/requirements-tests.txt b/requirements-tests.txt deleted file mode 100644 index ce32e75..0000000 --- a/requirements-tests.txt +++ /dev/null @@ -1,3 +0,0 @@ -h5py -pytest -matplotlib diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index c5a4eac..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -h5py From c155300e95bbd217fe626d06a9c9c5133e5c735b Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 18 Nov 2024 21:39:21 +0000 Subject: [PATCH 7/9] update pyproject.toml --- pyproject.toml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f9a612c..6bb4d68 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,15 +20,8 @@ email = "developers@icecube.wisc.edu" file = "LICENSE" [project.optional-dependencies] -tests = [ - "h5py", - "pytest", - "matplotlib" -] -display = [ - "h5py", - "matplotlib" -] +tests = ["h5py", "pytest", "matplotlib"] +display = ["h5py", "matplotlib"] [project.urls] Homepage = "https://pypi.org/project/icecube-simprod-histograms/" From e2bdfebc3479f15430d7f4321b808ba96bddbae6 Mon Sep 17 00:00:00 2001 From: ric-evans Date: Mon, 18 Nov 2024 15:41:16 -0600 Subject: [PATCH 8/9] setup.py --- setup.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 setup.py diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..d649009 --- /dev/null +++ b/setup.py @@ -0,0 +1,3 @@ +from setuptools import setup # type: ignore[import] + +setup() From 7f4421dc223209f24fce641478f5719e5a78290d Mon Sep 17 00:00:00 2001 From: ric-evans Date: Mon, 18 Nov 2024 15:44:59 -0600 Subject: [PATCH 9/9] add mypy dep --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 6bb4d68..c9d1e74 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,7 @@ file = "LICENSE" [project.optional-dependencies] tests = ["h5py", "pytest", "matplotlib"] +mypy = ["h5py", "pytest", "matplotlib"] display = ["h5py", "matplotlib"] [project.urls]