164 lines (146 loc) · 6.24 KB
/
python-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Test Build wheels and Deploy
# Build on every branch push, tag push, and pull request change:
on: [push, pull_request]
# Alternatively, to publish when a (published) GitHub Release is created, use the following:
# on:
# push:
# pull_request:
# release:
# types:
# - published
jobs:
test_code:
runs-on: ubuntu-latest
env:
working-directory: ./python
strategy:
matrix:
python-version: [ 3.7 ]
#python-version: [ 3.7, 3.8, 3.9 ]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
working-directory: ${{env.working-directory}}
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
working-directory: ${{env.working-directory}}
- name: Build c extensions
run: |
# python setup.py build_ext --inplace
python setup.py install
working-directory: ${{env.working-directory}}
- name: Test with pytest
run: |
# pytest test
cd unittest
pytest
working-directory: ${{env.working-directory}}
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
working-directory: ./python
needs: [ test_code ]
#if: github.ref == 'refs/heads/master'
strategy:
matrix:
#os: [ubuntu-20.04, windows-2019, macos-10.15]
os: [windows-2019]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: copy data to root (unix-like)
run: |
ls -la
cp -r ${{env.working-directory}}/* .
continue-on-error: true
- uses: suisei-cn/actions-download-file@v1
id: downloadfile # Remember to give an ID if you need the output filename
name: Download the file
with:
url: "https://icl.cs.utk.edu/lapack-for-windows/libraries/VisualStudio/3.7.0/Dynamic-MINGW/Win64/libblas.lib"
- name: copy data to root (windows)
run: |
xcopy .\python\* . /E /C /H /R /K /O /Y
curl -OutFile libblas.lib "https://icl.cs.utk.edu/lapack-for-windows/libraries/VisualStudio/3.7.0/Dynamic-MINGW/Win64/libblas.lib"
curl -OutFile liblapack.lib "https://icl.cs.utk.edu/lapack-for-windows/libraries/VisualStudio/3.7.0/Dynamic-MINGW/Win64/liblapack.lib"
continue-on-error: true
- name: Build wheels
uses: pypa/cibuildwheel@v2.4.0
env:
CIBW_BEFORE_BUILD: pip install numpy==1.19.5
CIBW_BUILD: cp36-* cp37-* cp38-*
CIBW_BEFORE_ALL_MACOS: brew reinstall gcc
CIBW_BEFORE_ALL_LINUX: yum install -y lapack-devel blas-devel; apt-get install -y libblas-dev liblapack-dev; apk add openblas-dev; apk add lapack-dev; echo "import platform; print(platform.platform())" | python
#CIBW_BEFORE_ALL_WINDOWS: >
# curl -OutFile libblas.lib https://icl.cs.utk.edu/lapack-for-windows/libraries/VisualStudio/3.7.0/Dynamic-MINGW/Win64/libblas.lib &&
# curl -OutFile liblapack.lib https://icl.cs.utk.edu/lapack-for-windows/libraries/VisualStudio/3.7.0/Dynamic-MINGW/Win64/liblapack.lib CIBW_SKIP: "*-musllinux_* *win32*"
#working-directory: ${{env.working-directory}}
- name: Build wheels
uses: pypa/cibuildwheel@v2.4.0
env:
CIBW_BEFORE_BUILD: pip install numpy==1.21.6
CIBW_BUILD: cp39-* cp310-*
CIBW_ARCHS_MACOS: x86_64
CIBW_BEFORE_ALL_MACOS: brew reinstall gcc
CIBW_BEFORE_ALL_LINUX: yum install -y lapack-devel blas-devel; apt-get install -y libblas-dev liblapack-dev; apk add openblas-dev; apk add lapack-dev; echo "import platform; print(platform.platform())" | python
#CIBW_BEFORE_ALL_WINDOWS: >
# curl -OutFile libblas.lib https://icl.cs.utk.edu/lapack-for-windows/libraries/VisualStudio/3.7.0/Dynamic-MINGW/Win64/libblas.lib &&
# curl -OutFile liblapack.lib https://icl.cs.utk.edu/lapack-for-windows/libraries/VisualStudio/3.7.0/Dynamic-MINGW/Win64/liblapack.lib CIBW_SKIP: "*-musllinux_* *win32*"
#working-directory: ${{env.working-directory}}
- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl
build_sdist:
name: Build source distribution
needs: [ test_code ]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install numpy
working-directory: ${{env.working-directory}}
- name: Build sdist
run: |
python setup.py sdist
working-directory: ${{env.working-directory}}
- uses: actions/upload-artifact@v2
with:
path: dist/*.tar.gz
upload_pypi:
needs: [build_wheels, build_sdist, test_code]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
# upload to PyPI on every tag starting with 'v'
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
# alternatively, to publish when a GitHub Release is created, use the following rule:
# if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
# repository_url: https://test.pypi.org/legacy/
skip_existing: true