Skip to content

Commit f1c7df1

Browse files
Add standard workflow and move setup requires into pyproject.toml
Rename to labscript-utils since conda cares about this
1 parent 2735750 commit f1c7df1

File tree

3 files changed

+226
-31
lines changed

3 files changed

+226
-31
lines changed

.github/workflows/release.yml

Lines changed: 221 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
name: Build and release
1+
name: Build and Release
2+
23
on:
34
push:
45
branches:
5-
- master
6-
- maintenance/*
6+
- conda
7+
# - master
8+
# - maintenance/*
79
create:
810
tags:
911
- 'v[0-9]+.[0-9]+.[0-9]+*'
@@ -12,46 +14,206 @@ defaults:
1214
run:
1315
shell: bash
1416

17+
env:
18+
PACKAGE_NAME: labscript-utils
19+
SCM_VERSION_SCHEME: release-branch-semver
20+
SCM_LOCAL_SCHEME: no-local-version
21+
ANACONDA_USER: labscript-suite
22+
23+
# Configuration for a package with compiled extensions:
24+
# PURE: false
25+
# NOARCH: false
26+
27+
# Configuration for a package with no extensions, but with dependencies that differ by
28+
# platform or Python version:
29+
# PURE: true
30+
# NOARCH: false
31+
32+
# Configuration for a package with no extensions and the same dependencies on all
33+
# platforms and Python versions. For this configuration you should comment out all but
34+
# the first entry in the job matrix of the build job since multiple platforms are not
35+
# needed.
36+
PURE: true
37+
NOARCH: true
38+
1539
jobs:
1640
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
41+
name: Build
42+
runs-on: ${{ matrix.os }}
43+
strategy:
44+
matrix:
45+
include:
46+
- { os: ubuntu-latest, python: 3.8, arch: x64 }
47+
# - { os: ubuntu-latest, python: 3.7, arch: x64 }
48+
# - { os: ubuntu-latest, python: 3.6, arch: x64 }
49+
50+
# - { os: macos-latest, python: 3.8, arch: x64 }
51+
# - { os: macos-latest, python: 3.7, arch: x64 }
52+
# - { os: macos-latest, python: 3.6, arch: x64 }
53+
54+
# - { os: windows-latest, python: 3.8, arch: x64 }
55+
# - { os: windows-latest, python: 3.7, arch: x64 }
56+
# - { os: windows-latest, python: 3.6, arch: x64 }
57+
58+
# - { os: windows-latest, python: 3.8, arch: x86 }
59+
# - { os: windows-latest, python: 3.7, arch: x86 }
60+
# - { os: windows-latest, python: 3.6, arch: x86 }
61+
2362
if: github.repository == 'labscript-suite/labscript-utils' && (github.event_name != 'create' || github.event.ref_type != 'branch')
2463
steps:
2564
- name: Checkout
2665
uses: actions/checkout@v2
27-
- name: Unshallow
66+
with:
67+
fetch-depth: 0
68+
69+
- name: Ignore Tags
2870
if: github.event.ref_type != 'tag'
29-
run: |
30-
git fetch --prune --unshallow
31-
git tag -d $(git tag --points-at HEAD)
71+
run: git tag -d $(git tag --points-at HEAD)
72+
3273
- name: Install Python
3374
uses: actions/setup-python@v2
3475
with:
35-
python-version: 3.8
36-
- name: Build Distributions
76+
python-version: ${{ matrix.python }}
77+
architecture: ${{ matrix.arch }}
78+
79+
- name: Source Distribution
80+
if: strategy.job-index == 0
81+
run: |
82+
python -m pip install --upgrade pip setuptools wheel pep517
83+
python -m pep517.build -s .
84+
85+
- name: Wheel Distribution
86+
# Impure Linux wheels are built in the manylinux job.
87+
if: (env.PURE == 'true' && strategy.job-index == 0) || (env.PURE == 'false' && runner.os != 'Linux')
88+
run: |
89+
python -m pip install --upgrade pip setuptools wheel pep517
90+
python -m pep517.build -b .
91+
92+
- name: Upload Artifact
93+
if: strategy.job-index == 0 || (env.PURE == 'false' && runner.os != 'Linux')
94+
uses: actions/upload-artifact@v2
95+
with:
96+
name: dist
97+
path: ./dist
98+
99+
- name: Set Variables for Conda Build
37100
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"
43-
- name: Publish on TestPyPI
44-
if: github.event.ref_type == 'tag' || contains(env.SCM_VERSION, 'dev')
45-
uses: pypa/gh-action-pypi-publish@master
101+
if [ $RUNNER_OS == Windows ] && [ ${{ matrix.arch }} == x64 ]; then
102+
CONDA_INSTALLER=Miniconda3-latest-Windows-x86_64.exe
103+
elif [ $RUNNER_OS == Windows ]; then
104+
CONDA_INSTALLER=Miniconda3-latest-Windows-x86.exe
105+
elif [ $RUNNER_OS == Linux ]; then
106+
CONDA_INSTALLER=Miniconda3-latest-Linux-x86_64.sh
107+
else
108+
CONDA_INSTALLER=Miniconda3-latest-MacOSX-x86_64.sh
109+
fi
110+
if [ $NOARCH == true ]; then
111+
CONDA_BUILD_ARGS="--noarch"
112+
else
113+
CONDA_BUILD_ARGS=""
114+
fi
115+
echo "::set-env name=CONDA_INSTALLER::$CONDA_INSTALLER"
116+
echo "::set-env name=CONDA_BUILD_ARGS::$CONDA_BUILD_ARGS"
117+
118+
- name: Conda package (Unix)
119+
if: runner.os != 'Windows'
120+
run: |
121+
curl -LO https://repo.continuum.io/miniconda/$CONDA_INSTALLER
122+
bash "$CONDA_INSTALLER" -b -p .miniconda
123+
source .miniconda/etc/profile.d/conda.sh
124+
conda activate
125+
conda update -n base -c defaults conda
126+
conda create -n py${{ matrix.python }} python=${{ matrix.python }}
127+
conda activate py${{ matrix.python }}
128+
conda install -c cbillington setuptools-conda
129+
pip install --upgrade setuptools_scm
130+
setuptools-conda build $CONDA_BUILD_ARGS .
131+
132+
- name: Conda Package (Windows)
133+
if: runner.os == 'Windows'
134+
shell: cmd
135+
run: |
136+
curl -LO https://repo.continuum.io/miniconda/%CONDA_INSTALLER%
137+
%CONDA_INSTALLER% /S /D=%CD%\.miniconda && ^
138+
.miniconda\Scripts\activate && ^
139+
conda update -n base -c defaults conda && ^
140+
conda create -n py${{ matrix.python }} python=${{ matrix.python }} && ^
141+
conda activate py${{ matrix.python }} && ^
142+
conda install -c cbillington setuptools-conda && ^
143+
pip install --upgrade setuptools_scm && ^
144+
setuptools-conda build %CONDA_BUILD_ARGS% .
145+
146+
- name: Upload Artifact
147+
uses: actions/upload-artifact@v2
46148
with:
47-
user: __token__
48-
password: ${{ secrets.testpypi }}
49-
repository_url: https://test.pypi.org/legacy/
149+
name: conda_packages
150+
path: ./conda_packages
151+
152+
153+
manylinux:
154+
name: Build Manylinux
155+
runs-on: ubuntu-latest
156+
strategy:
157+
matrix:
158+
include:
159+
- { python: 'cp36-cp36m cp37-cp37m cp38-cp38' }
160+
161+
if: github.repository == 'labscript-suite/labscript-utils' && (github.event_name != 'create' || github.event.ref_type != 'branch')
162+
steps:
163+
- name: Checkout
164+
if: env.PURE == 'false'
165+
uses: actions/checkout@v2
166+
with:
167+
fetch-depth: 0
168+
169+
- name: Ignore Tags
170+
if: github.event.ref_type != 'tag' && env.PURE == 'false'
171+
run: git tag -d $(git tag --points-at HEAD)
172+
173+
- name: Build Manylinux Wheels
174+
if: env.PURE == 'false'
175+
uses: RalfG/python-wheels-manylinux-build@v0.2.2-manylinux2010_x86_64
176+
with:
177+
python-versions: ${{ matrix.python }}
178+
179+
- name: Upload Artifact
180+
if: env.PURE == 'false'
181+
uses: actions/upload-artifact@v2
182+
with:
183+
name: dist
184+
path: wheelhouse/*manylinux*.whl
185+
186+
release:
187+
name: Release
188+
runs-on: ubuntu-latest
189+
needs: [build, manylinux]
190+
steps:
191+
192+
- name: Download Artifact
193+
uses: actions/download-artifact@v2
194+
with:
195+
name: dist
196+
path: ./dist
197+
198+
- name: Download Artifact
199+
uses: actions/download-artifact@v2
200+
with:
201+
name: conda_packages
202+
path: ./conda_packages
203+
204+
# - name: Publish on TestPyPI
205+
# uses: pypa/gh-action-pypi-publish@master
206+
# with:
207+
# user: __token__
208+
# password: ${{ secrets.testpypi }}
209+
# repository_url: https://test.pypi.org/legacy/
210+
50211
- name: Get Version Number
51212
if: github.event.ref_type == 'tag'
52213
run: |
53214
VERSION="${GITHUB_REF/refs\/tags\/v/}"
54215
echo "::set-env name=VERSION::$VERSION"
216+
55217
- name: Create GitHub Release
56218
if: github.event.ref_type == 'tag'
57219
id: create_release
@@ -63,6 +225,7 @@ jobs:
63225
release_name: ${{ env.PACKAGE_NAME }} ${{ env.VERSION }}
64226
draft: true
65227
prerelease: ${{ contains(github.event.ref, 'rc') }}
228+
66229
- name: Upload Release Asset
67230
if: github.event.ref_type == 'tag'
68231
uses: actions/upload-release-asset@v1
@@ -73,9 +236,41 @@ jobs:
73236
asset_path: ./dist/${{ env.PACKAGE_NAME }}-${{ env.VERSION }}.tar.gz
74237
asset_name: ${{ env.PACKAGE_NAME }}-${{ env.VERSION }}.tar.gz
75238
asset_content_type: application/gzip
239+
76240
- name: Publish on PyPI
77241
if: github.event.ref_type == 'tag'
78242
uses: pypa/gh-action-pypi-publish@master
79243
with:
80244
user: __token__
81245
password: ${{ secrets.pypi }}
246+
247+
- name: Install Miniconda and cloud client
248+
run: |
249+
curl -LO https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
250+
bash Miniconda3-latest-Linux-x86_64.sh -b -p .miniconda
251+
source .miniconda/etc/profile.d/conda.sh
252+
conda activate
253+
conda install anaconda-client
254+
255+
# - name: Publish to Anaconda test label
256+
# if: github.event.ref_type != 'tag'
257+
# run: |
258+
# source .miniconda/etc/profile.d/conda.sh
259+
# conda activate
260+
# anaconda \
261+
# --token ${{ secrets.ANACONDA_API_TOKEN }} \
262+
# upload \
263+
# --user $ANACONDA_USER \
264+
# --label test \
265+
# conda_packages/*/*
266+
267+
- name: Publish to Anaconda main label
268+
if: github.event.ref_type == 'tag'
269+
run: |
270+
source .miniconda/etc/profile.d/conda.sh
271+
conda activate
272+
anaconda \
273+
--token ${{ secrets.ANACONDA_API_TOKEN }} \
274+
upload \
275+
--user $ANACONDA_USER \
276+
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: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[metadata]
2-
name = labscript_utils
2+
name = labscript-utils
33
description = Shared utilities for the labscript suite
44
long_description = file: README.md
55
long_description_content_type = text/markdown
@@ -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)