Skip to content

Commit

Permalink
build: Add support for pip install OpenImageIO
Browse files Browse the repository at this point in the history
- Add build scripts for wheel dependencies.
- Fix OpenColorIO.
- Working wheel build.
- Remove unused scripts.
- Cleanup CentOS build.
- Require Python Development.Module instead of Development since the libpython is not required to build the extension.
- Remove unnecessary changes.
- Working windows build!
- Build from pyproject.toml with scikit.build

Signed-off-by: Alex Clark <[email protected]>
  • Loading branch information
JeanChristopheMorinPerso authored and aclark4life committed Dec 6, 2023
1 parent 8f21ed1 commit c704487
Show file tree
Hide file tree
Showing 24 changed files with 358 additions and 75 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ _coverage/
/*.jpg
/*.tx
/*.log
*.egg-info/
*.whl
26 changes: 14 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,6 @@ if (CMAKE_VERSION VERSION_LESS 3.21)
endif ()
endif ()

# If the user wants to use Conan to build dependencies, they will have done
# this prior to the cmake config:
# cd <build area>
# conan install <source area>
# and that will leave a conanbuildinfo.cmake in the build area for us.
if (EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
include (${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
message (STATUS "Using Conan for dependencies")
conan_basic_setup()
endif()

if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Release")
endif ()
Expand Down Expand Up @@ -154,6 +143,7 @@ endif ()
add_definitions (-DOIIO_INTERNAL=1)

list (APPEND CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/build"
"${PROJECT_SOURCE_DIR}/src/cmake/modules"
"${PROJECT_SOURCE_DIR}/src/cmake")

Expand All @@ -169,6 +159,18 @@ include (add_oiio_plugin)
# All the C++ and compiler related options and adjustments
include (compiler)

# If the user wants to use Conan to build dependencies, they will have done
# this prior to the cmake config:
# cd <build area>
# conan install <source area>
# and that will leave a conanbuildinfo.cmake in the build area for us.
if (EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
include (${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
message (STATUS "Using Conan for dependencies")
conan_basic_setup()
endif()


# Utilities and options related to finding python and making python bindings
include (pythonutils)

Expand Down Expand Up @@ -247,7 +249,7 @@ if (NOT EMBEDPLUGINS AND NOT BUILD_OIIOUTIL_ONLY)
endforeach ()
endif ()

if (USE_PYTHON AND Python_Development_FOUND AND NOT BUILD_OIIOUTIL_ONLY)
if (USE_PYTHON AND Python_FOUND AND NOT BUILD_OIIOUTIL_ONLY)
add_subdirectory (src/python)
endif ()

Expand Down
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ Additionally, a few helpful modifiers alter some build-time options:
| make STOP_ON_WARNING=0 | Do not stop building if compiler warns |
| make EMBEDPLUGINS=0 ... | Don't compile the plugins into libOpenImageIO |
| make USE_OPENGL=0 ... | Skip anything that needs OpenGL |
| make USE_QT=0 ... | Skip anything that needs Qt |
| make USE_QT5=0 ... | Skip anything that needs Qt |
| make MYCC=xx MYCXX=yy ... | Use custom compilers |
| make USE_PYTHON=0 ... | Don't build the Python binding |
| make BUILD_SHARED_LIBS=0 | Build static library instead of shared |
Expand Down
74 changes: 60 additions & 14 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
[requires]
zlib/1.2.11
libtiff/4.0.9
boost/1.79.0
zlib/1.2.12
libtiff/4.3.0
libpng/1.6.37
openexr/2.4.0
boost/1.70.0
libjpeg/9c
libjpeg-turbo/2.0.2
giflib/5.1.4
freetype/2.10.0
#opencv/4.1.1@conan/stable
openjpeg/2.3.1
libwebp/1.0.3
tsl-robin-map/0.6.1@tessil/stable
giflib/5.2.1
freetype/2.12.1
#opencv/4.5.5
libjpeg/9d
openjpeg/2.5.0
libwebp/1.2.3
#tsl-robin-map/0.6.1@tessil/stable
tbb/2020.0
ffmpeg/5.0
libheif/1.12.0
lcms/2.13.1
libraw/0.20.2
ptex/2.4.0
yaml-cpp/0.6.3
pystring/1.1.3
expat/2.4.8
# To do:
# opencolorio? not on conan?
# pybind11/2.4.3 - conan doesn't have this minimum version
Expand All @@ -26,7 +32,47 @@ tbb/2020.0


[generators]
cmake
cmake_find_package

[options]
#libpng:shared=False
*:shared=False
*:fPIC=True
ffmpeg:with_vulkan=False # Should not be set on non linux system.
ffmpeg:with_asm=False
ffmpeg:with_pulse=False # Should not be set on non linux system.
ffmpeg:with_vaapi=False # This links against the system library
ffmpeg:with_vdpau=False # This links against the system library
ffmpeg:with_xcb=False # This links against the system library
libx265:assembly=False
boost:without_atomic=False
boost:without_chrono=False
boost:without_container=False
boost:without_date_time=False
boost:without_exception=False
boost:without_system=False
boost:without_filesystem=False
boost:without_thread=False
boost:with_stacktrace_backtrace=True
boost:without_context=True
boost:without_contract=True
boost:without_coroutine=True
boost:without_fiber=True
boost:without_graph=True
boost:without_graph_parallel=True
boost:without_iostreams=True
boost:without_json=True
boost:without_locale=True
boost:without_log=True
boost:without_math=True
boost:without_mpi=True
boost:without_nowide=True
boost:without_program_options=True
boost:without_python=True
boost:without_random=True
boost:without_regex=True
boost:without_serialization=True
boost:without_stacktrace=True
boost:without_test=True
boost:without_timer=True
boost:without_type_erasure=True
boost:without_wave=True
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,10 @@ oiiotool = "OpenImageIO._commands:oiiotool"
testtex = "OpenImageIO._commands:testtex"

[build-system]
requires = ["scikit-build-core"]
requires = [
"scikit-build-core",
"cmake>=3.12",
"ninja",
"numpy"
]
build-backend = "scikit_build_core.build"
20 changes: 17 additions & 3 deletions src/build-scripts/build_opencolorio.bash
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,26 @@ OPENCOLORIO_BUILD_DIR=${OPENCOLORIO_BUILD_DIR:=${LOCAL_DEPS_DIR}/OpenColorIO-bui
OPENCOLORIO_INSTALL_DIR=${OPENCOLORIO_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
OPENCOLORIO_BUILD_TYPE=${OPENCOLORIO_BUILD_TYPE:=Release}
OPENCOLORIO_CXX_FLAGS=${OPENCOLORIO_CXX_FLAGS:="-Wno-unused-function -Wno-deprecated-declarations -Wno-cast-qual -Wno-write-strings"}
OPENCOLORIO_YAML_CXX_FLAGS=${OPENCOLORIO_YAML_CXX_FLAGS:=''}
if [[ "$OSTYPE" != "msys" ]]; then
OPENCOLORIO_CXX_FLAGS=${OPENCOLORIO_CXX_FLAGS:="-Wno-unused-function -Wno-deprecated-declarations -Wno-cast-qual -Wno-write-strings"}
OPENCOLORIO_YAML_CXX_FLAGS=${OPENCOLORIO_YAML_CXX_FLAGS:=''}
else
if [[ "${OPENCOLORIO_BUILD_SHARED_LIBS}" != "ON" ]]; then
OPENCOLORIO_CXX_FLAGS=${OPENCOLORIO_CXX_FLAGS:="//MT"}
OPENCOLORIO_YAML_CXX_FLAGS=${OPENCOLORIO_YAML_CXX_FLAGS:='//MT'}
fi
fi
# Just need libs:
OPENCOLORIO_BUILDOPTS="-DOCIO_BUILD_APPS=OFF -DOCIO_BUILD_NUKE=OFF \
-DOCIO_BUILD_DOCS=OFF -DOCIO_BUILD_TESTS=OFF \
-DOCIO_BUILD_GPU_TESTS=OFF \
-DOCIO_BUILD_PYTHON=OFF -DOCIO_BUILD_PYGLUE=OFF \
-DOCIO_BUILD_JAVA=OFF \
-DBUILD_SHARED_LIBS=${OPENCOLORIO_BUILD_SHARED_LIBS:=ON}"

OPENCOLORIO_BUILDOPTS="${OPENCOLORIO_BUILDOPTS} -DCMAKE_POSITION_INDEPENDENT_CODE=ON"

BASEDIR=`pwd`
pwd
echo "OpenColorIO install dir will be: ${OPENCOLORIO_INSTALL_DIR}"
Expand All @@ -46,9 +59,10 @@ git checkout ${OPENCOLORIO_VERSION} --force
time cmake -S . -B ${OPENCOLORIO_BUILD_DIR} \
-DCMAKE_BUILD_TYPE=${OPENCOLORIO_BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX=${OPENCOLORIO_INSTALL_DIR} \
-DCMAKE_CXX_FLAGS="${OPENCOLORIO_CXX_FLAGS}" \
${OPENCOLORIO_BUILDOPTS}
time cmake --build ${OPENCOLORIO_BUILD_DIR} --config Release --target install
-DCMAKE_CXX_FLAGS_RELEASE="${OPENCOLORIO_CXX_FLAGS}" \
-Dyaml-cpp_CXX_FLAGS="${OPENCOLORIO_YAML_CXX_FLAGS}" \
${OPENCOLORIO_BUILDOPTS} ${OPENCOLORIO_SOURCE_DIR}
time cmake --build . --config Release --target install
popd

# ls -R ${OPENCOLORIO_INSTALL_DIR}
Expand Down
22 changes: 18 additions & 4 deletions src/build-scripts/build_openexr.bash
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@ OPENEXR_INSTALL_DIR=${OPENEXR_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
OPENEXR_BUILD_TYPE=${OPENEXR_BUILD_TYPE:=Release}
OPENEXR_CMAKE_FLAGS=${OPENEXR_CMAKE_FLAGS:=""}
OPENEXR_CXX_FLAGS=${OPENEXR_CXX_FLAGS:=""}
OPENEXR_BUILD_SHARED_LIBS=${OPENEXR_BUILD_SHARED_LIBS:="ON"}
BASEDIR=$PWD

if [[ "$OSTYPE" == "msys" ]]; then
OPENEXR_CXX_FLAGS="${OPENEXR_CXX_FLAGS} /W1 /EHsc /DWIN32=1"
if [[ "${OPENEXR_BUILD_SHARED_LIBS}" != "ON" ]]; then
OPENEXR_CXX_FLAGS="${OPENEXR_CXX_FLAGS} /MT"
fi
fi

pwd
echo "Building OpenEXR ${OPENEXR_VERSION}"
echo "OpenEXR build dir will be: ${OPENEXR_BUILD_DIR}"
Expand All @@ -39,8 +47,10 @@ mkdir -p ${OPENEXR_INSTALL_DIR} && true
pushd ${OPENEXR_SOURCE_DIR}
git checkout ${OPENEXR_VERSION} --force

cmake -S . -B ${OPENEXR_BUILD_DIR} \
-DCMAKE_BUILD_TYPE=${OPENEXR_BUILD_TYPE} \
# Simplified setup for 2.4+
cd ${OPENEXR_BUILD_DIR}
cmake -DCMAKE_BUILD_TYPE=${OPENEXR_BUILD_TYPE} \
-DBUILD_SHARED_LIBS=${OPENEXR_BUILD_SHARED_LIBS} \
-DCMAKE_INSTALL_PREFIX="${OPENEXR_INSTALL_DIR}" \
-DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}" \
-DILMBASE_PACKAGE_PREFIX="${OPENEXR_INSTALL_DIR}" \
Expand All @@ -52,8 +62,12 @@ cmake -S . -B ${OPENEXR_BUILD_DIR} \
-DOPENEXR_INSTALL_EXAMPLES=0 \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_CXX_FLAGS="${OPENEXR_CXX_FLAGS}" \
${OPENEXR_CMAKE_FLAGS}
time cmake --build ${OPENEXR_BUILD_DIR} --target install --config ${OPENEXR_BUILD_TYPE}
-DCMAKE_CXX_FLAGS_RELEASE="${OPENEXR_CXX_FLAGS}" \
-DCMAKE_C_FLAGS="${OPENEXR_CXX_FLAGS}" \
-DCMAKE_C_FLAGS_RELEASE="${OPENEXR_CXX_FLAGS}" \
-DCMAKE_MODULE_PATH=${CONAN_CMAKE_FILES} \
${OPENEXR_CMAKE_FLAGS} ${OPENEXR_SOURCE_DIR}
time cmake --build . --target install --config ${OPENEXR_BUILD_TYPE}

popd

Expand Down
9 changes: 8 additions & 1 deletion src/build-scripts/build_pugixml.bash
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ PUGIXML_BUILD_DIR=${PUGIXML_BUILD_DIR:=${PUGIXML_SRC_DIR}/build}
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
PUGIXML_INSTALL_DIR=${PUGIXML_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
#PUGIXML_BUILD_OPTS=${PUGIXML_BUILD_OPTS:=}
PUGIXML_BUILD_SHARED_LIBS=${PUGIXML_BUILD_SHARED_LIBS:="ON"}

PUGIXML_CXX_FLAGS=${PUGIXML_CXX_FLAGS:=}
if [[ "$OSTYPE" == 'msys' ]] && [[ "${PUGIXML_BUILD_SHARED_LIBS}" != "ON" ]]; then
PUGIXML_CXX_FLAGS="${PUGIXML_CXX_FLAGS}"
fi

pwd
echo "pugixml install dir will be: ${PUGIXML_INSTALL_DIR}"
Expand All @@ -41,8 +47,9 @@ git checkout ${PUGIXML_VERSION} --force
if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
time cmake -S . -B ${PUGIXML_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PUGIXML_INSTALL_DIR} \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_SHARED_LIBS=${PUGIXML_BUILD_SHARED_LIBS} \
-DBUILD_TESTS=OFF \
-DCMAKE_CXX_FLAGS_RELEASE=${PUGIXML_CXX_FLAGS} \
${PUGIXML_BUILD_OPTS} ..
time cmake --build ${PUGIXML_BUILD_DIR} --config Release --target install
fi
Expand Down
5 changes: 3 additions & 2 deletions src/build-scripts/build_pybind11.bash
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
time cmake -S . -B ${PYBIND11_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PYBIND11_INSTALL_DIR} \
-DPYBIND11_TEST=OFF \
${PYBIND11_BUILD_OPTS}
time cmake --build ${PYBIND11_BUILD_DIR} --config Release --target install
-DCMAKE_MODULE_PATH=${CONAN_CMAKE_FILES} \
${PYBIND11_BUILD_OPTS} ..
time cmake --build . --config Release --target install
fi

# ls -R ${PYBIND11_INSTALL_DIR}
Expand Down
3 changes: 2 additions & 1 deletion src/build-scripts/ci-build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ if [[ ${GITHUB_ACTIONS} == true ]] ; then
OIIO_CMAKE_FLAGS+=" -DCMAKE_UNITY_BUILD=${CMAKE_UNITY_BUILD:=ON} -DCMAKE_UNITY_BUILD_MODE=${CMAKE_UNITY_BUILD_MODE:=BATCH}"
fi

cmake -S . -B build -G "$CMAKE_GENERATOR" \
pushd build
cmake .. -G "$CMAKE_GENERATOR" \
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \
-DCMAKE_INSTALL_PREFIX="$OpenImageIO_ROOT" \
Expand Down
8 changes: 5 additions & 3 deletions src/build-scripts/ci-startup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ export UBSAN_OPTIONS=suppressions=$PWD/src/build-scripts/ubsan-suppressions.txt
export PYTHON_VERSION=${PYTHON_VERSION:="2.7"}
export PYTHONPATH=$OpenImageIO_ROOT/lib/python${PYTHON_VERSION}/site-packages:$PYTHONPATH
export BUILD_MISSING_DEPS=${BUILD_MISSING_DEPS:=1}
export COMPILER=${COMPILER:=gcc}
export CC=${CC:=gcc}
export CXX=${CXX:=g++}
if [[ "$OSTYPE" != "msys" ]]; then
export COMPILER=${COMPILER:=gcc}
export CC=${CC:=gcc}
export CXX=${CXX:=g++}
fi
export OpenImageIO_CI=true
export USE_NINJA=${USE_NINJA:=1}
export CMAKE_GENERATOR=${CMAKE_GENERATOR:=Ninja}
Expand Down
Loading

0 comments on commit c704487

Please sign in to comment.