Skip to content

Commit

Permalink
Build/publish binary wheels with cibuildwheel (#52)
Browse files Browse the repository at this point in the history
* Create python-publish.yml

* Modernize setuptools

* Bump version number and dependabot warnings

* Update test-ci workflow to match current versions

* Skip PyPy wheel builds
  • Loading branch information
zbowling authored Dec 28, 2024
1 parent 18c4686 commit 1a837fc
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 45 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
67 changes: 67 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build and upload to PyPI

on:
workflow_dispatch:
pull_request:
push:
branches:
- main
release:
types:
- published

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
os: [ubuntu-latest, macos-13, macos-14]

steps:
- uses: actions/checkout@v4

- name: Build wheels
uses: pypa/[email protected]

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
run: pipx run build --sdist

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- name: Download artifacts from other jobs
uses: actions/download-artifact@v4
with:
# unpacks all CIBW artifacts into dist/
pattern: cibw-*
path: dist
merge-multiple: true

- name: Publish to Pypi
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
2 changes: 1 addition & 1 deletion .github/workflows/test-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
os: ['ubuntu-latest', 'macos-latest']
runs-on: ${{ matrix.os }}
steps:
Expand Down
36 changes: 35 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
[build-system]
requires = ["setuptools", "wheel", "Cython"]
requires = ["setuptools>=75.6.0", "wheel", "cython>=0.29"]
build-backend = "setuptools.build_meta"

[project]
name = "faster-fifo"
version = "1.5.0"
description = "A faster alternative to Python's standard multiprocessing.Queue (IPC FIFO queue)"
readme = {file = "README.md", content-type = "text/markdown"}
requires-python = ">=3.9"
license = {text = "MIT"}
authors = [
{name = "Aleksei Petrenko"},
{name = "Tushar Kumar"}
]
keywords = ["multiprocessing", "data structures"]
urls = { homepage = "https://github.com/alex-petrenko/faster-fifo" }

[project.optional-dependencies]
dev = ["twine", "numpy>=1.18.1,<2.0"]

[tool.setuptools]
ext-modules = [
{ name='faster_fifo', sources=['faster_fifo.pyx', 'cpp_faster_fifo/cpp_lib/faster_fifo.cpp'], language='c++', extra-compile-args=['-std=c++11'], include-dirs=['cpp_faster_fifo/cpp_lib']}
]

[tool.setuptools.packages.find]
where = ["./"]
include = ["faster_fifo*"]

[tool.cython]
language_level = 3

[tool.cibuildwheel]
# Skip CPython 3.6, CPython 3.7, and CPython 3.8
# Also skip PyPy on all Python versions because of setuptools bug
skip = ["cp36-*", "cp37-*", "cp38-*", "pp*"]
45 changes: 2 additions & 43 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,3 @@
import setuptools
from Cython.Build import cythonize
from setuptools import setup, Extension
from setuptools import setup


extensions = [
Extension(
name='faster_fifo',
sources=['faster_fifo.pyx', 'cpp_faster_fifo/cpp_lib/faster_fifo.cpp'],
language='c++',
extra_compile_args=['-std=c++11'],
include_dirs=['cpp_faster_fifo/cpp_lib'],
),
]

with open('README.md', 'r') as fh:
long_description = fh.read()

setup(
# Information
name='faster-fifo',
version='1.4.7',
url='https://github.com/alex-petrenko/faster-fifo',
author='Aleksei Petrenko & Tushar Kumar',
license='MIT',
keywords='multiprocessing data structures',
description='A faster alternative to Python\'s standard multiprocessing.Queue (IPC FIFO queue)',
long_description=long_description,
long_description_content_type='text/markdown',

# Build instructions
ext_modules=cythonize(extensions),
install_requires=[
'setuptools>=45.2.0',
'cython>=0.29'
],
extras_require={
'dev': ['twine', 'numpy>=1.18.1,<2.0'],
},
python_requires='>=3.6',

packages=setuptools.find_packages(where='./', include='faster_fifo*'),
# install_requires=["pip>=19.3"],
)
setup()

0 comments on commit 1a837fc

Please sign in to comment.