Skip to content

Commit 8111c28

Browse files
Merge pull request #49 from labscript-suite/conda
Add standard workflow and move setup requires into pyproject.toml
2 parents b348e92 + 8067b83 commit 8111c28

File tree

3 files changed

+217
-23
lines changed

3 files changed

+217
-23
lines changed

.github/workflows/release.yml

Lines changed: 213 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
name: Build and release
1+
name: Build and Release
2+
23
on:
34
push:
45
branches:
@@ -12,46 +13,206 @@ defaults:
1213
run:
1314
shell: bash
1415

16+
env:
17+
PACKAGE_NAME: labscript-utils
18+
SCM_VERSION_SCHEME: release-branch-semver
19+
SCM_LOCAL_SCHEME: no-local-version
20+
ANACONDA_USER: labscript-suite
21+
22+
# Configuration for a package with compiled extensions:
23+
# PURE: false
24+
# NOARCH: false
25+
26+
# Configuration for a package with no extensions, but with dependencies that differ by
27+
# platform or Python version:
28+
# PURE: true
29+
# NOARCH: false
30+
31+
# Configuration for a package with no extensions and the same dependencies on all
32+
# platforms and Python versions. For this configuration you should comment out all but
33+
# the first entry in the job matrix of the build job since multiple platforms are not
34+
# needed.
35+
PURE: true
36+
NOARCH: true
37+
1538
jobs:
1639
build:
17-
name: Build and Release
18-
runs-on: ubuntu-latest
19-
env:
20-
PACKAGE_NAME: labscript-utils
21-
SCM_VERSION_SCHEME: release-branch-semver
22-
SCM_LOCAL_SCHEME: no-local-version
40+
name: Build
41+
runs-on: ${{ matrix.os }}
42+
strategy:
43+
matrix:
44+
include:
45+
- { os: ubuntu-latest, python: 3.8, arch: x64 }
46+
# - { os: ubuntu-latest, python: 3.7, arch: x64 }
47+
# - { os: ubuntu-latest, python: 3.6, arch: x64 }
48+
49+
# - { os: macos-latest, python: 3.8, arch: x64 }
50+
# - { os: macos-latest, python: 3.7, arch: x64 }
51+
# - { os: macos-latest, python: 3.6, arch: x64 }
52+
53+
# - { os: windows-latest, python: 3.8, arch: x64 }
54+
# - { os: windows-latest, python: 3.7, arch: x64 }
55+
# - { os: windows-latest, python: 3.6, arch: x64 }
56+
57+
# - { os: windows-latest, python: 3.8, arch: x86 }
58+
# - { os: windows-latest, python: 3.7, arch: x86 }
59+
# - { os: windows-latest, python: 3.6, arch: x86 }
60+
2361
if: github.repository == 'labscript-suite/labscript-utils' && (github.event_name != 'create' || github.event.ref_type != 'branch')
2462
steps:
2563
- name: Checkout
2664
uses: actions/checkout@v2
27-
- name: Unshallow
65+
with:
66+
fetch-depth: 0
67+
68+
- name: Ignore Tags
2869
if: github.event.ref_type != 'tag'
29-
run: |
30-
git fetch --prune --unshallow
31-
git tag -d $(git tag --points-at HEAD)
70+
run: git tag -d $(git tag --points-at HEAD)
71+
3272
- name: Install Python
3373
uses: actions/setup-python@v2
3474
with:
35-
python-version: 3.8
36-
- name: Build Distributions
75+
python-version: ${{ matrix.python }}
76+
architecture: ${{ matrix.arch }}
77+
78+
- name: Source Distribution
79+
if: strategy.job-index == 0
3780
run: |
38-
python -m pip install --upgrade pip setuptools wheel
39-
pip install -U git+https://github.com/pypa/setuptools_scm.git@8e6aa2b5fd42cb257c86e6dbe720eaee6d1e2c9b
40-
python setup.py sdist bdist_wheel
41-
SCM_VERSION=$(python setup.py --version)
42-
echo "::set-env name=SCM_VERSION::$SCM_VERSION"
81+
python -m pip install --upgrade pip setuptools wheel pep517
82+
python -m pep517.build -s .
83+
84+
- name: Wheel Distribution
85+
# Impure Linux wheels are built in the manylinux job.
86+
if: (env.PURE == 'true' && strategy.job-index == 0) || (env.PURE == 'false' && runner.os != 'Linux')
87+
run: |
88+
python -m pip install --upgrade pip setuptools wheel pep517
89+
python -m pep517.build -b .
90+
91+
- name: Upload Artifact
92+
if: strategy.job-index == 0 || (env.PURE == 'false' && runner.os != 'Linux')
93+
uses: actions/upload-artifact@v2
94+
with:
95+
name: dist
96+
path: ./dist
97+
98+
- name: Set Variables for Conda Build
99+
run: |
100+
if [ $RUNNER_OS == Windows ] && [ ${{ matrix.arch }} == x64 ]; then
101+
CONDA_INSTALLER=Miniconda3-latest-Windows-x86_64.exe
102+
elif [ $RUNNER_OS == Windows ]; then
103+
CONDA_INSTALLER=Miniconda3-latest-Windows-x86.exe
104+
elif [ $RUNNER_OS == Linux ]; then
105+
CONDA_INSTALLER=Miniconda3-latest-Linux-x86_64.sh
106+
else
107+
CONDA_INSTALLER=Miniconda3-latest-MacOSX-x86_64.sh
108+
fi
109+
if [ $NOARCH == true ]; then
110+
CONDA_BUILD_ARGS="--noarch"
111+
else
112+
CONDA_BUILD_ARGS=""
113+
fi
114+
echo "::set-env name=CONDA_INSTALLER::$CONDA_INSTALLER"
115+
echo "::set-env name=CONDA_BUILD_ARGS::$CONDA_BUILD_ARGS"
116+
117+
- name: Conda package (Unix)
118+
if: runner.os != 'Windows'
119+
run: |
120+
curl -LO https://repo.continuum.io/miniconda/$CONDA_INSTALLER
121+
bash "$CONDA_INSTALLER" -b -p .miniconda
122+
source .miniconda/etc/profile.d/conda.sh
123+
conda activate
124+
conda update -n base -c defaults conda
125+
conda create -n py${{ matrix.python }} python=${{ matrix.python }}
126+
conda activate py${{ matrix.python }}
127+
conda install -c cbillington setuptools-conda
128+
pip install --upgrade setuptools_scm
129+
setuptools-conda build $CONDA_BUILD_ARGS .
130+
131+
- name: Conda Package (Windows)
132+
if: runner.os == 'Windows'
133+
shell: cmd
134+
run: |
135+
curl -LO https://repo.continuum.io/miniconda/%CONDA_INSTALLER%
136+
%CONDA_INSTALLER% /S /D=%CD%\.miniconda && ^
137+
.miniconda\Scripts\activate && ^
138+
conda update -n base -c defaults conda && ^
139+
conda create -n py${{ matrix.python }} python=${{ matrix.python }} && ^
140+
conda activate py${{ matrix.python }} && ^
141+
conda install -c cbillington setuptools-conda && ^
142+
pip install --upgrade setuptools_scm && ^
143+
setuptools-conda build %CONDA_BUILD_ARGS% .
144+
145+
- name: Upload Artifact
146+
uses: actions/upload-artifact@v2
147+
with:
148+
name: conda_packages
149+
path: ./conda_packages
150+
151+
152+
manylinux:
153+
name: Build Manylinux
154+
runs-on: ubuntu-latest
155+
strategy:
156+
matrix:
157+
include:
158+
- { python: 'cp36-cp36m cp37-cp37m cp38-cp38' }
159+
160+
if: github.repository == 'labscript-suite/labscript-utils' && (github.event_name != 'create' || github.event.ref_type != 'branch')
161+
steps:
162+
- name: Checkout
163+
if: env.PURE == 'false'
164+
uses: actions/checkout@v2
165+
with:
166+
fetch-depth: 0
167+
168+
- name: Ignore Tags
169+
if: github.event.ref_type != 'tag' && env.PURE == 'false'
170+
run: git tag -d $(git tag --points-at HEAD)
171+
172+
- name: Build Manylinux Wheels
173+
if: env.PURE == 'false'
174+
uses: RalfG/python-wheels-manylinux-build@v0.2.2-manylinux2010_x86_64
175+
with:
176+
python-versions: ${{ matrix.python }}
177+
178+
- name: Upload Artifact
179+
if: env.PURE == 'false'
180+
uses: actions/upload-artifact@v2
181+
with:
182+
name: dist
183+
path: wheelhouse/*manylinux*.whl
184+
185+
release:
186+
name: Release
187+
runs-on: ubuntu-latest
188+
needs: [build, manylinux]
189+
steps:
190+
191+
- name: Download Artifact
192+
uses: actions/download-artifact@v2
193+
with:
194+
name: dist
195+
path: ./dist
196+
197+
- name: Download Artifact
198+
uses: actions/download-artifact@v2
199+
with:
200+
name: conda_packages
201+
path: ./conda_packages
202+
43203
- name: Publish on TestPyPI
44-
if: github.event.ref_type == 'tag' || contains(env.SCM_VERSION, 'dev')
45204
uses: pypa/gh-action-pypi-publish@master
46205
with:
47206
user: __token__
48207
password: ${{ secrets.testpypi }}
49208
repository_url: https://test.pypi.org/legacy/
209+
50210
- name: Get Version Number
51211
if: github.event.ref_type == 'tag'
52212
run: |
53213
VERSION="${GITHUB_REF/refs\/tags\/v/}"
54214
echo "::set-env name=VERSION::$VERSION"
215+
55216
- name: Create GitHub Release
56217
if: github.event.ref_type == 'tag'
57218
id: create_release
@@ -63,6 +224,7 @@ jobs:
63224
release_name: ${{ env.PACKAGE_NAME }} ${{ env.VERSION }}
64225
draft: true
65226
prerelease: ${{ contains(github.event.ref, 'rc') }}
227+
66228
- name: Upload Release Asset
67229
if: github.event.ref_type == 'tag'
68230
uses: actions/upload-release-asset@v1
@@ -73,9 +235,41 @@ jobs:
73235
asset_path: ./dist/${{ env.PACKAGE_NAME }}-${{ env.VERSION }}.tar.gz
74236
asset_name: ${{ env.PACKAGE_NAME }}-${{ env.VERSION }}.tar.gz
75237
asset_content_type: application/gzip
238+
76239
- name: Publish on PyPI
77240
if: github.event.ref_type == 'tag'
78241
uses: pypa/gh-action-pypi-publish@master
79242
with:
80243
user: __token__
81244
password: ${{ secrets.pypi }}
245+
246+
- name: Install Miniconda and cloud client
247+
run: |
248+
curl -LO https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
249+
bash Miniconda3-latest-Linux-x86_64.sh -b -p .miniconda
250+
source .miniconda/etc/profile.d/conda.sh
251+
conda activate
252+
conda install anaconda-client
253+
254+
- name: Publish to Anaconda test label
255+
if: github.event.ref_type != 'tag'
256+
run: |
257+
source .miniconda/etc/profile.d/conda.sh
258+
conda activate
259+
anaconda \
260+
--token ${{ secrets.ANACONDA_API_TOKEN }} \
261+
upload \
262+
--user $ANACONDA_USER \
263+
--label test \
264+
conda_packages/*/*
265+
266+
- name: Publish to Anaconda main label
267+
if: github.event.ref_type == 'tag'
268+
run: |
269+
source .miniconda/etc/profile.d/conda.sh
270+
conda activate
271+
anaconda \
272+
--token ${{ secrets.ANACONDA_API_TOKEN }} \
273+
upload \
274+
--user $ANACONDA_USER \
275+
conda_packages/*/*

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools", "wheel", "setuptools_scm"]
3+
build-backend = "setuptools.build_meta"

setup.cfg

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,11 @@ install_requires =
2828
importlib_metadata>=1.0
2929
h5py>=2.9
3030
numpy>=1.15
31-
pyqtgraph>=0.11.0rc0 ; python_version>='3.8'
32-
pyqtgraph ; python_version<'3.8'
31+
pyqtgraph>=0.11.0rc0
3332
qtutils>=2.2.3
3433
scipy
3534
setuptools_scm
3635
zprocess>=2.18.0
37-
setup_requires =
38-
setuptools_scm
3936

4037
[options.package_data]
4138
labscript_profile = ../labscript-suite.pth

0 commit comments

Comments
 (0)