Skip to content

Commit 7a91c6b

Browse files
committed
Add action to upload to PyPI; Bugfixes
1 parent e08c860 commit 7a91c6b

File tree

4 files changed

+55
-7
lines changed

4 files changed

+55
-7
lines changed

.github/workflows/upload_pypi.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Upload PyPI wheels
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
deploy:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- name: Setup python
14+
uses: actions/setup-python@v1
15+
with:
16+
python-version: 3.7
17+
18+
- name: Install python dependencies
19+
run: |
20+
python -m pip install --upgrade pip
21+
python -m pip install twine
22+
23+
- name: Publish wheels to PyPI
24+
env:
25+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
26+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
27+
run: |
28+
twine upload pace_wheelhouse/*.whl

docs/developers.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ python setup.py install --user
3030

3131
The build will download the necessary Matlab packages (i.e. Horace and SpinW) and compile them.
3232
You will need a Matlab installation with the Matlab Compiler SDK toolbox installed.
33+
The Parallel Computation toolbox is also needed if you want build with Horace with `parpool` parallelisation.
34+
If you don't need this, also comment ou the relevant number in
35+
[make_package.m](https://github.com/pace-neutrons/pace-python/blob/main/installer/make_package.m#L13).
3336
In addition, you will need `cmake`, and a Matlab supported C compiler for your OS
3437
(generally `gcc-6`, `Visual Studio 2017` or `xcode-10.13` or newer).
3538

3639
Note that Matlab only supports [certain Python versions](https://www.mathworks.com/content/dam/mathworks/mathworks-dot-com/support/sysreq/files/python-compatibility.pdf).
37-
In particular, no Matlab versions supports Python 3.9, and only Matlab R2020b and newer supports Python 3.8.
40+
In particular, no Matlab versions supports Python 3.10 or higher, and only Matlab R2020b and newer supports Python 3.8.
3841

3942
The build will install `pace_neutrons` as a module which can be imported.
4043

@@ -53,7 +56,7 @@ If you have [chocolatey](https://chocolatey.org/) installed, you can install all
5356

5457
```
5558
choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System'
56-
choco install -y visualstudio2019community --package-parameters "--includeRecommended --add Microsoft.VisualStudio.Workload.NativeDesktop
59+
choco install -y visualstudio2019community --package-parameters "--includeRecommended --add Microsoft.VisualStudio.Workload.NativeDesktop"
5760
choco install -y miniconda git
5861
Invoke-WebRequest -Uri https://raw.githubusercontent.com/majkinetor/posh/master/MM_Admin/Invoke-Environment.ps1 -OutFile C:\windows\system32\Invoke-Environment.psm1
5962
```

pace_neutrons_cli/worker.py

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def _get_args():
5050
parser.add_argument('-nosplash', action='store_true', help='Do not show splash screen')
5151
parser.add_argument('-nojvm', action='store_true', help='Do not start JVM')
5252
parser.add_argument('-nodesktop', action='store_true', help='Do not start desktop')
53+
parser.add_argument('-softwareopengl', action='store_true', help='Use software OpenGL')
5354
parser.add_argument('ctrl_str', metavar='C', nargs='*', default='', help='Worker control string')
5455
return parser
5556

release.py

+21-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from importlib_resources import open_text
99
import yaml
1010
from pace_neutrons import __version__
11-
from pace_neutrons_cli.utils import release_exists
11+
from pace_neutrons_cli.utils import release_exists, download_github
1212

1313
def main():
1414
parser = get_parser()
@@ -58,11 +58,27 @@ def release_github(test=True):
5858

5959

6060
def release_pypi(test=True):
61-
subprocess.run(['rm','-r','dist'])
62-
subprocess.run(['rm','-r','build'])
63-
subprocess.run(['python', 'setup.py', 'sdist'])
61+
# Downloads wheels from github and upload to PyPI
62+
response = requests.get(
63+
'https://api.github.com/repos/pace-neutrons/pace-python/releases')
64+
# Get the latest release
65+
releases = response.json()
66+
ids = [r['id'] for r in releases]
67+
latest = [r for r in releases if r['id'] == max(ids)][0]
68+
# Creates a custom wheelhouse folder
69+
try:
70+
os.mkdir('pace_wheelhouse')
71+
except FileExistsError:
72+
pass
73+
# Loops through assets and downloads all the wheels
74+
headers = {"Accept":"application/octet-stream"}
75+
for asset in latest['assets']:
76+
if asset['name'].endswith('whl'):
77+
print('Downloading %s' % (asset['name']))
78+
localfile = os.path.join('pace_wheelhouse', asset['name'])
79+
download_github(asset['url'], localfile, use_auth=False)
6480
if not test:
65-
subprocess.run(['twine', 'upload', 'dist/*'])
81+
subprocess.run(['twine', 'upload', 'pace_wheelhouse/*'])
6682

6783

6884
def get_parser():

0 commit comments

Comments
 (0)