Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that the tests find the built python module vs an install #4411

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/cmake/pythonutils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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/$<CONFIG>/OpenImageIO
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/python${PYTHON_VERSION}/site-packages/$<CONFIG>/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/$<CONFIG>/OpenImageIO/__init__.py)

install(FILES __init__.py DESTINATION ${PYTHON_SITE_DIR})

endmacro ()
Expand Down
14 changes: 14 additions & 0 deletions src/cmake/testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ macro (oiio_add_tests)
"OIIO_TESTSUITE_SRC=${_testsrcdir}"
"OIIO_TESTSUITE_CUR=${_testdir}"
${_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()
Comment on lines +118 to +122
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure I understand all the implications -- now or after future changes we aren't considering -- of setting OpenImageIO_ROOT to point to the src directory, of all places.

And what happens if somebody is building in an environment where OpenImageIO_ROOT is already set to someplace other than this build area (maybe to an existing install)? In that case, this would not be set, and what would that mean?

Wouldn't it be more direct to set OPENIMAGEIO_FONTS to exactly the right spot? And much less likely to affect absolutely anything else?

Also, sorry about this nit, but would you mind using 4-space indentation like the surrounding code? Thanks.

if (USE_PYTHON)
set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT
"PYTHONPATH=$<SHELL_PATH:${CMAKE_BINARY_DIR}/lib/python${PYTHON_VERSION}/site-packages/$<CONFIG>;$ENV{PYTHONPATH}>")
endif()
endif()
if (NOT ${_ats_testdir} STREQUAL "")
set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT
"OIIO_TESTSUITE_IMAGEDIR=${_ats_testdir}")
Expand Down
Loading