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

Merged
merged 2 commits into from
May 12, 2025
Merged
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
72 changes: 72 additions & 0 deletions recipes/openusd/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
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.
:: testWorkThreadLimits3 is disabled as it can fail on machines with few cores
:: testJsIO is disabled as it now actually links usd_tf, and so the linker remove the link to Python
ctest --output-on-failure -C Release -E "testWorkThreadLimits3|testJsIO"
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 installed in $CMAKE_INSTALL_PREFIX/tests, $CMAKE_INSTALL_PREFIX/share/usd/examples and $CMAKE_INSTALL_PREFIX/share/usd/tutorials can be removed
rd /s /q "%LIBRARY_PREFIX%\tests"
if errorlevel 1 exit 1

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 This logic is to ensure that pip list lists usd-core (https://pypi.org/project/usd-core/) as installed package
REM The version style is a bit different: openusd version are something like 22.01, 23.05, 24.11 while usd-core are 22.1, 23.5, 24.11
REM so we convert the first occurence of .0 to . if present, to convert from one style to another
set "PIP_USD_CORE_VERSION=%PKG_VERSION:.0=.%"

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-%PIP_USD_CORE_VERSION%.dist-info"

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

set installer_file=%SP_DIR%\usd_core-%PIP_USD_CORE_VERSION%.dist-info\INSTALLER
echo>%installer_file% conda
75 changes: 75 additions & 0 deletions recipes/openusd/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/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
# testWorkThreadLimits3 is disabled as it can fail on machines with few cores
# testJsIO is disabled as it now actually links usd_tf, and so the linker remove the link to Python
ctest --output-on-failure -C Release -E "testWorkThreadLimits3|testJsIO"

# 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 installed in $CMAKE_INSTALL_PREFIX/tests, $CMAKE_INSTALL_PREFIX/share/usd/examples and $CMAKE_INSTALL_PREFIX/share/usd/tutorials can be removed
rm -rf $PREFIX/tests
rm -rf $PREFIX/share/usd/examples
rm -rf $PREFIX/share/usd/tutorials

# This logic is to ensure that pip list lists usd-core (https://pypi.org/project/usd-core/) as installed package
# The version style is a bit different: openusd version are something like 22.01, 23.05, 24.11 while usd-core are 22.1, 23.5, 24.11
# so we convert the first occurence of .0 to . if present, to convert from one style to another
PIP_USD_CORE_VERSION=${PKG_VERSION/\.0/.}


# 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-$PIP_USD_CORE_VERSION.dist-info

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

cat > $SP_DIR/usd_core-$PIP_USD_CORE_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)

97 changes: 97 additions & 0 deletions recipes/openusd/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
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

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
# openusd builds are quite long, so we only build for Python 3.11 and 3.12 in staged-recipes,
# more Python version will be unblocked in the feedstock
- match(python, "<3.11")

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
# Without tbb-devel, CMake's find_package(pxr REQUIRED) fails
- tbb-devel
run_exports:
- ${{ pin_subpackage(name, upper_bound='x.x') }}

tests:
- package_contents:
include:
- pxr/pxr.h
lib:
- usd_usd
- 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/\.0/.} | wc -l) -eq 1
- 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