Skip to content

Add recipe for openusd package #29501

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

Open
wants to merge 6 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
19 changes: 19 additions & 0 deletions recipes/openusd/always_link_python_in_tests.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff --git a/cmake/macros/Public.cmake b/cmake/macros/Public.cmake
index 2647707ac6..8f6212ed38 100644
--- a/cmake/macros/Public.cmake
+++ b/cmake/macros/Public.cmake
@@ -653,6 +653,14 @@ function(pxr_build_test TEST_NAME)
${bt_LIBRARIES}
)

+ # The solution in https://github.com/PixarAnimationStudios/OpenUSD/pull/3577 works fine
+ # for executables that directly link usd_tf, while some tests do not directly link usd_tf,
+ # or they directly link it but they do not use tf, so depending on the linker configuration
+ # the link to python may be stripped, so to play sure we explicitly link Python3::Python here.
+ if(PXR_ENABLE_PYTHON_SUPPORT AND PXR_PY_UNDEFINED_DYNAMIC_LOOKUP)
+ target_link_libraries(${TEST_NAME} Python3::Python)
+ endif()
+
# Find libraries under the install prefix, which has the core USD
# libraries.
_pxr_init_rpath(rpath "tests")
67 changes: 67 additions & 0 deletions recipes/openusd/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
mkdir build
cd build

cmake %CMAKE_ARGS% ^
-G "Ninja" ^
-DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
-DCMAKE_BUILD_TYPE=Release ^
-DBUILD_TESTING:BOOL=ON ^
-DBUILD_SHARED_LIBS:BOOL=ON ^
-DPXR_HEADLESS_TEST_MODE:BOOL=ON ^
-DPXR_BUILD_IMAGING:BOOL=ON ^
-DPXR_BUILD_USD_IMAGING=ON ^
-DPXR_ENABLE_PYTHON_SUPPORT=ON ^
-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY:BOOL=ON ^
-DPXR_PYTHON_SHEBANG="/usr/bin/env python" ^
-DPython3_EXECUTABLE=%PYTHON% ^
-DPython_EXECUTABLE=%PYTHON% ^
%SRC_DIR%
if errorlevel 1 exit 1

:: Build.
cmake --build . --config Release
if errorlevel 1 exit 1

:: Install.
cmake --build . --config Release --target install
if errorlevel 1 exit 1

:: Test.
ctest --output-on-failure -C Release
if errorlevel 1 exit 1

:: The CMake install logic of openusd is not flexible, so let's fix the files
:: that should not be installed or should be installed in a different location

:: Python files should be moved from $CMAKE_INSTALL_PREFIX/lib/python/pxr to $SP_DIR/pxr
move "%LIBRARY_PREFIX%\lib\python\pxr" "%SP_DIR%\pxr"
if errorlevel 1 exit 1

:: All files listed in install_manifest.txt that are installed in $CMAKE_INSTALL_PREFIX/tests should be removed
for /f "usebackq delims=" %%F in (`findstr /c:"%LIBRARY_PREFIX%\tests" install_manifest.txt`) do (
echo Deleting %%F
del /q "%%F"
)

:: All files installed in $CMAKE_INSTALL_PREFIX/share/usd/examples and $CMAKE_INSTALL_PREFIX/share/usd/tutorials can be removed
rd /s /q "%LIBRARY_PREFIX%\share\usd\examples"
if errorlevel 1 exit 1

rd /s /q "%LIBRARY_PREFIX%\share\usd\tutorials"
if errorlevel 1 exit 1

REM The METADATA file is necessary to ensure that pip list shows the pip package installed by conda
REM The INSTALLER file is necessary to ensure that pip list shows that the package is installed by conda
REM See https://packaging.python.org/specifications/recording-installed-packages/
REM and https://packaging.python.org/en/latest/specifications/core-metadata/#core-metadata

mkdir "%SP_DIR%/usd_core-%PKG_VERSION%.dist-info"

set metadata_file=%SP_DIR%\usd_core-%PKG_VERSION%.dist-info\METADATA
echo>%metadata_file% Metadata-Version: 2.1
echo>>%metadata_file% Name: usd-core
echo>>%metadata_file% Version: %PKG_VERSION%
echo>>%metadata_file% Summary: Pixar's Universal Scene Description

set installer_file=%SP_DIR%\usd_core-%PKG_VERSION%.dist-info\INSTALLER
echo>%installer_file% conda
68 changes: 68 additions & 0 deletions recipes/openusd/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/sh

