Skip to content

Commit d3df9ac

Browse files
matatonschlichwasade
authored
Build wheels for BIOM and modernize package metadata (#996)
* build: install gcc in conda host env * ci: add wheelhouse/ to gitignore * build: move build system to pyproject.toml & `cibuildwheel` * Update pyproject.toml * Add separate file for wheels workflow * Make author list reflect current implementation * Remove setuptools version requirement * Modify path to unit test location for cibuildhweel * Add numpy to test requirements for cibuildwheel * Include Cython modules in cibuildhweel init * Correct path for tests? * Try force compiling extensions * Remove .pyx from pytest ini options * Run tests against wheels * Skip 32-bit builds * Bit of linting * Fix linting in setup.py * Flake8 doesn't support pyproject.toml, so modify make command * Remove gcc from conda_host_env.yml * Add back other authors, sans email * Remove redundant build elements and refactor release.yml * Remove redundant classifiers and enable dynamic versioning * Correct reference to existing version definition * Add all authors from original publication * Commas are important * Add specific python versions for wheel building to pyproject.toml * Make macos versioning specific * Only build wheels on relevant PRs and releases, and clean up .gitignore --------- Co-authored-by: Ty Schlichenmeyer <ty.schlich@gmail.com> Co-authored-by: Daniel McDonald <damcdonald@ucsd.edu>
1 parent b60cba7 commit d3df9ac

9 files changed

Lines changed: 211 additions & 231 deletions

File tree

‎.github/workflows/python-package-conda.yml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,3 @@ jobs:
109109
- name: Run unit tests
110110
shell: bash -l {0}
111111
run: make test
112-

‎.github/workflows/release.yml‎

Lines changed: 4 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -5,124 +5,8 @@ on:
55
tags:
66
- '*'
77

8-
env:
9-
earliest_python: "3.9"
10-
latest_python: "3.13"
11-
miniforge_version: "23.11.0-0"
12-
miniforge_variant: "Mambaforge"
13-
148
jobs:
15-
release:
16-
runs-on: ubuntu-latest
17-
steps:
18-
- uses: actions/checkout@v2
19-
- name: Set up Python 3.9
20-
uses: actions/setup-python@v2
21-
with:
22-
python-version: 3.9
23-
- name: Build distribution
24-
run: |
25-
# set version from '${{ github.ref_name }}'
26-
export RELEASE_VERSION=${{ github.ref_name }}
27-
pip install numpy cython
28-
python setup.py sdist
29-
30-
- name: Publish a Python distribution to PyPI
31-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
32-
uses: pypa/gh-action-pypi-publish@release/v1
33-
with:
34-
user: __token__
35-
password: ${{ secrets.PYPI_API_TOKEN }}
36-
37-
# wheels are not working
38-
# cutting them out did not "just" work
39-
# getting a release out right now is more important than
40-
# precompiled builds.
41-
#jobs:
42-
# build_sdist:
43-
# name: Build sdist
44-
# runs-on: ubuntu-latest
45-
# steps:
46-
# - uses: actions/checkout@v4
47-
#
48-
# - name: Build distribution
49-
# run: |
50-
# pip install numpy cython
51-
# pipx run build --sdist
52-
#
53-
# - uses: actions/upload-artifact@v4
54-
# with:
55-
# name: cibw-sdist
56-
# path: dist/*.tar.gz
57-
#
58-
# # adapted from
59-
# # https://github.com/pypa/cibuildwheel/blob/main/examples/github-deploy.yml
60-
# build_wheels:
61-
# name: Build wheels (py ${{ matrix.pyver }}) ${{ matrix.os }}
62-
# runs-on: ${{ matrix.os }}
63-
# strategy:
64-
# matrix:
65-
# os: [ubuntu-latest, macos-latest, windows-latest, ubuntu-24.04-arm, macos-13]
66-
# pyver: ["39", "310", "311", "312", "313"]
67-
#
68-
# steps:
69-
# - uses: actions/checkout@v4
70-
#
71-
# - name: Install Python packaging tools
72-
# run: |
73-
# pip install numpy cython
74-
# python -m pip install --upgrade pip setuptools wheel
75-
#
76-
# - name: Build wheels (py ${{ matrix.pyver }}) Linux
77-
# if: matrix.os == 'ubuntu-latest'
78-
# env:
79-
# CIBW_ARCHS_LINUX: "x86_64 aarch64"
80-
# CIBW_SKIP: "*-musllinux*"
81-
# CIBW_BUILD: "cp${{ matrix.pyver }}-*"
82-
#
83-
# uses: pypa/cibuildwheel@v2.17.0
84-
#
85-
# - name: Build wheels (py ${{ matrix.pyver }}) MacOS
86-
# if: matrix.os == 'macos-latest'
87-
# env:
88-
# CIBW_ARCHS_MACOS: "x86_64 arm64 universal2"
89-
# CIBW_BUILD: "cp${{ matrix.pyver }}-*"
90-
#
91-
# uses: pypa/cibuildwheel@v2.17.0
92-
#
93-
# - name: Build wheels (py ${{ matrix.pyver }}) Windows
94-
# if: matrix.os == 'windows-latest'
95-
# env:
96-
# CIBW_ARCHS_WINDOWS: "amd64 win32"
97-
# CIBW_BUILD: "cp${{ matrix.pyver }}-*"
98-
#
99-
# uses: pypa/cibuildwheel@v2.17.0
100-
#
101-
# - uses: actions/upload-artifact@v4
102-
# with:
103-
# name: cibw-wheels-${{ matrix.os }}-${{ matrix.pyver }}-${{ strategy.job-index }}
104-
# path: ./wheelhouse/*.whl
105-
#
106-
# release:
107-
# needs: [build_wheels, build_sdist]
108-
# runs-on: ubuntu-latest
109-
# environment: pypi
110-
# permissions:
111-
# id-token: write
112-
#
113-
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
114-
# steps:
115-
# - uses: actions/download-artifact@v4
116-
# with:
117-
# name: cibw-*
118-
# path: dist
119-
# merge-multiple: true
120-
#
121-
# - name: Check artifacts
122-
# run: ls -lrt dist/
123-
#
124-
# - name: Publish Distribution
125-
# uses: pypa/gh-action-pypi-publish@v1.5.0
126-
# with:
127-
# user: __token__
128-
# password: ${{ secrets.PYPI_API_TOKEN }}
9+
build_and_publish:
10+
name: Build and publish to PyPI
11+
uses: ./.github/workflows/wheels.yml
12+
secrets: inherit

‎.github/workflows/wheels.yml‎

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Build Wheels
2+
3+
on:
4+
pull_request:
5+
branches: [ master ]
6+
paths:
7+
- 'setup.py'
8+
- 'pyproject.toml'
9+
- 'biom/*.pyx'
10+
- '.github/workflows/wheels.yml'
11+
- '.github/workflows/release.yml'
12+
workflow_call:
13+
workflow_dispatch:
14+
15+
jobs:
16+
build_wheels:
17+
name: Build wheels on ${{ matrix.os }}
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
matrix:
21+
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-13, macos-14]
22+
# The 5 runners correspond to 5 architectures. Details:
23+
# https://cibuildwheel.pypa.io/en/stable/options/#archs
24+
# The runners and architectures should be automatically associated. However, in
25+
# case not in the future, they can be manually specified as follows:
26+
# include:
27+
# - os: ubuntu-latest
28+
# cibw_archs: 'x86_64'
29+
# - os: ubuntu-24.04-arm
30+
# cibw_archs: 'aarch64'
31+
# - os: windows-latest
32+
# cibw_archs: 'AMD64'
33+
# - os: macos-13
34+
# cibw_archs: 'x86_64'
35+
# - os: macos-latest
36+
# cibw_archs: 'arm64'
37+
38+
steps:
39+
- uses: actions/checkout@v4
40+
with:
41+
submodules: true
42+
43+
- name: Build wheels
44+
uses: pypa/cibuildwheel@v2.23.3
45+
46+
- uses: actions/upload-artifact@v4
47+
with:
48+
name: wheels-${{ matrix.os }}-${{ strategy.job-index }}
49+
path: ./wheelhouse/*.whl
50+
51+
build_sdist:
52+
name: Build source distribution
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v4
56+
with:
57+
submodules: true
58+
59+
- name: Set up Python
60+
uses: actions/setup-python@v5
61+
with:
62+
python-version: '3.9'
63+
64+
- name: Install build dependencies
65+
run: |
66+
pip install numpy cython build
67+
68+
- name: Build sdist
69+
run: python -m build --sdist
70+
71+
- uses: actions/upload-artifact@v4
72+
with:
73+
name: sdist
74+
path: dist/*.tar.gz
75+
76+
upload_pypi:
77+
needs: [build_wheels, build_sdist]
78+
runs-on: ubuntu-latest
79+
# Only upload to PyPI on tagged commits
80+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
81+
steps:
82+
- uses: actions/download-artifact@v4
83+
with:
84+
pattern: wheels-*
85+
path: dist
86+
merge-multiple: true
87+
88+
- uses: actions/download-artifact@v4
89+
with:
90+
name: sdist
91+
path: dist
92+
93+
- name: Publish to PyPI
94+
uses: pypa/gh-action-pypi-publish@release/v1
95+
with:
96+
user: __token__
97+
password: ${{ secrets.PYPI_API_TOKEN }}

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ R-code/biom.Rcheck*
4242

4343
# Sphinx builds
4444
doc/documentation/generated
45+
46+
# Wheel builds
47+
wheelhouse/

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test:
1919
sh usage_tests.sh
2020

2121
lint:
22-
flake8 biom setup.py
22+
flake8 biom setup.py --exclude=biom/tests/long_lines.py
2323

2424
doc:
2525
$(MAKE) -C doc clean html

‎pyproject.toml‎

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,91 @@
11
[build-system]
22
requires = ["setuptools","wheel", "numpy", "cython"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "biom_format"
7+
dynamic = ["version"]
8+
description = "Biological Observation Matrix (BIOM) format"
9+
requires-python = ">= 3.9"
10+
readme = "README.md"
11+
authors = [
12+
{name = "Daniel McDonald", email = "damcdonald@ucsd.edu"},
13+
{name = "Greg Caporaso"},
14+
{name = "Jai Ram Rideout"},
15+
{name = "Jose Clemente"},
16+
{name = "Jorge Cañardo Alastuey"},
17+
{name = "Michael Hall"},
18+
{name = "Justin Kuczynski"},
19+
{name = "Jesse Stombaugh"},
20+
{name = "Doug Wendel"},
21+
{name = "Andreas Wilke"},
22+
{name = "Susan Huse"},
23+
{name = "John Hufnagle"},
24+
{name = "Folker Meyer"},
25+
{name = "Rob Knight"}
26+
]
27+
license = { text = "BSD" }
28+
classifiers = [
29+
"Development Status :: 4 - Beta",
30+
"License :: OSI Approved :: BSD License",
31+
"Topic :: Scientific/Engineering :: Bio-Informatics",
32+
"Topic :: Software Development :: Libraries :: Application Frameworks",
33+
"Topic :: Software Development :: Libraries :: Python Modules",
34+
"Programming Language :: Python",
35+
"Programming Language :: Python :: 3",
36+
"Programming Language :: Python :: 3 :: Only",
37+
"Programming Language :: Python :: 3.9",
38+
"Programming Language :: Python :: 3.10",
39+
"Programming Language :: Python :: 3.11",
40+
"Programming Language :: Python :: 3.12",
41+
"Programming Language :: Python :: 3.13",
42+
"Programming Language :: Python :: Implementation :: CPython",
43+
"Operating System :: OS Independent",
44+
"Operating System :: POSIX :: Linux",
45+
"Operating System :: MacOS :: MacOS X",
46+
"Operating System :: Microsoft :: Windows",
47+
]
48+
dependencies = [
49+
"click",
50+
"numpy >= 1.9.2",
51+
"scipy >= 1.3.1",
52+
"pandas >= 0.20.0",
53+
"h5py",
54+
]
55+
56+
[project.optional-dependencies]
57+
# Corresponds to the old `extras_require`
58+
test = [
59+
"pytest>=6.2.4",
60+
"pytest-cov",
61+
"flake8",
62+
]
63+
hdf5 = ["h5py >= 2.2.0"]
64+
anndata = ["anndata"]
65+
66+
[project.urls]
67+
Homepage = "http://www.biom-format.org"
68+
69+
[project.scripts]
70+
biom = "biom.cli:cli"
71+
72+
[tool.setuptools.packages.find]
73+
where = ["."]
74+
75+
[tool.setuptools.dynamic]
76+
version = {attr = "biom.util.__version__"}
77+
78+
[tool.cibuildwheel]
79+
test-command = "pytest --pyargs biom.tests"
80+
test-requires = ["pytest", "numpy"]
81+
82+
# Skip 32-bit builds, PyPy, and musllinux
83+
skip = ["*-win32", "*-manylinux_i686", "pp*", "*-musllinux*"]
84+
85+
# Python versions to build
86+
build = "cp39-* cp310-* cp311-* cp312-* cp313-*"
87+
88+
[tool.pytest.ini_options]
89+
addopts = ["--ignore=biom/assets/exercise_api.py "]
90+
doctest_optionflags = [ "NORMALIZE_WHITESPACE", "IGNORE_EXCEPTION_DETAIL" ]
91+
testpaths = ["biom"]

‎pytest.ini‎

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎setup.cfg‎

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)