diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index cd0225f..f0e9407 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -2,7 +2,7 @@ name: test-linux on: push: - branches: [ main ] + branches: [ main, dev ] pull_request: branches: [ main, dev ] @@ -15,17 +15,14 @@ permissions: jobs: test-linux: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest timeout-minutes: 300 strategy: fail-fast: false matrix: - usd: ["v23.11", "v24.08"] - python: ["3.7", "3.10"] - include: - - usd: "v24.08" - python: "3.11" + usd: ["v25.05"] + python: ["3.10", "3.12"] name: "USD-${{ matrix.usd }}-py${{ matrix.python }}" diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index c93fd30..1f58f5c 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -2,7 +2,7 @@ name: test-windows on: push: - branches: [ main ] + branches: [ main, dev ] pull_request: branches: [ main, dev ] @@ -21,11 +21,8 @@ jobs: strategy: fail-fast: false matrix: - usd: ["v23.11", "v24.08"] - python: ["3.7", "3.10"] - include: - - usd: "v24.08" - python: "3.11" + usd: ["v25.05"] + python: ["3.10", "3.12"] name: "USD-${{ matrix.usd }}-py${{ matrix.python }}" diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e2b141..95a3707 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,9 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) # https://cmake.org/cmake/help/latest/policy/CMP0094.html cmake_policy(SET CMP0094 NEW) +find_package(USD 0.20.11 REQUIRED) +find_package(TBB 2017.0 COMPONENTS tbb REQUIRED) + if(BUILD_PYTHON_BINDINGS) # The 'manylinux' images do not include the Python library. # CMake >= 3.18 is required for this option to work as expected. @@ -82,11 +85,13 @@ if(BUILD_PYTHON_BINDINGS) set(_py_version ${Python_VERSION_MAJOR}${Python_VERSION_MINOR}) mark_as_advanced(_py_version) - find_package(Boost 1.70.0 COMPONENTS "python${_py_version}" REQUIRED) + if (NOT USD_USE_INTERNAL_BOOST_PYTHON) + find_package(Boost 1.70.0 COMPONENTS "python${_py_version}" REQUIRED) - # Define generic target for Boost Python if necessary. - if (NOT TARGET Boost::python) - add_library(Boost::python ALIAS "Boost::python${_py_version}") + # Define generic target for Boost Python if necessary. + if (NOT TARGET Boost::python) + add_library(Boost::python ALIAS "Boost::python${_py_version}") + endif() endif() # Set variable to identify the path to install and test python libraries. @@ -97,13 +102,8 @@ if(BUILD_PYTHON_BINDINGS) set(PYTHON_DESTINATION "${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION}/site-packages" CACHE INTERNAL "Python library path.") -else() - find_package(Boost 1.70.0 REQUIRED) endif() -find_package(USD 0.20.11 REQUIRED) -find_package(TBB 2017.0 COMPONENTS tbb REQUIRED) - add_subdirectory(src) if (BUILD_TESTS) diff --git a/cmake/modules/FindUSD.cmake b/cmake/modules/FindUSD.cmake index 04e25f3..6c5dcf6 100644 --- a/cmake/modules/FindUSD.cmake +++ b/cmake/modules/FindUSD.cmake @@ -38,15 +38,9 @@ find_path( include ) -set(USD_LIBRARIES usd sdf tf plug arch vt) +set(USD_LIBRARIES usd sdf tf plug arch vt boost python) -set(USD_DEPENDENCIES "Boost::boost;TBB::tbb") - -if (BUILD_PYTHON_BINDINGS) - set(USD_DEPENDENCIES "${USD_DEPENDENCIES};Python::Python;Boost::python") -endif() - -mark_as_advanced(USD_INCLUDE_DIR USD_LIBRARIES USD_DEPENDENCIES) +mark_as_advanced(USD_INCLUDE_DIR USD_LIBRARIES) foreach(NAME IN LISTS USD_LIBRARIES) find_library( @@ -64,6 +58,7 @@ foreach(NAME IN LISTS USD_LIBRARIES) mark_as_advanced("${NAME}_LIBRARY") endforeach() + if(USD_INCLUDE_DIR AND EXISTS "${USD_INCLUDE_DIR}/pxr/pxr.h") file(READ "${USD_INCLUDE_DIR}/pxr/pxr.h" _pxr_header) foreach(label MAJOR MINOR PATCH) @@ -75,11 +70,34 @@ if(USD_INCLUDE_DIR AND EXISTS "${USD_INCLUDE_DIR}/pxr/pxr.h") set(USD_VERSION ${_pxr_MAJOR}.${_pxr_MINOR}.${_pxr_PATCH}) + set(USD_DEPENDENCIES "TBB::tbb") + if (BUILD_PYTHON_BINDINGS) + list(APPEND USD_DEPENDENCIES "Python::Python") + endif() + + # Detect whether PXR_USE_INTERNAL_BOOST_PYTHON is explicitly enabled + set(USD_USE_INTERNAL_BOOST_PYTHON ON CACHE INTERNAL "") + string(REGEX MATCH + "#if +1[^\n]*\n[ \t]*#define +PXR_USE_INTERNAL_BOOST_PYTHON" + _use_internal_boost_python "${_pxr_header}") + + # Use external Boost dependencies if USD version is less than 0.25.5, and + # if internal Boost.Python is not explicitly enabled + if (USD_VERSION VERSION_LESS "0.25.5" AND NOT _use_internal_boost_python) + set(USD_USE_INTERNAL_BOOST_PYTHON OFF CACHE INTERNAL "") + list(APPEND USD_DEPENDENCIES "Boost::boost") + if (BUILD_PYTHON_BINDINGS) + list(APPEND USD_DEPENDENCIES "Boost::python") + endif() + endif() + mark_as_advanced( _pxr_MAJOR _pxr_MINOR _pxr_PATCH + _use_internal_boost_python USD_VERSION + USD_DEPENDENCIES ) endif() @@ -93,6 +111,8 @@ find_package_handle_standard_args( plug_LIBRARY arch_LIBRARY vt_LIBRARY + boost_LIBRARY + python_LIBRARY VERSION_VAR USD_VERSION ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 45fb21f..021c967 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -40,6 +40,12 @@ target_link_libraries(unf usd::vt ) +# Transitive Pixar libraries depend on vendorized Boost.Python +# (Required due to manual CMake module used to locate USD) +if (BUILD_PYTHON_BINDINGS) + target_link_libraries(unf PUBLIC usd::boost usd::python) +endif() + install( TARGETS unf EXPORT ${PROJECT_NAME} diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index e5d23d6..97539fb 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -29,11 +29,13 @@ target_include_directories(pyUnf $ ) -target_link_libraries(pyUnf - PUBLIC - unf - Boost::python -) +target_link_libraries(pyUnf PUBLIC unf) + +if (NOT USD_USE_INTERNAL_BOOST_PYTHON) + target_link_libraries(pyUnf PUBLIC Boost::python) +else() + target_link_libraries(pyUnf PUBLIC usd::boost usd::python) +endif() set_target_properties(pyUnf PROPERTIES diff --git a/src/python/predicate.h b/src/python/predicate.h index 563adbf..9d51bc7 100644 --- a/src/python/predicate.h +++ b/src/python/predicate.h @@ -8,11 +8,16 @@ #include #include +#ifndef PXR_USE_INTERNAL_BOOST_PYTHON #include +using namespace boost::python; +#else +#include +using namespace PXR_BOOST_PYTHON_NAMESPACE; +#endif #include -using namespace boost::python; using namespace unf; PXR_NAMESPACE_USING_DIRECTIVE diff --git a/src/python/wrapBroker.cpp b/src/python/wrapBroker.cpp index 9e94015..93bd6f0 100644 --- a/src/python/wrapBroker.cpp +++ b/src/python/wrapBroker.cpp @@ -13,9 +13,16 @@ #include #include +#ifndef PXR_USE_INTERNAL_BOOST_PYTHON #include - using namespace boost::python; +using noncopyable = boost::noncopyable; +#else +#include +using namespace PXR_BOOST_PYTHON_NAMESPACE; +using noncopyable = PXR_BOOST_PYTHON_NAMESPACE::noncopyable; +#endif + using namespace unf; PXR_NAMESPACE_USING_DIRECTIVE @@ -31,7 +38,7 @@ void wrapBroker() // Ensure that predicate function can be passed from Python. TfPyFunctionFromPython<_CapturePredicateFuncRaw>(); - class_( + class_( "Broker", "Intermediate object between the Usd Stage and any clients that needs " "asynchronous handling and upstream filtering of notices.", diff --git a/src/python/wrapCapturePredicate.cpp b/src/python/wrapCapturePredicate.cpp index 152c2cc..f0e6236 100644 --- a/src/python/wrapCapturePredicate.cpp +++ b/src/python/wrapCapturePredicate.cpp @@ -2,9 +2,14 @@ #include "unf/capturePredicate.h" +#ifndef PXR_USE_INTERNAL_BOOST_PYTHON #include - using namespace boost::python; +#else +#include +using namespace PXR_BOOST_PYTHON_NAMESPACE; +#endif + using namespace unf; PXR_NAMESPACE_USING_DIRECTIVE diff --git a/src/python/wrapNotice.cpp b/src/python/wrapNotice.cpp index 6dae635..1308adf 100644 --- a/src/python/wrapNotice.cpp +++ b/src/python/wrapNotice.cpp @@ -9,9 +9,14 @@ #include +#ifndef PXR_USE_INTERNAL_BOOST_PYTHON #include - using namespace boost::python; +#else +#include +using namespace PXR_BOOST_PYTHON_NAMESPACE; +#endif + using namespace unf::UnfNotice; PXR_NAMESPACE_USING_DIRECTIVE diff --git a/src/python/wrapTransaction.cpp b/src/python/wrapTransaction.cpp index e1c5783..bd5c027 100644 --- a/src/python/wrapTransaction.cpp +++ b/src/python/wrapTransaction.cpp @@ -9,10 +9,16 @@ #include #include +#ifndef PXR_USE_INTERNAL_BOOST_PYTHON #include #include - using namespace boost::python; +#else +#include +#include +using namespace PXR_BOOST_PYTHON_NAMESPACE; +#endif + using namespace unf; PXR_NAMESPACE_USING_DIRECTIVE diff --git a/test/utility/unfTest/observer.h b/test/utility/unfTest/observer.h index 9695237..37c496a 100644 --- a/test/utility/unfTest/observer.h +++ b/test/utility/unfTest/observer.h @@ -6,8 +6,7 @@ #include #include -#include - +#include #include namespace Test { @@ -64,7 +63,7 @@ class Observer : public PXR_NS::TfWeakBase { } } - boost::optional _notice; + std::optional _notice; size_t _count; PXR_NS::TfNotice::Key _key; std::function _callback;