mkdir build
cd build

# -fvisibility-inlines-hidden results in linking errors like:
# testVtCpp.cpp:(.text.startup.main+0x2fa): undefined reference to pxrInternal_v0_25_2__pxrReserved__::VtArray<int>::_DecRef()'
# This is a temporary workaround until https://github.com/PixarAnimationStudios/OpenUSD/pull/3452 is merged upstream,
# that should solve this issue in a clean way
export CFLAGS="$(echo $CFLAGS | sed 's/-fvisibility-inlines-hidden//g')"
export CXXFLAGS="$(echo $CXXFLAGS | sed 's/-fvisibility-inlines-hidden//g')"

# From https://conda-forge.org/docs/maintainer/knowledge_base/#finding-numpy-in-cross-compiled-python-packages-using-cmake
Python_INCLUDE_DIR="$(python -c 'import sysconfig; print(sysconfig.get_path("include"))')"
CMAKE_ARGS="${CMAKE_ARGS} -DPython_EXECUTABLE:PATH=${PYTHON}"
CMAKE_ARGS="${CMAKE_ARGS} -DPython_INCLUDE_DIR:PATH=${Python_INCLUDE_DIR}"
CMAKE_ARGS="${CMAKE_ARGS} -DPython3_EXECUTABLE:PATH=${PYTHON}"
CMAKE_ARGS="${CMAKE_ARGS} -DPython3_INCLUDE_DIR:PATH=${Python_INCLUDE_DIR}"

if [[ "${target_platform}" == osx-* ]]; then
# See https://conda-forge.org/docs/maintainer/knowledge_base.html#newer-c-features-with-old-sdk
CXXFLAGS="${CXXFLAGS} -D_LIBCPP_DISABLE_AVAILABILITY"
fi

cmake ${CMAKE_ARGS} -GNinja .. \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING:BOOL=ON \
-DPXR_HEADLESS_TEST_MODE:BOOL=ON \
-DPXR_BUILD_IMAGING:BOOL=ON \
-DPXR_BUILD_USD_IMAGING:BOOL=ON \
-DPXR_ENABLE_PYTHON_SUPPORT:BOOL=ON \
-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY:BOOL=ON \
-DPXR_PYTHON_SHEBANG="/usr/bin/env python"

cmake --build . --config Release
cmake --build . --config Release --target install
ctest --output-on-failure -C Release

# The CMake install logic of openusd is not flexible, so let's fix the files
# that should not be installed or should be installed in a different location

# Python files should be moved from $CMAKE_INSTALL_PREFIX/lib/python/pxr to $SP_DIR/pxr
mv $PREFIX/lib/python/pxr $SP_DIR/pxr

# All files listed in install_manifest.txt that are installed in $CMAKE_INSTALL_PREFIX/tests should be removed
cat install_manifest.txt | grep $PREFIX/tests | xargs --no-run-if-empty --verbose rm -f

# All files installed in $CMAKE_INSTALL_PREFIX/share/usd/examples and $CMAKE_INSTALL_PREFIX/share/usd/tutorials can be removed
rm -rf $PREFIX/share/usd/examples
rm -rf $PREFIX/share/usd/tutorials

# The METADATA file is necessary to ensure that pip list shows the pip package installed by conda
# The INSTALLER file is necessary to ensure that pip list shows that the package is installed by conda
# See https://packaging.python.org/specifications/recording-installed-packages/
# and https://packaging.python.org/en/latest/specifications/core-metadata/#core-metadata

mkdir $SP_DIR/usd_core-$PKG_VERSION.dist-info

cat > $SP_DIR/usd_core-$PKG_VERSION.dist-info/METADATA <<METADATA_FILE
Metadata-Version: 2.1
Name: usd-core
Version: $PKG_VERSION
Summary: Pixar's Universal Scene Description
METADATA_FILE

cat > $SP_DIR/usd_core-$PKG_VERSION.dist-info/INSTALLER <<INSTALLER_FILE
conda
INSTALLER_FILE
29 changes: 29 additions & 0 deletions recipes/openusd/link_python_to_executables.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git a/pxr/external/boost/python/CMakeLists.txt b/pxr/external/boost/python/CMakeLists.txt
index 3874e7b24d..b5bb9f15a4 100644
--- a/pxr/external/boost/python/CMakeLists.txt
+++ b/pxr/external/boost/python/CMakeLists.txt
@@ -338,6 +338,23 @@ target_compile_definitions(python
PRIVATE $<$<NOT:$<CONFIG:Debug>>:NDEBUG>
)

