@@ -244,6 +244,14 @@ ELSE() # Not WINDOWS
244244 )
245245ENDIF ()
246246
247+ # Set the appropriate library for CMAKE_ARGS based on platform
248+ # Windows needs the import library (.lib), Unix needs the shared library (.so/.dylib)
249+ IF (RV_TARGET_WINDOWS)
250+ SET (_python3_cmake_library ${_python3_implib} )
251+ ELSE ()
252+ SET (_python3_cmake_library ${_python3_lib} )
253+ ENDIF ()
254+
247255# Generate requirements.txt from template with the OpenTimelineIO version substituted
248256SET (_requirements_input_file
249257 "${PROJECT_SOURCE_DIR} /src/build/requirements.txt.in"
@@ -258,47 +266,31 @@ CONFIGURE_FILE(
258266 @ONLY
259267)
260268
261- IF (RV_TARGET_WINDOWS)
262- # On Windows, OpenTimelineIO needs to be built from source and requires
263- # CMake to find the Python libraries. Set CMAKE_ARGS to help pybind11
264- # locate the Python development files.
265- # This is required for both old and new versions of pybind11, but especially
266- # for pybind11 v2.13.6+ which has stricter Python library detection.
267- # Note: pybind11's FindPythonLibsNew.cmake uses PYTHON_LIBRARY (all caps),
268- # PYTHON_INCLUDE_DIR, and PYTHON_EXECUTABLE variables.
269- # --no-cache-dir: Don't use pip's wheel cache (prevents using wheels built for wrong Python version)
270- # --force-reinstall: Reinstall packages even if already installed (ensures fresh build)
271-
272- IF (CMAKE_BUILD_TYPE MATCHES "^Debug$" )
273- # For Debug builds, we need to tell OpenTimelineIO to build in debug mode
274- # and link against the debug Python library (python311_d.lib)
275- SET (_requirements_install_command
276- ${CMAKE_COMMAND} -E env
277- "OTIO_CXX_DEBUG_BUILD=1"
278- "CMAKE_ARGS=-DPYTHON_LIBRARY=${_python3_implib} -DPYTHON_INCLUDE_DIR=${_include_dir} -DPYTHON_EXECUTABLE=${_python3_executable} "
279- "${_python3_executable} " -m pip install --upgrade --no -cache -dir --force-reinstall -r "${_requirements_output_file} "
280- )
281- ELSE ()
282- SET (_requirements_install_command
283- ${CMAKE_COMMAND} -E env
284- "CMAKE_ARGS=-DPYTHON_LIBRARY=${_python3_implib} -DPYTHON_INCLUDE_DIR=${_include_dir} -DPYTHON_EXECUTABLE=${_python3_executable} "
285- "${_python3_executable} " -m pip install --upgrade --no -cache -dir --force-reinstall -r "${_requirements_output_file} "
286- )
287- ENDIF ()
269+ # OpenTimelineIO needs to be built from source with CMAKE_ARGS to ensure it uses
270+ # the correct custom-built Python libraries. This is required for both old and new
271+ # versions of pybind11, especially pybind11 v2.13.6+ which has stricter detection.
272+ # Note: pybind11's FindPythonLibsNew.cmake uses PYTHON_LIBRARY (all caps),
273+ # PYTHON_INCLUDE_DIR, and PYTHON_EXECUTABLE variables.
274+ # --no-cache-dir: Don't use pip's wheel cache (prevents using wheels built for wrong Python version)
275+ # --force-reinstall: Reinstall packages even if already installed (ensures fresh build)
276+
277+ # Set OTIO_CXX_DEBUG_BUILD for all Debug builds to ensure OTIO's C++ extensions
278+ # are built with debug symbols and proper optimization levels matching RV's build type.
279+ # On Windows, this also ensures OTIO links against the debug Python library (python311_d.lib).
280+ IF (CMAKE_BUILD_TYPE MATCHES "^Debug$" )
281+ SET (_otio_debug_env "OTIO_CXX_DEBUG_BUILD=1" )
288282ELSE ()
289- # On macOS and Linux, force pip to build OpenTimelineIO from source and avoid using
290- # cached wheels that may have been built for a different Python version.
291- # This ensures ABI compatibility with our custom-built Python.
292- # --no-cache-dir: Don't use pip's wheel cache (prevents using wheels built for wrong Python version)
293- # --force-reinstall: Reinstall packages even if already installed (ensures fresh build)
294- # CMAKE_ARGS: Tell OTIO's CMake build which Python to use (prevents it from finding system Python via pyenv/etc)
295- SET (_requirements_install_command
296- ${CMAKE_COMMAND} -E env
297- "CMAKE_ARGS=-DPYTHON_EXECUTABLE=${_python3_executable} "
298- "${_python3_executable} " -m pip install --upgrade --no -cache -dir --force-reinstall -r "${_requirements_output_file} "
299- )
283+ SET (_otio_debug_env "" )
300284ENDIF ()
301285
286+ # Single unified command for all platforms and build types
287+ SET (_requirements_install_command
288+ ${CMAKE_COMMAND} -E env
289+ ${_otio_debug_env}
290+ "CMAKE_ARGS=-DPYTHON_LIBRARY=${_python3_cmake_library} -DPYTHON_INCLUDE_DIR=${_include_dir} -DPYTHON_EXECUTABLE=${_python3_executable} "
291+ "${_python3_executable} " -m pip install --upgrade --no -cache -dir --force-reinstall -r "${_requirements_output_file} "
292+ )
293+
302294IF (RV_TARGET_WINDOWS)
303295 SET (_patch_python_command
304296 "patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR} /patch/python-${RV_DEPS_PYTHON_VERSION} /python.${RV_DEPS_PYTHON_VERSION} .openssl.props.patch &&\
0 commit comments