Skip to content

Commit 9b7a303

Browse files
committed
ci: Add python wheel workflow
Signed-off-by: mevrin <[email protected]>
1 parent a2ef565 commit 9b7a303

File tree

2 files changed

+158
-0
lines changed

2 files changed

+158
-0
lines changed

.github/workflows/python-wheels.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright (c) Contributors to the OpenEXR Project.
3+
4+
name: Python Wheels
5+
6+
on:
7+
8+
# Run on all changes (PR and push) to the python binding
9+
# source/configuration files, except on the release branches, which
10+
# have their own workflow, which also publish to pypi/test.pypi.
11+
# Note that changes to the core libraries will *not*
12+
# trigger building the wheels. However, the main ci workflow does
13+
# build and test the bindings (for a single python version on a
14+
# single arch)
15+
16+
push:
17+
branches-ignore:
18+
- RB-*
19+
paths:
20+
- 'src/**'
21+
- '.github/workflows/python-wheels.yml'
22+
pull_request:
23+
branches-ignore:
24+
- RB-*
25+
paths:
26+
- 'src/**'
27+
- 'pyproject.toml'
28+
- '.github/workflows/python-wheels.yml'
29+
30+
permissions:
31+
contents: read
32+
33+
jobs:
34+
build_wheels:
35+
name: Python Wheels - ${{ matrix.os }}
36+
runs-on: ${{ matrix.os }}
37+
strategy:
38+
matrix:
39+
os: [ubuntu-latest, macos-latest, windows-latest]
40+
41+
steps:
42+
43+
- name: Checkout
44+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
45+
46+
- name: Install Python
47+
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
48+
with:
49+
python-version: '3.x'
50+
51+
- name: Create sdist
52+
# Only create it once.
53+
if: ${{ matrix.os == 'ubuntu-latest' }}
54+
run: pipx run build --sdist . --outdir wheelhouse
55+
56+
- name: Build wheel
57+
uses: pypa/cibuildwheel@79b0dd328794e1180a7268444d46cdf12e1abd01 # v2.21.0
58+
env:
59+
CIBW_ARCHS_MACOS: x86_64 arm64 universal2
60+
# Build Python 3.7 through 3.11.
61+
# Skip python 3.6 since scikit-build-core requires 3.7+
62+
# Skip 32-bit wheels builds on Windows
63+
# Also skip the PyPy builds, since they fail the unit tests
64+
CIBW_BUILD: "cp37-* cp38-* cp39-* cp310-* cp311-*"
65+
CIBW_SKIP: "*-win32 *_i686"
66+
CIBW_TEST_SKIP: "*-macosx*arm64"
67+
68+
- name: Upload artifact
69+
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
70+
with:
71+
name: wheels-${{ matrix.os }}
72+
path: |
73+
./wheelhouse/*.whl
74+
./wheelhouse/*.tar.gz

pyproject.toml

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright (c) Contributors to the OpenEXR Project.
3+
4+
[build-system]
5+
requires = ["scikit-build-core==0.8.1", "pybind11"]
6+
build-backend = "scikit_build_core.build"
7+
8+
[project]
9+
name = "Imath"
10+
dynamic = ["version"]
11+
12+
description="Python bindings for the Imath a basic, light-weight, and efficient C++ representation of 2D and 3D vectors and matrices and other simple but useful mathematical objects, functions, and data types common in computer graphics applications, including the “half” 16-bit floating-point type."
13+
readme = "README.md"
14+
authors = [
15+
{ name="Contributors to the OpenEXR project", email="[email protected]" },
16+
]
17+
requires-python = ">=3.7"
18+
19+
[project.urls]
20+
"Homepage" = "https://imath.readthedocs.io/"
21+
"Source" = "https://github.com/AcademySoftwareFoundation/Imath"
22+
"Bug Tracker" = "https://github.com/AcademySoftwareFoundation/Imath/issues"
23+
24+
[project.optional-dependencies]
25+
test = ["pytest"]
26+
27+
[tool.pytest.ini_options]
28+
minversion = "6.0"
29+
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
30+
xfail_strict = true
31+
log_cli_level = "INFO"
32+
filterwarnings = [
33+
"error",
34+
]
35+
testpaths = ["tests"]
36+
37+
[tool.scikit-build]
38+
wheel.expand-macos-universal-tags = true
39+
sdist.exclude = [".github", "src/**Test", "website", "share"]
40+
41+
# Only build the PyOpenEXR (cmake --build --target PyOpenEXR).
42+
cmake.targets = ["Imath"]
43+
# Only install the "python" component (cmake --install --component python).
44+
# This makes sure that only files marked as "python" component are installed.
45+
install.components = ["python"]
46+
# strip debug symbols
47+
install.strip = true
48+
49+
# Enable experimental features if any are available
50+
# In this case we need custom local plugin to get
51+
# the project version from cmake.
52+
experimental = true
53+
metadata.version.provider = "IMATH_skbuild_plugin"
54+
metadata.version.provider-path = "./src/python"
55+
56+
57+
[tool.scikit-build.cmake.define]
58+
IMATH_INSTALL = 'OFF'
59+
IMATH_BUILD_PYTHON = 'ON'
60+
IMATH_BUILD_EXAMPLES = 'OFF'
61+
IMATH_BUILD_TOOLS = 'OFF'
62+
IMATH_INSTALL_TOOLS = 'OFF'
63+
IMATH_INSTALL_PKG_CONFIG = 'OFF'
64+
IMATH_FORCE_INTERNAL_DEFLATE = 'ON'
65+
IMATH_FORCE_INTERNAL_IMATH = 'ON'
66+
IMATH_TEST_LIBRARIES = 'OFF'
67+
BUILD_SHARED_LIBS = 'OFF'
68+
CMAKE_OSX_DEPLOYMENT_TARGET = '10.15'
69+
CMAKE_POSITION_INDEPENDENT_CODE = 'ON'
70+
71+
[tool.cibuildwheel]
72+
test-command = "pytest -s {project}/src/python/tests"
73+
test-requires = ["numpy"]
74+
test-extras = ["test"]
75+
test-skip = ["*universal2:arm64"]
76+
build-verbosity = 1
77+
78+
manylinux-x86_64-image = "manylinux2014"
79+
manylinux-i686-image = "manylinux2014"
80+
manylinux-aarch64-image = "manylinux2014"
81+
82+
# Needed for full C++17 support
83+
[tool.cibuildwheel.macos.environment]
84+
MACOSX_DEPLOYMENT_TARGET = "10.15"

0 commit comments

Comments
 (0)