+# Even if PXR_PY_UNDEFINED_DYNAMIC_LOOKUP is defined (to avoid that the usd python extensions
+# links to the python library, to avoid problems with statically linked python interpreters)
+# we want that executables that link usd_python to link with the Python library,
+# as otherwise they would fail due to missing symbols, see
+# https://github.com/PixarAnimationStudios/OpenUSD/issues/2371
+# and https://github.com/PixarAnimationStudios/OpenUSD/issues/2568
+# This can be done by adding to INTERFACE_LINK_LIBRARIES the appropriate generator expression,
+# that will evalute to empty when usd_python is linked to a library, but it will evaluate to
+# Python3::Python when linked to an executable
+if (PXR_PY_UNDEFINED_DYNAMIC_LOOKUP)
+ # This should equivalent to target_link_libraries(python INTERFACE ...), that we can't
+ # use as pxr_library already use the target_link_libraries plain signature, and the two can't be mixed
+ set_property(TARGET python APPEND PROPERTY INTERFACE_LINK_LIBRARIES
+ "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:Python3::Python>"
+ )
+endif()
+
# Since we're not going through the normal pxr_build_test macros
# we need to elide tests here if requested.
if (NOT PXR_BUILD_TESTS)

94 changes: 94 additions & 0 deletions recipes/openusd/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
schema_version: 1

context:
name: openusd
version: 25.05

package:
name: ${{ name }}
version: ${{ version }}

source:
- url: https://github.com/PixarAnimationStudios/OpenUSD/archive/refs/tags/v${{ version }}.tar.gz
sha256: 231faca9ab71fa63d6c1e0da18bda0c365f82d9bef1cfd4b3d3d6784c8d5fb96
patches:
- link_python_to_executables.patch
- always_link_python_in_tests.patch

build:
number: 0
skip:
# osx requires the use of macOS SDK 10.14 via the use of MTLIndirectCommandBuffer, see:
# https://github.com/PixarAnimationStudios/OpenUSD/blob/v25.05/BUILDING.md?plain=1#L110
# So in staged-recipe we skip it, and then the build will be enabled in the feedstock
- osx
# Windows fails due to the CI running out of disk space, see
# https://github.com/conda-forge/staged-recipes/pull/29501#issuecomment-2838524046
# it will be enabled in the feedstock
- win

requirements:
build:
- ${{ compiler('c') }}
- ${{ stdlib('c') }}
- ${{ compiler('cxx') }}
- ninja
- cmake
host:
- if: linux
then:
- libgl-devel
- libglx-devel
- xorg-libxrandr
- glfw
- tbb-devel
- libboost-devel
- libopensubdiv
- python
- jinja2
- pyside6
- pyopengl
run:
- python
run_exports:
- ${{ pin_subpackage(name, upper_bound='x.x') }}

tests:
- package_contents:
include:
- pxr/pxr.h
lib:
- usd_ms
- requirements:
run:
- cmake-package-check
- ${{ compiler('c') }}
- ${{ compiler('cxx') }}
- pip
script:
- cmake-package-check pxr
- usdInitSchema --help
- if: win
then:
- pip list | findstr "usd-core"
else:
- test $(pip list | grep usd-core | tr -s " " | grep $PKG_VERSION | wc -l) -eq 1
- cmake --build . --config Debug --target install
- python:
imports:
- pxr
- pxr.Usd
- pxr.UsdGeom

about:
# The main openusd license is the Tomorrow Open Source Technology License 1.0 (see https://forum.aousd.org/t/upcoming-openusd-license-update/1561)
# The license is not OSI-approved or have an official SPDX identified, so we use LicenseRef-Tomorrow-Open-Source-Technology-License-1.0
# openusd vendors several other libraries, but all their licenses are listed in LICENSE.txt and listed in the following
license: LicenseRef-Tomorrow-Open-Source-Technology-License-1.0 AND Apache-2.0 AND MIT AND BSD-2-Clause AND BSD-3-Clause AND JSON AND BSL-1.0
license_file: LICENSE.txt
summary: Library to read and write Universal Scene Description (USD) files.
homepage: https://github.com/PixarAnimationStudios/OpenUSD

extra:
recipe-maintainers:
- traversaro
Loading