Skip to content

Commit dbb9fea

Browse files
Merge pull request #324 from astro-informatics/automatic_release
Automatic release implementation plus add new papers to readme
2 parents a32962e + 5b6adc1 commit dbb9fea

File tree

7 files changed

+154
-9
lines changed

7 files changed

+154
-9
lines changed

.github/workflows/build.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Adapted from example at
2+
# https://github.com/pypa/cibuildwheel/blob/0319c431dedc020eb/examples/github-deploy.yml
3+
#
4+
# Original license:
5+
#
6+
# This project is licensed under the 'BSD 2-clause license'.
7+
#
8+
# Copyright (c) 2017-2023, Joe Rickerby and contributors. All rights reserved.
9+
#
10+
# Redistribution and use in source and binary forms, with or without
11+
# modification, are permitted provided that the following conditions are met:
12+
#
13+
# 1. Redistributions of source code must retain the above copyright notice, this
14+
# list of conditions and the following disclaimer.
15+
#
16+
# 2. Redistributions in binary form must reproduce the above copyright notice,
17+
# this list of conditions and the following disclaimer in the documentation
18+
# and/or other materials provided with the distribution.
19+
#
20+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
31+
name: Build (and upload to PyPI for published releases)
32+
33+
on:
34+
workflow_dispatch:
35+
pull_request:
36+
push:
37+
branches:
38+
- main
39+
release:
40+
types:
41+
- published
42+
43+
jobs:
44+
build_wheels:
45+
name: Build wheels on ${{ matrix.os }}
46+
runs-on: ${{ matrix.os }}
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
os: [ubuntu-latest, macos-latest]
51+
52+
steps:
53+
- uses: actions/checkout@v5.0.0
54+
with:
55+
fetch-depth: 0
56+
fetch-tags: true
57+
- name: Build wheels
58+
uses: pypa/cibuildwheel@v3.1.4
59+
- uses: actions/upload-artifact@v4
60+
with:
61+
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
62+
path: ./wheelhouse/*.whl
63+
64+
build_sdist:
65+
name: Build source distribution
66+
runs-on: ubuntu-latest
67+
steps:
68+
- uses: actions/checkout@v5.0.0
69+
with:
70+
fetch-depth: 0
71+
fetch-tags: true
72+
- name: Build sdist
73+
run: pipx run build --sdist
74+
- uses: actions/upload-artifact@v4
75+
with:
76+
name: cibw-sdist
77+
path: dist/*.tar.gz
78+
79+
upload_test_pypi:
80+
needs: [build_wheels, build_sdist]
81+
runs-on: ubuntu-latest
82+
environment: test-pypi
83+
permissions:
84+
id-token: write
85+
if: |
86+
(github.event_name == 'release' && github.event.action == 'published') ||
87+
(github.event_name == 'push' && github.ref == 'refs/heads/main')
88+
steps:
89+
- uses: actions/download-artifact@v5
90+
with:
91+
# Unpack all CIBW artifacts (wheels) into dist/
92+
# pypa/gh-action-pypi-publish action uploads contents of dist/ unconditionally
93+
pattern: cibw-*
94+
path: dist
95+
merge-multiple: true
96+
# Try publishing to Test PyPI first - if there are issues this should
97+
# cause job to fail before attempting to publish on PyPI itself
98+
- name: Publish package distribution to Test PyPI
99+
uses: pypa/gh-action-pypi-publish@release/v1
100+
with:
101+
repository-url: https://test.pypi.org/legacy/
102+
verbose: true
103+
104+
upload_pypi:
105+
needs: [build_wheels, build_sdist, upload_test_pypi]
106+
runs-on: ubuntu-latest
107+
environment: pypi
108+
permissions:
109+
id-token: write
110+
if: github.event_name == 'release' && github.event.action == 'published'
111+
steps:
112+
- uses: actions/download-artifact@v5
113+
with:
114+
pattern: cibw-*
115+
path: dist
116+
merge-multiple: true
117+
- name: Publish package distribution to PyPI
118+
uses: pypa/gh-action-pypi-publish@release/v1
File renamed without changes.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ docs/assets/static_notebooks/.temp.*
1717
dist/
1818
harmonic.egg-info/
1919
harmonic/examples/data/NUTS
20+
harmonic/_version.py

README.rst

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@
1818
:target: https://arxiv.org/abs/2307.00048
1919
.. |arxiv4| image:: http://img.shields.io/badge/arXiv-2405.05969-orange.svg?style=flat
2020
:target: https://arxiv.org/abs/2405.05969
21+
.. |arxiv5| image:: http://img.shields.io/badge/arXiv-2410.21076-orange.svg?style=flat
22+
:target: https://arxiv.org/abs/2410.21076
23+
.. |arxiv6| image:: http://img.shields.io/badge/arXiv-2506.04339-orange.svg?style=flat
24+
:target: https://arxiv.org/abs/2506.04339
2125
.. .. image:: https://img.shields.io/pypi/pyversions/harmonic.svg
2226
.. :target: https://pypi.python.org/pypi/harmonic/
2327
24-
|github| |tests| |docs| |codecov| |pypi| |licence| |arxiv1| |arxiv2| |arxiv3| |arxiv4|
28+
|github| |tests| |docs| |codecov| |pypi| |licence| |arxiv1| |arxiv2| |arxiv3| |arxiv4| |arxiv5| |arxiv6|
2529

2630

2731
|logo|
@@ -30,9 +34,9 @@
3034
:width: 90
3135
=================================================================================================================
3236

33-
``harmonic`` is an open source, well tested and documented Python implementation of the *learnt harmonic mean estimator* (`McEwen et al. 2021 <https://arxiv.org/abs/2111.12720>`_) to compute the marginal likelihood (Bayesian evidence), required for Bayesian model selection.
37+
``harmonic`` is an open source, well tested and documented Python implementation of the *learned harmonic mean estimator* (`McEwen et al. 2021 <https://arxiv.org/abs/2111.12720>`_) to compute the marginal likelihood (Bayesian evidence), required for Bayesian model selection.
3438

35-
For an accessible overview of the *learnt harmonic mean estimator* please see this `Towards Data Science article <https://towardsdatascience.com/learnt-harmonic-mean-estimator-for-bayesian-model-selection-47258bb0fc2e>`_.
39+
For an accessible overview of the *learned harmonic mean estimator* please see this `Towards Data Science article <https://towardsdatascience.com/learnt-harmonic-mean-estimator-for-bayesian-model-selection-47258bb0fc2e>`_.
3640

3741
While ``harmonic`` requires only posterior samples, and so is agnostic to the technique used to perform Markov chain Monte Carlo (MCMC) sampling, ``harmonic`` works well with MCMC sampling techniques that naturally provide samples from multiple chains by their ensemble nature, such as affine invariant ensemble samplers. For instance, ``harmonic`` can be used with the popular `emcee <https://github.com/dfm/emcee>`_ code implementing the affine invariant sampler of `Goodman & Weare (2010) <https://cims.nyu.edu/~weare/papers/d13.pdf>`_, or the `NumPyro <https://github.com/pyro-ppl/numpyro>`_ code implementing various MCMC algorithms.
3842

@@ -146,6 +150,22 @@ A BibTeX entry for the paper is:
146150
year = {2023}
147151
}
148152
153+
Please *also* cite `Lin et al. (2025) <https://arxiv.org/abs/2506.04339>`_ if using the Savage-Dickey density ratio estimation.
154+
155+
A BibTeX entry for the paper is:
156+
157+
.. code-block::
158+
159+
@article{spurio-mancini:harmonic_sddr,
160+
title={{S}avage-{D}ickey density ratio estimation with normalizing flows for {B}ayesian model comparison},
161+
author={Kiyam Lin and Alicja Polanska and Davide Piras and Alessio Spurio Mancini and Jason D. McEwen},
162+
year={2025},
163+
eprint={2506.04339},
164+
archivePrefix={arXiv},
165+
primaryClass={astro-ph.CO},
166+
url={https://arxiv.org/abs/2506.04339},
167+
}
168+
149169
150170
License
151171
=======

pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "numpy", "Cython"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["setuptools", "setuptools-scm", "wheel", "numpy", "Cython"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.setuptools_scm]
6+
local_scheme = "no-local-version"
7+
write_to = "harmonic/_version.py"

requirements/requirements-core.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
numpy
22
setuptools==68.0.0
3+
setuptools-scm
34
wheel==0.41.0
45
cython>=0.29.30
56
ipython>=8.4.0

setup.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@ def read_file(file):
3838

3939
setup(
4040
classifiers=[
41-
"Programming Language :: Python :: 3.9",
42-
"Programming Language :: Python :: 3.10",
4341
"Programming Language :: Python :: 3.11",
42+
"Programming Language :: Python :: 3.12",
43+
"Programming Language :: Python :: 3.13",
4444
"Operating System :: OS Independent",
4545
"Intended Audience :: Developers",
4646
"Intended Audience :: Science/Research",
4747
],
48+
python_requires='>=3.11, <3.14',
4849
name="harmonic",
49-
version="1.3.0",
5050
prefix=".",
5151
url="https://github.com/astro-informatics/harmonic",
52-
author="Jason D. McEwen, Alicja Polanska, Christopher G. R. Wallis, Matthew A. Price, Matthew M. Docherty & Contributors",
52+
author="Jason D. McEwen, Alicja Polanska, Christopher G. R. Wallis, Matthew A. Price, Matthew M. Docherty, Kiyam Lin, Zixiao Hu & Contributors",
5353
author_email="jason.mcewen@ucl.ac.uk",
5454
license="GNU General Public License v3 (GPLv3)",
5555
install_requires=required,
@@ -60,6 +60,7 @@ def read_file(file):
6060
include_package_data=True,
6161
package_data={"harmonic": ["default-logging-config.yaml"]},
6262
cmdclass={"build_ext": build_ext},
63+
dynamic = ["version",],
6364
ext_modules=cythonize(
6465
[
6566
Extension(

0 commit comments

Comments
 (0)