From 04848f029cb95e5623f6a5699cd9f4b96bde2d5a Mon Sep 17 00:00:00 2001 From: Kimball Thurston Date: Mon, 9 Sep 2024 08:50:42 +1200 Subject: [PATCH 1/3] Ensure that the tests find the built python python module vs an installed one This may have a slightly messy un-intended consequence of "snap-shotting" pythonpath when configured in a large python env, but eases testing confusion on systems where pythonpath is not yet set, but an (older) copy of OpenImageIO is installed. Signed-off-by: Kimball Thurston --- src/cmake/testing.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cmake/testing.cmake b/src/cmake/testing.cmake index bedf2faf48..5ba445b29b 100644 --- a/src/cmake/testing.cmake +++ b/src/cmake/testing.cmake @@ -110,6 +110,7 @@ macro (oiio_add_tests) "OIIO_TESTSUITE_ROOT=${_testsuite}" "OIIO_TESTSUITE_SRC=${_testsrcdir}" "OIIO_TESTSUITE_CUR=${_testdir}" + "PYTHONPATH=${CMAKE_BINARY_DIR}/lib/python/site-packages:$ENV{PYTHONPATH}" ${_ats_ENVIRONMENT}) if (NOT ${_ats_testdir} STREQUAL "") set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT From 4e08f52c14b3173e372bf3a3aba46655e9026488 Mon Sep 17 00:00:00 2001 From: Kimball Thurston Date: Sat, 14 Sep 2024 12:17:20 +1200 Subject: [PATCH 2/3] Use generator expression to get correct OS separator Signed-off-by: Kimball Thurston --- src/cmake/testing.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmake/testing.cmake b/src/cmake/testing.cmake index 5ba445b29b..ace7078256 100644 --- a/src/cmake/testing.cmake +++ b/src/cmake/testing.cmake @@ -110,7 +110,7 @@ macro (oiio_add_tests) "OIIO_TESTSUITE_ROOT=${_testsuite}" "OIIO_TESTSUITE_SRC=${_testsrcdir}" "OIIO_TESTSUITE_CUR=${_testdir}" - "PYTHONPATH=${CMAKE_BINARY_DIR}/lib/python/site-packages:$ENV{PYTHONPATH}" + "PYTHONPATH=$" ${_ats_ENVIRONMENT}) if (NOT ${_ats_testdir} STREQUAL "") set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT From 1340c90bab7d737e2942e94284de4138c6f18bf6 Mon Sep 17 00:00:00 2001 From: Kimball Thurston Date: Sat, 14 Sep 2024 16:30:28 +1200 Subject: [PATCH 3/3] Make build tree look more like install tree Also adds python version and init.py to build tree such that windows has a chance of working with the DLL loading Signed-off-by: Kimball Thurston --- src/cmake/pythonutils.cmake | 10 ++++++++-- src/cmake/testing.cmake | 15 ++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/cmake/pythonutils.cmake b/src/cmake/pythonutils.cmake index c5f4720400..187155c927 100644 --- a/src/cmake/pythonutils.cmake +++ b/src/cmake/pythonutils.cmake @@ -133,14 +133,20 @@ macro (setup_python_module) # non-python libraries of the same name (which aren't prefixed by "lib" # on Windows). set_target_properties (${target_name} PROPERTIES - LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/python/site-packages - ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/python/site-packages + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/python${PYTHON_VERSION}/site-packages/$/OpenImageIO + ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/python${PYTHON_VERSION}/site-packages/$/OpenImageIO ) install (TARGETS ${target_name} RUNTIME DESTINATION ${PYTHON_SITE_DIR} COMPONENT user LIBRARY DESTINATION ${PYTHON_SITE_DIR} COMPONENT user) + add_custom_command ( + TARGET ${target_name} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py + ${CMAKE_BINARY_DIR}/lib/python${PYTHON_VERSION}/site-packages/$/OpenImageIO/__init__.py) + install(FILES __init__.py DESTINATION ${PYTHON_SITE_DIR}) endmacro () diff --git a/src/cmake/testing.cmake b/src/cmake/testing.cmake index ace7078256..379ce0b08d 100644 --- a/src/cmake/testing.cmake +++ b/src/cmake/testing.cmake @@ -110,8 +110,21 @@ macro (oiio_add_tests) "OIIO_TESTSUITE_ROOT=${_testsuite}" "OIIO_TESTSUITE_SRC=${_testsrcdir}" "OIIO_TESTSUITE_CUR=${_testdir}" - "PYTHONPATH=$" ${_ats_ENVIRONMENT}) + if (NOT DEFINED ENV{GITHUB_ACTIONS}) + # the github actions run all the tests from the dist tree + # and do an install prior to running the tests so skip + # setting these here + if (NOT DEFINED ENV{OpenImageIO_ROOT}) + # this will ensure the appropriate fonts are found + set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT + "OpenImageIO_ROOT=${CMAKE_SOURCE_DIR}/src") + endif() + if (USE_PYTHON) + set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT + "PYTHONPATH=$;$ENV{PYTHONPATH}>") + endif() + endif() if (NOT ${_ats_testdir} STREQUAL "") set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT "OIIO_TESTSUITE_IMAGEDIR=${_ats_testdir}")