Skip to content

Commit ec2bf63

Browse files
committed
New release v32 (#144)
* Add despatch workflow to publish to pypi * Add release scripts and CI files * Fix typo in publish_pypi.yml
1 parent 415d143 commit ec2bf63

10 files changed

Lines changed: 366 additions & 25 deletions

File tree

.github/workflows/build_pyspinw.yml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: pySpinW
22

3-
on: [push, workflow_dispatch]
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master, development]
8+
types: [opened, reopened, synchronize]
9+
workflow_dispatch:
410

511
jobs:
612
compile_mex:
@@ -93,12 +99,6 @@ jobs:
9399
echo "PYSPINW_VERSION=$( cat pyproject.toml | grep "version = \"" | awk -F'"' '$0=$2' | sed 's/ //g' )" >> $GITHUB_ENV
94100
mkdir pyspinw/ctfs
95101
mv ctf/*.ctf pyspinw/ctfs
96-
- name: Update Versions
97-
if: startsWith(github.ref, 'refs/tags/v')
98-
run: |
99-
pip install poetry
100-
cd ${{ github.workspace }}/python
101-
poetry version $(git describe --tags --abbrev=0)
102102
- name: Build Wheel
103103
run: |
104104
cd ${{ github.workspace }}/python
@@ -119,11 +119,8 @@ jobs:
119119
with:
120120
name: pySpinW Wheel
121121
path: ${{ github.workspace }}/python/build/*.whl
122-
- uses: ncipollo/release-action@v1
123-
if: startsWith(github.ref, 'refs/tags/v')
124-
with:
125-
artifacts: ${{ github.workspace }}/python/build/*.whl
126-
prerelease: true
127-
replacesArtifacts: true
128-
name: "pySpinW"
129-
bodyFile: ${{ github.workspace }}/python/release_notes.md
122+
- name: Upload release wheels
123+
if: ${{ github.event_name == 'release' }}
124+
run: |
125+
pip3 install requests
126+
python3 release.py --notest --github --token=${{ secrets.GH_TOKEN }}

.github/workflows/publish_pypi.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Publish to PyPI
2+
3+
on: workflow_dispatch
4+
5+
jobs:
6+
pypi-publish:
7+
name: upload release to PyPI
8+
runs-on: ubuntu-latest
9+
permissions:
10+
# IMPORTANT: this permission is mandatory for trusted publishing
11+
id-token: write
12+
steps:
13+
- uses: actions/checkout@v3
14+
with:
15+
fetch-depth: 0
16+
- name: Download wheels
17+
run: |
18+
python3 -m pip install twine requests
19+
python3 release.py --pypi --token=${{ secrets.GH_TOKEN }}
20+
- name: Publish package distributions to PyPI
21+
uses: pypa/gh-action-pypi-publish@release/v1
22+
with:
23+
packages-dir: twine_wheelhouse
24+
verbose: true

.github/workflows/release.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Release SpinW
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
types: [closed]
7+
8+
jobs:
9+
create_release:
10+
name: Creates a SpinW release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
with:
15+
fetch-depth: 0
16+
- if: |
17+
contains(github.event.pull_request.title, 'RELEASE') &&
18+
github.event.pull_request.merged
19+
shell: bash -l {0}
20+
run: |
21+
pip3 install requests
22+
python3 release.py --notest --github --create_tag --token=${{ secrets.GH_TOKEN }}

.gitignore

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ dev/standalone/MacOS/Source/
2828
python/ctf
2929
.idea/
3030
**/*.pyc
31-
python/ctf
32-
.idea/
33-
**/*.pyc
31+
python/build/
32+
python/pyspinw/ctfs/
33+
34+
includedSupportPackages.txt
35+
mccExcludedFiles.log
36+
requiredMCRProducts.txt
37+
unresolvedSymbols.txt

CHANGELOG.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# [v3.2.0](https://github.com/pace-neutrons/libpymcr/compare/0.0.1...v3.2.0)
2+
3+
## Initial public beta of PySpinW
4+
5+
This is an initial public beta version of PySpinW released on PyPI.
6+
7+
Please install using:
8+
9+
```bash
10+
pip install spinw
11+
```
12+
13+
This will install a module called `pyspinw` (note the `py` at the start).
14+
15+
You can then run SpinW with:
16+
17+
```python
18+
import numpy as np
19+
import matplotlib.pyplot as plt
20+
from pyspinw import Matlab
21+
m = Matlab()
22+
swobj = m.spinw()
23+
swobj.genlattice('lat_const', [3, 3, 6], 'angled', [90, 90, 120], 'sym', 'P 1');
24+
swobj.addatom('r', [0, 0, 0], 'S', 1/2, 'label', 'MCu2')
25+
swobj.gencoupling('maxDistance', 5)
26+
swobj.addmatrix('label', 'J1', 'value', 1.00, 'color', 'g')
27+
swobj.addcoupling('mat', 'J1', 'bond', 1)
28+
swobj.genmagstr('mode', 'helical', 'k', [-1/3, -1/3, 0], 'n',[0, 0, 1], 'unit', 'lu', 'S', [[1], [0], [0]])
29+
spec = swobj.spinwave([[-1/2, 0, 0], [0, 0, 0], [1/2, 1/2, 0], 100], 'hermit', False)
30+
spec = m.sw_egrid(spec, 'component', 'Sxx+Syy', 'imagChk', False, 'Evect', np.linspace(0, 3, 100))
31+
ax = plt.imshow(np.real(np.flipud(spec['swConv'])), aspect='auto', vmax=1)
32+
plt.show()
33+
```
34+
35+
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).
36+
37+
38+
# [v0.0.1](https://github.com/spinw/spinw/compare/v3.1.2...0.0.1)
39+
40+
## pySpinW
41+
42+
This is an initial release of pySpinW as a `pip` installable wheel for python >= 3.8 and MATLAB >= R2021a
43+
44+
### Installation
45+
46+
Please install with
47+
48+
```bash
49+
pip install pyspinw*.whl
50+
```
51+
52+
This package can now be used in python if you have a version of MATLAB or MCR available on the machine.
53+
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.
54+
55+
```python
56+
from pyspinw import Matlab
57+
m = Matlab(matlab_version='R2023a', matlab_path='/usr/local/MATLAB/R2023a/')
58+
```
59+
60+
### Example
61+
62+
An example would be:
63+
64+
```python
65+
import numpy as np
66+
from pyspinw import Matlab
67+
68+
m = Matlab()
69+
70+
# Create a spinw model, in this case a triangular antiferromagnet
71+
s = m.sw_model('triAF', 1)
72+
73+
# Specify the start and end points of the q grid and the number of points
74+
q_start = [0, 0, 0]
75+
q_end = [1, 1, 0]
76+
pts = 501
77+
78+
# Calculate the spin wave spectrum
79+
spec = m.spinwave(s, [q_start, q_end, pts])
80+
```
81+
82+
### Known limitations
83+
84+
At the moment graphics will not work on macOS systems and is disabled.

CITATION.cff

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
cff-version: "1.1.0"
2+
message: "If you have used SpinW in your research, please cite it as below"
3+
abstract: "SpinW is a library for spin wave calculations"
4+
authors:
5+
- family-names: "Tóth"
6+
given-names: "Sándor"
7+
orcid: "https://orcid.org/0000-0002-7174-9399"
8+
- family-names: "Ward"
9+
given-names: "Simon"
10+
orcid: "https://orcid.org/0000-0001-7127-5763"
11+
- family-names: "Le"
12+
given-names: "Manh Duc"
13+
orcid: "https://orcid.org/0000-0003-3012-6053"
14+
- family-names: "Fair"
15+
given-names: "Rebecca L."
16+
orcid: "https://orcid.org/0000-0002-0926-2942"
17+
- family-names: "Waite"
18+
given-names: "Richard"
19+
title: "libpymcr"
20+
version: "3.2.0"
21+
date-released: "2023-06-12"
22+
license: "GPL-3.0-only"
23+
repository: "https://github.com/spinw/spinw"
24+
url: "https://www.spinw.org"
25+
keywords:
26+
- "Python"
27+
- "Matlab"
28+
File renamed without changes.

python/pyproject.toml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
[build-system]
2-
requires = ["poetry-core"]
3-
build-backend = "poetry.core.masonry.api"
2+
requires = [
3+
"poetry-core",
4+
"poetry-dynamic-versioning",
5+
]
6+
build-backend = "poetry_dynamic_versioning.backend"
47

58
[tool.black]
69
line-length = 88
@@ -19,13 +22,18 @@ source = ['pyspinw']
1922
organization = 'spinw'
2023
repo = 'spinw'
2124

25+
[tool.poetry-dynamic-versioning]
26+
enable = true
27+
vcs = "git"
28+
style = "semver"
29+
2230
[tool.poetry]
23-
name = "pyspinw"
24-
version = "0.0.2"
31+
name = "spinw"
32+
version = "0.0.0"
2533
description = "Python library for spin wave calculations"
2634
license = "BSD-3-Clause"
27-
authors = ["Duc Le", "Simon Ward", "Richard Waite"]
28-
readme = "../README.md"
35+
authors = ["Sándor Tóth", "Duc Le", "Simon Ward", "Becky Fair", "Richard Waite"]
36+
readme = "README.md"
2937
homepage = "https://spinw.org"
3038
classifiers = [
3139
"Development Status :: 3 - Alpha",
@@ -35,6 +43,7 @@ classifiers = [
3543
"Programming Language :: Python :: 3 :: Only",
3644
]
3745
packages = [ { include = "pyspinw" } ]
46+
include = [ { path = "pyspinw/ctfs/*" } ]
3847

3948
[tool.poetry.dependencies]
4049
python = ">=3.8,<=3.12"

python/pyspinw/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
__author__ = "github.com/wardsimon"
4-
__version__ = "0.1.0"
4+
__version__ = "0.0.0"
55

66
import os
77
import libpymcr

0 commit comments

Comments
 (0)