-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Streamline Python wheel workflow, and add tests and a CMake setup for…
… bindings (#1517) - Remove the libdeflate patch, not actually necessary - Add a CMake build setup, controlled ``OPENEXR_BUILD_PYTHON``, off by default - Update the doc strings - Add ``#define PY_SSIZE_T_CLEAN``, apparently required in Python 3.10 for ``Py_BuildValue("s#")``. PreviewImage attributes crash otherwise. - Add a more extensive unit test - Disable building PyPy wheels, since the bindings don't work properly (the ``channels()`` method fails in ``test_unittests.py`` when built against PyPy) Signed-off-by: Cary Phillips <[email protected]>
- Loading branch information
Showing
6 changed files
with
341 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,34 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright (c) Contributors to the OpenEXR Project. | ||
# | ||
|
||
name: Python wheels | ||
|
||
on: | ||
push: | ||
branches: [ $default-branch, main, python ] | ||
branches-ignore: | ||
- RB-2.* | ||
tags-ignore: | ||
- v1.* | ||
- v2.* | ||
paths: | ||
- '**' | ||
- '!**.md' | ||
- '!website/**' | ||
- 'website/src/**' | ||
- '!bazel/**' | ||
pull_request: | ||
branches-ignore: | ||
- RB-2.* | ||
tags-ignore: | ||
- v1.* | ||
- v2.* | ||
paths: | ||
- '**' | ||
- '!**.md' | ||
- '!website/**' | ||
- 'website/src/**' | ||
- '!bazel/**' | ||
|
||
jobs: | ||
build_wheels: | ||
|
@@ -12,30 +38,13 @@ jobs: | |
matrix: | ||
os: [ubuntu-22.04, windows-latest, macOS-latest] | ||
env: | ||
# Skip 32-bit wheels builds | ||
CIBW_SKIP: "*-win32 *_i686" | ||
# Skip 32-bit wheels builds. | ||
# Also skip the PyPy builds, since they fail the unittests | ||
CIBW_SKIP: "*-win32 *_i686 pp*" | ||
CIBW_BEFORE_BUILD: > | ||
echo "Installing Zlib..." && | ||
cd zlib.build && | ||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../openexr.install -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_PREFIX_PATH=../openexr.install -DCMAKE_INSTALL_LIBDIR=lib ../zlib && | ||
cmake --build ./ --config Release --clean-first && | ||
cmake --install ./ --config Release && | ||
cd .. && | ||
echo "Installing libDeflate..." && | ||
cd libdeflate.build && | ||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../openexr.install -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_PREFIX_PATH=../openexr.install -DCMAKE_INSTALL_LIBDIR=lib -DLIBDEFLATE_BUILD_SHARED_LIB=OFF -DLIBDEFLATE_USE_SHARED_LIB=OFF -DBUILD_SHARED_LIBS=OFF ../libdeflate && | ||
cmake --build ./ --config Release --clean-first && | ||
cmake --install ./ --config Release && | ||
cd .. && | ||
echo "Installing Imath-3.1.9..." && | ||
cd imath.build && | ||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../openexr.install -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_PREFIX_PATH=../openexr.install -DCMAKE_INSTALL_LIBDIR=lib -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF ../imath && | ||
cmake --build ./ --config Release --clean-first && | ||
cmake --install ./ --config Release && | ||
cd .. && | ||
echo "Installing OpenEXR..." && | ||
cd openexr.build && | ||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../openexr.install -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_PREFIX_PATH=../openexr.install -DCMAKE_INSTALL_LIBDIR=lib -DBUILD_TESTING=OFF -DOPENEXR_INSTALL_EXAMPLES=OFF -DBUILD_SHARED_LIBS=OFF -DOPENEXR_FORCE_INTERNAL_DEFLATE=ON ../ && | ||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../openexr.install -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_PREFIX_PATH=../openexr.install -DCMAKE_INSTALL_LIBDIR=lib -DBUILD_TESTING=OFF -DOPENEXR_INSTALL_EXAMPLES=OFF -DOPENEXR_BUILD_TOOLS=OFF -DBUILD_SHARED_LIBS=OFF -DOPENEXR_FORCE_INTERNAL_DEFLATE=ON -DOPENEXR_FORCE_INTERNAL_IMATH=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON ../ && | ||
cmake --build ./ --config Release --clean-first && | ||
cmake --install ./ --config Release && | ||
cd .. | ||
|
@@ -61,52 +70,9 @@ jobs: | |
- name: Create folders | ||
run: | | ||
mkdir -p ${{github.workspace}}/zlib.build | ||
mkdir -p ${{github.workspace}}/libdeflate.build | ||
mkdir -p ${{github.workspace}}/imath.build | ||
mkdir -p ${{github.workspace}}/openexr.build | ||
mkdir -p ${{github.workspace}}/openexr.install | ||
- name: download Zlib source code | ||
uses: suisei-cn/[email protected] | ||
with: | ||
url: https://github.com/madler/zlib/releases/download/v1.2.13/zlib-1.2.13.tar.gz | ||
target: ${{github.workspace}}/ | ||
|
||
- name: Extract Zlib | ||
run: | | ||
tar -xvzf zlib-1.2.13.tar.gz -C ${{github.workspace}}/ | ||
mv zlib-1.2.13 zlib | ||
rm zlib-1.2.13.tar.gz | ||
- name: download libDeflate source code | ||
uses: suisei-cn/[email protected] | ||
with: | ||
url: https://github.com/ebiggers/libdeflate/archive/refs/tags/v1.18.tar.gz | ||
target: ${{github.workspace}}/ | ||
|
||
- name: Extract libDeflate | ||
run: | | ||
tar -xvzf v1.18.tar.gz -C ${{github.workspace}}/ | ||
mv libdeflate-1.18 libdeflate | ||
rm v1.18.tar.gz | ||
- name: Patch libDeflate | ||
run: | | ||
patch -u libdeflate/CMakeLists.txt -i ${{github.workspace}}/src/wrappers/python/libdeflate.patch | ||
- name: download Imath source code | ||
uses: suisei-cn/[email protected] | ||
with: | ||
url: https://github.com/AcademySoftwareFoundation/Imath/archive/refs/tags/v3.1.9.tar.gz | ||
target: ${{github.workspace}}/ | ||
|
||
- name: Extract Imath | ||
run: | | ||
tar -xvzf v3.1.9.tar.gz -C ${{github.workspace}}/ | ||
mv Imath-3.1.9 imath | ||
rm v3.1.9.tar.gz | ||
- name: Build wheels | ||
run: python -m cibuildwheel --output-dir wheelhouse | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright Contributors to the OpenEXR Project. | ||
|
||
if(NOT "${CMAKE_PROJECT_NAME}" STREQUAL "OpenEXR") | ||
cmake_minimum_required(VERSION 3.12) | ||
project(PyOpenEXR) | ||
find_package(OpenEXR) | ||
endif() | ||
|
||
get_cmake_property(_variableNames VARIABLES) | ||
list (SORT _variableNames) | ||
foreach (_variableName ${_variableNames}) | ||
message(STATUS "${_variableName}=${${_variableName}}") | ||
endforeach() | ||
|
||
add_library (PyOpenEXR SHARED OpenEXR.cpp) | ||
|
||
set (Python_ADDITIONAL_VERSIONS 3) | ||
find_package (PythonLibs REQUIRED) | ||
find_package (PythonInterp REQUIRED) | ||
|
||
include_directories ("${PYTHON_INCLUDE_DIRS}") | ||
|
||
set_target_properties (PyOpenEXR PROPERTIES PREFIX "") | ||
set_target_properties (PyOpenEXR PROPERTIES OUTPUT_NAME "OpenEXR") | ||
set_target_properties (PyOpenEXR PROPERTIES SUFFIX ".so") | ||
|
||
target_link_libraries (PyOpenEXR "${PYTHON_LIBRARIES}" OpenEXR::OpenEXR) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.