Skip to content

Commit d0a3018

Browse files
authored
Merge pull request #704 from CGATOxford/{IS}_build_wheels_cibuildwheel
Overhaul of build system.
2 parents eb79d7b + 0782e04 commit d0a3018

3 files changed

Lines changed: 86 additions & 35 deletions

File tree

Lines changed: 76 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,88 @@
1-
# This workflow will upload a Python Package using Twine when a release is created
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3-
4-
# This workflow uses actions that are not certified by GitHub.
5-
# They are provided by a third-party and are governed by
6-
# separate terms of service, privacy policy, and support
7-
# documentation.
1+
# THis workflow builds wheels and sdist on tag push, and then publishes to PyPI when a release is published. Builds wheels for python >=3.8
2+
# using cibuildwheel.
83

94
name: Upload Python Package
105

116
on:
7+
push:
8+
tags:
9+
- 'v*'
1210
release:
1311
types: [published]
1412

15-
permissions:
16-
contents: read
17-
1813
jobs:
19-
deploy:
20-
21-
runs-on: ubuntu-latest
14+
# --- JOB 1: BUILD BINARY WHEELS ---
15+
build_wheels:
16+
name: Build wheels on ${{ matrix.os }}
17+
runs-on: ${{ matrix.os }}
18+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') || github.event_name == 'release'
2219
strategy:
2320
matrix:
24-
python-version: ["3.11"]
21+
os: [ubuntu-latest, macos-13, macos-latest]
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
2525

26+
- name: Build wheels
27+
uses: pypa/cibuildwheel@v2.22.0
28+
env:
29+
CIBW_SKIP: "cp36-* cp37-* pp*"
30+
CIBW_ENVIRONMENT: "PIP_ONLY_BINARY=numpy PIP_PREFER_BINARY=1"
31+
32+
- name: Upload wheel artifacts
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
36+
path: ./wheelhouse/*.whl
37+
38+
# --- JOB 2: NEW! BUILD SOURCE DISTRIBUTION (sdist) ---
39+
build_sdist:
40+
name: Build source distribution
41+
runs-on: ubuntu-latest
42+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') || github.event_name == 'release'
2643
steps:
27-
- uses: actions/checkout@v4
28-
- name: Set up Python
29-
uses: actions/setup-python@v4
30-
with:
31-
python-version: ${{ matrix.python-version }}
32-
- name: Install dependencies
33-
run: |
34-
python -m pip install --upgrade pip
35-
pip install build
36-
- name: Build package
37-
run: python -m build --sdist --wheel --outdir dist
38-
- name: Publish package
39-
uses: pypa/gh-action-pypi-publish@release/v1
40-
with:
41-
user: __token__
42-
password: ${{ secrets.PYPI_API_TOKEN }}
44+
- name: Checkout code
45+
uses: actions/checkout@v4
46+
47+
- name: Set up Python
48+
uses: actions/setup-python@v5
49+
with:
50+
python-version: "3.11"
51+
52+
- name: Install build tool
53+
run: python -m pip install build
54+
55+
- name: Build sdist
56+
run: python -m build --sdist
57+
58+
- name: Upload sdist artifact
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: cibw-sdist
62+
path: dist/*.tar.gz
63+
64+
# --- JOB 3: PUBLISH TO PYPI (Collects Wheels + Sdist) ---
65+
publish_pypi:
66+
name: Publish to PyPI
67+
# Crucial: Wait for BOTH wheels and sdist to finish building successfully
68+
needs: [build_wheels, build_sdist]
69+
runs-on: ubuntu-latest
70+
if: github.event_name == 'release' && github.event.action == 'published'
71+
72+
environment:
73+
name: pypi
74+
permissions:
75+
id-token: write
76+
77+
steps:
78+
# This downloads ALL artifacts matching 'cibw-*' (both wheels and sdist)
79+
# and merges them cleanly into the ./dist folder
80+
- name: Download all artifacts
81+
uses: actions/download-artifact@v4
82+
with:
83+
path: ./dist
84+
pattern: cibw-*
85+
merge-multiple: true
86+
87+
- name: Publish to PyPI
88+
uses: pypa/gh-action-pypi-publish@release/v1

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ez_setup bootstrap
2-
include ez_setup.py
2+
# include ez_setup.py
33
# extensions
44
include umi_tools/*.pyx
55
include umi_tools/*.c

pyproject.toml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[build-system]
2-
requires = ["setuptools>=42", "setuptools-scm"]
3-
build-backend = "setuptools_cython"
4-
backend-path = ["setuptools-cython"]
2+
requires = ["setuptools>=42", "setuptools-scm", "numpy>=1.7"]
3+
build-backend = "setuptools.build_meta"
54

65
[project]
76
name = "umi_tools"
@@ -36,17 +35,23 @@ dependencies = [
3635

3736
[tool.setuptools]
3837
ext-modules = [
39-
{name = "umi_tools._dedup_umi", sources = ["umi_tools/_dedup_umi.pyx"]}
38+
{name = "umi_tools._dedup_umi", sources = ["umi_tools/_dedup_umi.c"]}
4039
]
4140

4241
[tool.setuptools.packages.find]
4342

4443

4544
[tool.setuptools_scm]
4645

46+
[tool.cibuildwheel]
47+
# This tells cibuildwheel to inject these flags into pip whenever it runs
48+
environment = { PIP_ONLY_BINARY = "numpy", PIP_PREFER_BINARY = "1" }
49+
50+
4751
[project.urls]
4852
Homepage = "https://github.com/CGATOxford/UMI-tools"
4953
Repository = "https://github.com/CGATOxford/UMI-tools"
5054

5155
[project.scripts]
5256
umi_tools = "umi_tools.umi_tools:main"
57+

0 commit comments

Comments
 (0)