Skip to content

Commit

Permalink
New release v32 (#144)
Browse files Browse the repository at this point in the history
* Add despatch workflow to publish to pypi

* Add release scripts and CI files

* Fix typo in publish_pypi.yml
  • Loading branch information
mducle committed Jun 12, 2023
1 parent 415d143 commit df2a40d
Show file tree
Hide file tree
Showing 10 changed files with 366 additions and 25 deletions.
27 changes: 12 additions & 15 deletions .github/workflows/build_pyspinw.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: pySpinW

on: [push, workflow_dispatch]
on:
push:
branches: [master]
pull_request:
branches: [master, development]
types: [opened, reopened, synchronize]
workflow_dispatch:

jobs:
compile_mex:
Expand Down Expand Up @@ -93,12 +99,6 @@ jobs:
echo "PYSPINW_VERSION=$( cat pyproject.toml | grep "version = \"" | awk -F'"' '$0=$2' | sed 's/ //g' )" >> $GITHUB_ENV
mkdir pyspinw/ctfs
mv ctf/*.ctf pyspinw/ctfs
- name: Update Versions
if: startsWith(github.ref, 'refs/tags/v')
run: |
pip install poetry
cd ${{ github.workspace }}/python
poetry version $(git describe --tags --abbrev=0)
- name: Build Wheel
run: |
cd ${{ github.workspace }}/python
Expand All @@ -119,11 +119,8 @@ jobs:
with:
name: pySpinW Wheel
path: ${{ github.workspace }}/python/build/*.whl
- uses: ncipollo/release-action@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
artifacts: ${{ github.workspace }}/python/build/*.whl
prerelease: true
replacesArtifacts: true
name: "pySpinW"
bodyFile: ${{ github.workspace }}/python/release_notes.md
- name: Upload release wheels
if: ${{ github.event_name == 'release' }}
run: |
pip3 install requests
python3 release.py --notest --github --token=${{ secrets.GH_TOKEN }}
24 changes: 24 additions & 0 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publish to PyPI

on: workflow_dispatch

jobs:
pypi-publish:
name: upload release to PyPI
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download wheels
run: |
python3 -m pip install twine requests
python3 release.py --pypi --token=${{ secrets.GH_TOKEN }}
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: twine_wheelhouse
verbose: true
22 changes: 22 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release SpinW

on:
pull_request:
branches: [master]
types: [closed]

jobs:
create_release:
name: Creates a SpinW release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- if: |
contains(github.event.pull_request.title, 'RELEASE') &&
github.event.pull_request.merged
shell: bash -l {0}
run: |
pip3 install requests
python3 release.py --notest --github --create_tag --token=${{ secrets.GH_TOKEN }}
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ dev/standalone/MacOS/Source/
python/ctf
.idea/
**/*.pyc
python/ctf
.idea/
**/*.pyc
python/build/
python/pyspinw/ctfs/

includedSupportPackages.txt
mccExcludedFiles.log
requiredMCRProducts.txt
unresolvedSymbols.txt
84 changes: 84 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# [v3.2.0](https://github.com/pace-neutrons/libpymcr/compare/0.0.1...v3.2.0)

## Initial public beta of PySpinW

This is an initial public beta version of PySpinW released on PyPI.

Please install using:

```bash
pip install spinw
```

This will install a module called `pyspinw` (note the `py` at the start).

You can then run SpinW with:

```python
import numpy as np
import matplotlib.pyplot as plt
from pyspinw import Matlab
m = Matlab()
swobj = m.spinw()
swobj.genlattice('lat_const', [3, 3, 6], 'angled', [90, 90, 120], 'sym', 'P 1');
swobj.addatom('r', [0, 0, 0], 'S', 1/2, 'label', 'MCu2')
swobj.gencoupling('maxDistance', 5)
swobj.addmatrix('label', 'J1', 'value', 1.00, 'color', 'g')
swobj.addcoupling('mat', 'J1', 'bond', 1)
swobj.genmagstr('mode', 'helical', 'k', [-1/3, -1/3, 0], 'n',[0, 0, 1], 'unit', 'lu', 'S', [[1], [0], [0]])
spec = swobj.spinwave([[-1/2, 0, 0], [0, 0, 0], [1/2, 1/2, 0], 100], 'hermit', False)
spec = m.sw_egrid(spec, 'component', 'Sxx+Syy', 'imagChk', False, 'Evect', np.linspace(0, 3, 100))
ax = plt.imshow(np.real(np.flipud(spec['swConv'])), aspect='auto', vmax=1)
plt.show()
```

On Windows and Linux systems, as long as you're running PySpinW locally, Matlab plotting commands like `m.plot(swobj)` will work. This is not the case on MacOS (a known bug) and on remote systems (e.g. via JupyterHub).


# [v0.0.1](https://github.com/spinw/spinw/compare/v3.1.2...0.0.1)

## pySpinW

This is an initial release of pySpinW as a `pip` installable wheel for python >= 3.8 and MATLAB >= R2021a

### Installation

Please install with

```bash
pip install pyspinw*.whl
```

This package can now be used in python if you have a version of MATLAB or MCR available on the machine.
The package will try to automatically detect your installation, however if it is in a non-standard location, the path and version will have to be specified.

```python
from pyspinw import Matlab
m = Matlab(matlab_version='R2023a', matlab_path='/usr/local/MATLAB/R2023a/')
```

### Example

An example would be:

```python
import numpy as np
from pyspinw import Matlab

m = Matlab()

# Create a spinw model, in this case a triangular antiferromagnet
s = m.sw_model('triAF', 1)

# Specify the start and end points of the q grid and the number of points
q_start = [0, 0, 0]
q_end = [1, 1, 0]
pts = 501

# Calculate the spin wave spectrum
spec = m.spinwave(s, [q_start, q_end, pts])
```

### Known limitations

At the moment graphics will not work on macOS systems and is disabled.
28 changes: 28 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cff-version: "1.1.0"
message: "If you have used SpinW in your research, please cite it as below"
abstract: "SpinW is a library for spin wave calculations"
authors:
- family-names: "Tóth"
given-names: "Sándor"
orcid: "https://orcid.org/0000-0002-7174-9399"
- family-names: "Ward"
given-names: "Simon"
orcid: "https://orcid.org/0000-0001-7127-5763"
- family-names: "Le"
given-names: "Manh Duc"
orcid: "https://orcid.org/0000-0003-3012-6053"
- family-names: "Fair"
given-names: "Rebecca L."
orcid: "https://orcid.org/0000-0002-0926-2942"
- family-names: "Waite"
given-names: "Richard"
title: "libpymcr"
version: "3.2.0"
date-released: "2023-06-12"
license: "GPL-3.0-only"
repository: "https://github.com/spinw/spinw"
url: "https://www.spinw.org"
keywords:
- "Python"
- "Matlab"

File renamed without changes.
21 changes: 15 additions & 6 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = [
"poetry-core",
"poetry-dynamic-versioning",
]
build-backend = "poetry_dynamic_versioning.backend"

[tool.black]
line-length = 88
Expand All @@ -19,13 +22,18 @@ source = ['pyspinw']
organization = 'spinw'
repo = 'spinw'

[tool.poetry-dynamic-versioning]
enable = true
vcs = "git"
style = "semver"

[tool.poetry]
name = "pyspinw"
version = "0.0.2"
name = "spinw"
version = "0.0.0"
description = "Python library for spin wave calculations"
license = "BSD-3-Clause"
authors = ["Duc Le", "Simon Ward", "Richard Waite"]
readme = "../README.md"
authors = ["Sándor Tóth", "Duc Le", "Simon Ward", "Becky Fair", "Richard Waite"]
readme = "README.md"
homepage = "https://spinw.org"
classifiers = [
"Development Status :: 3 - Alpha",
Expand All @@ -35,6 +43,7 @@ classifiers = [
"Programming Language :: Python :: 3 :: Only",
]
packages = [ { include = "pyspinw" } ]
include = [ { path = "pyspinw/ctfs/*" } ]

[tool.poetry.dependencies]
python = ">=3.8,<=3.12"
Expand Down
2 changes: 1 addition & 1 deletion python/pyspinw/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

__author__ = "github.com/wardsimon"
__version__ = "0.1.0"
__version__ = "0.0.0"

import os
import libpymcr
Expand Down
Loading

0 comments on commit df2a40d

Please sign in to comment.