Skip to content

Commit

Permalink
Fix gh-actions (#2)
Browse files Browse the repository at this point in the history
* Fix gh-actions

* Fix CI for macos-latest (cross-compile fails)

* Add versioneer

* Remove debug info in default builds

* Add release scripts

* Fix sprintf compiler warning

* Cleanup CI scripts
  • Loading branch information
mducle authored Sep 5, 2024
1 parent d6c14e7 commit 5598bb1
Show file tree
Hide file tree
Showing 13 changed files with 3,260 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
libmcphase/_version.py export-subst
46 changes: 32 additions & 14 deletions .github/workflows/build_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,42 @@ jobs:
build_and_test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
name: Build and test, ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: mamba-org/setup-micromamba@v1
with:
cache-downloads: true
- name: Build wheels
uses: pypa/cibuildwheel@v2
run: |
$MAMBA_EXE create -n cibuildwheel python=3.12
eval "$($MAMBA_EXE shell activate cibuildwheel)"
python -m pip install cibuildwheel
if [[ $OSTYPE == "darwin23" ]] || [[ $OSTYPE == "darwin22" ]]
then
# For some reason cibuildwheel on builds 3.9-3.12 arm64 on macos-latest
export CIBW_BUILD="cp39* cp310* cp311* cp312*"
fi
python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: "cp38-* cp39* cp310-* cp311-* cp312-*"
CIBW_SKIP: "*musllinux* *win32* *i686*"
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
CIBW_ARCHS_MACOS: "native"
CIBW_BUILD_VERBOSITY: 1
- uses: mamba-org/setup-micromamba@v1
with:
cache-downloads: true
- name: Install wheels and run test
run: |
# set -e makes sure the script fails if any command in the loop fails
set -e
for pyver in 3.8 3.9 3.10 3.11 3.12
if [[ $OSTYPE == "darwin23" ]] || [[ $OSTYPE == "darwin22" ]]
then
export PYVERS="3.9 3.10 3.11 3.12"
else
export PYVERS="3.8 3.9 3.10 3.11 3.12"
fi
for pyver in $PYVERS
do
$MAMBA_EXE create -n py$pyver -c conda-forge python=$pyver numpy
eval "$($MAMBA_EXE shell activate py$pyver)"
Expand All @@ -52,17 +67,20 @@ jobs:
python -m unittest
cd ..
done
- name: Upload release wheels
if: |
contains(github.event.pull_request.title, 'RELEASE') &&
github.event.pull_request.merged
run: |
python -m pip install requests numpy
python release.py --notest --github --create_tag --token=${{ secrets.GH_TOKEN }}
- uses: actions/upload-artifact@v4
if: |
${{ github.event_name == 'pull_request' }} &&
contains(github.event.pull_request.labels.*.name, 'save_wheels')
with:
name: ${{ matrix.os }}_artifacts.zip
path: wheelhouse/*
#- name: Setup tmate
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
#- name: Publish wheels to PyPI
# if: ${{ github.event_name == 'release' }}
# env:
# TWINE_USERNAME: __token__
# TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
# run: |
# twine upload wheelhouse/*
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release libmcphase on PyPI

on:
workflow_dispatch:

defaults:
run:
shell: bash -l {0}

jobs:
create_release:
name: Creates a PyPI release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
- name: Publish wheels to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m pip install --upgrade pip
python -m pip install twine requests numpy
python release.py --notest --pypi
twine upload twine_wheelhouse/*.whl
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
### [v0.1.3](https://github.com/mducle/libmcphase/compare/v0.1.2...v0.1.3)

Library / dependencies update

* Update build system - now supports MacOS (Intel and ARM).
* Cleans up some compiler warnings

Example scripts (after installing with `pip install libmcphase`)

```
import libmcphase
cfp = libmcphase.cf1ion('Pr3+', B20=0.1, B40=0.01, B60=0.001, B66=-0.02)
V, E = cfp.eigensystem()
print(E)
```


### [v0.1.2](https://github.com/mducle/libmcphase/compare/v0.1.0...v0.1.2)

Pre-alpha release with only single-ion calculations of energy levels and some physical properties (magnetisation, susceptibility).

Very little documentation.


### [v0.1.0](https://github.com/mducle/libmcphase/compare/08c4a2e22b61c145b841ca531c7a11a3959d10fa...v0.1.0)

Initial commit of libmcphase.

* Reorganised McPhase code and changed directory structure.
* Rewrite of `cf1ion` module to remove old Fabi code and use 3j/6j symbols.
* Python interface using Pybind11.
19 changes: 19 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cff-version: "1.1.0"
message: "If you have used libmcphase in your research, please cite it as below"
abstract: "libmcphase is Python library for calculating magnetic properties of rare earth compounds"
authors:
- family-names: "Rotter"
given-names: "Martin"
- family-names: "Le"
given-names: "Manh Duc"
orcid: "https://orcid.org/0000-0003-3012-6053"
title: "libmcphase"
version: "0.1.3"
date-released: "2024-09-05"
license: "GPL-3.0-only"
repository: "https://github.com/mducle/libmcphase"
url: "https://github.com/mducle/libmcphase"
keywords:
- "Python"
- "Condensed Matter Physics"
- "Rare Earth Magnets"
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

3 changes: 3 additions & 0 deletions libmcphase/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
from .libmcphase import *

from . import _version
__version__ = _version.get_versions()['version']
Loading

0 comments on commit 5598bb1

Please sign in to comment.