LucaScheller / VFX-UsdAssetResolver

Usd Asset Resolver Reference Implementations
https://lucascheller.github.io/VFX-UsdAssetResolver/
Apache License 2.0
104 stars 21 forks source link

Building CachedResolver for Nuke 15.1v3 on Windows #19

Open dovanbel opened 1 day ago

dovanbel commented 1 day ago

Hi @LucaScheller

EDIT : sorry for all the messages, it's a bit of noise : Long story short, I managed to build the CachedResolver for Nuke, please see the last message : https://github.com/LucaScheller/VFX-UsdAssetResolver/issues/19#issuecomment-2366859486

I'm trying to build the CachedResolver for Nuke 15.1v3 on Windows. I tried modifying the CMakeLists.txt, but I feel like I'm playing a escape game :-)

Nuke 15.1v3 is using Python 3.10.10 [MSC v.1935 64 bit (AMD64)], Boost 1.80.0, USD 0.23.11 and is build with Visual Studio 2019

In Nuke's program folder there's a subfolder /FnUSD/ which contains most of the necessary files (I think) Boost include files are missing from the program, but I could download it from https://thefoundry.s3.amazonaws.com/products/nuke/developers/151/wins/boost.tar.gz (see page https://www.foundry.com/products/nuke-family/developers)

One thing I noticed is that in the program folder of Nuke, there's a file named : foundryboost_python310-vc143-mt-x64-1_80.dll, but in the downloaded Boost files, the files are named 'boost' and not 'foundryboost'. Not sure this is relevant but it might be. I set the variable AR_BOOST_NAMESPACE to 'boost'

I added these lines to the CMakeLists.txt file :

elseif("$ENV{AR_DCC_NAME}" STREQUAL "NUKE")
    # Nuke
    # Python
    set(AR_PYTHON_ROOT $ENV{PYTHON_ROOT} CACHE PATH "Python install directory")
    set(AR_PYTHON_LIB python3.10)
    set(AR_PYTHON_LIB_NUMBER python310)

    set(AR_PYTHON_LIB_DIR ${AR_PYTHON_ROOT}/libs)
    set(AR_PYTHON_INCLUDE_DIR ${AR_PYTHON_ROOT}/include)
    set(AR_PYTHON_EXECUTABLE ${AR_PYTHON_ROOT}/bin/python3) 

    # Boost
    set(AR_BOOST_NAMESPACE boost)
    set(AR_BOOST_PYTHON_LIB ${AR_BOOST_NAMESPACE}_${AR_PYTHON_LIB_NUMBER}-vc143-mt-x64-1_80)

    set(AR_BOOST_INCLUDE_DIR "C:/Users/toto/VFX-UsdAssetResolver/nuke/boost/include/boost-1_80")

    # Usd
    set(AR_PXR_LIB_DIR "C:/Program Files/Nuke15.1v3/FnUSD/lib")
    set(AR_PXR_LIB_PREFIX "usd_")
    set(AR_PXR_INCLUDE_DIR "C:/Program Files/Nuke15.1v3/FnUSD/include")
    set(AR_PXR_PYTHON_LIB_SITEPACKAGES "C:/Program Files/Nuke15.1v3/FnUSD/lib/python")
endif()

I then run the bat file modified like this:

set AR_RESOLVER_NAME=cachedResolver
set AR_DCC_NAME=NUKE
rmdir /S /Q build
rmdir /S /Q dist
rem cmake . -B build -G "Visual Studio 17 2022" -A x64 -T v143
cmake . -B build -G "Visual Studio 16 2019" -A x64 -T v142
cmake --build build  --clean-first --config Release
cmake --install build

When running the line : cmake --build build --clean-first --config Release

I get errors :

Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  1>Checking Build System
  Building Custom Rule C:/Users/toto/VFX-UsdAssetResolver/src/CachedResolver/CMakeLists.txt
cl : command line warning D9025: overriding '/W1' with '/w' [C:\Users\toto\VFX-UsdAssetResolver\build\src\CachedResolve
r\cachedResolver.vcxproj]
  debugCodes.cpp
  resolver.cpp
C:\Users\toto\VFX-UsdAssetResolver\nuke\boost\include\boost-1_80\boost/python/detail/wrap_python.hpp(57,11): fatal erro
r C1083: Cannot open include file: 'pyconfig.h': No such file or directory [C:\Users\toto\VFX-UsdAssetResolver\build\sr
c\CachedResolver\cachedResolver.vcxproj]
  resolverContext.cpp
C:\Users\toto\VFX-UsdAssetResolver\nuke\boost\include\boost-1_80\boost/python/detail/wrap_python.hpp(57,11): fatal erro
r C1083: Cannot open include file: 'pyconfig.h': No such file or directory [C:\Users\toto\VFX-UsdAssetResolver\build\sr
c\CachedResolver\cachedResolver.vcxproj]
  resolverTokens.cpp
  module.cpp
C:\Users\toto\VFX-UsdAssetResolver\nuke\boost\include\boost-1_80\boost/python/detail/wrap_python.hpp(57,11): fatal erro
r C1083: Cannot open include file: 'pyconfig.h': No such file or directory [C:\Users\toto\VFX-UsdAssetResolver\build\sr
c\CachedResolver\cachedResolver.vcxproj]
  moduleDeps.cpp
C:\Users\toto\VFX-UsdAssetResolver\nuke\boost\include\boost-1_80\boost/python/detail/wrap_python.hpp(57,11): fatal erro
r C1083: Cannot open include file: 'pyconfig.h': No such file or directory [C:\Users\toto\VFX-UsdAssetResolver\build\sr
c\CachedResolver\cachedResolver.vcxproj]
  wrapResolver.cpp
C:\Users\toto\VFX-UsdAssetResolver\nuke\boost\include\boost-1_80\boost/python/detail/wrap_python.hpp(57,11): fatal erro
r C1083: Cannot open include file: 'pyconfig.h': No such file or directory [C:\Users\toto\VFX-UsdAssetResolver\build\sr
c\CachedResolver\cachedResolver.vcxproj]
  wrapResolverContext.cpp
C:\Users\toto\VFX-UsdAssetResolver\nuke\boost\include\boost-1_80\boost/python/detail/wrap_python.hpp(57,11): fatal erro
r C1083: Cannot open include file: 'pyconfig.h': No such file or directory [C:\Users\toto\VFX-UsdAssetResolver\build\sr
c\CachedResolver\cachedResolver.vcxproj]
  wrapResolverTokens.cpp
C:\Users\toto\VFX-UsdAssetResolver\nuke\boost\include\boost-1_80\boost/python/detail/wrap_python.hpp(57,11): fatal erro
r C1083: Cannot open include file: 'pyconfig.h': No such file or directory [C:\Users\toto\VFX-UsdAssetResolver\build\sr
c\CachedResolver\cachedResolver.vcxproj]
  Generating Code...

The file: C:\Users\toto\VFX-UsdAssetResolver\nuke\boost\include\boost-1_80\boost\python\detail\wrap_python.hpp exists on disk and has the same contents as the same file in Maya's USD devkit (0.29.0)

I hope you could point out what needs to be fixed

Regards

dovanbel commented 14 hours ago

I did investigate a bit more :

My modified CmakeLists.txt file :

elseif("$ENV{AR_DCC_NAME}" STREQUAL "NUKE")
    # Nuke
    # Python
    set(AR_PYTHON_ROOT $ENV{PYTHON_ROOT} CACHE PATH "Python install directory")
    set(AR_PYTHON_LIB python3.10)
    set(AR_PYTHON_LIB_NUMBER python310)

    set(AR_PYTHON_LIB_DIR ${AR_PYTHON_ROOT}/libs)
    set(AR_PYTHON_INCLUDE_DIR ${AR_PYTHON_ROOT}/include)
    set(AR_PYTHON_EXECUTABLE ${AR_PYTHON_ROOT}/python.exe) 

    # Boost
    set(AR_BOOST_NAMESPACE boost)
    set(AR_BOOST_PYTHON_LIB ${AR_BOOST_NAMESPACE}_${AR_PYTHON_LIB_NUMBER}-vc143-mt-x64-1_80)
    set(AR_BOOST_INCLUDE_DIR "C:/Users/toto/NUKEBO/boost/include/boost-1_80")

    # Usd
    set(AR_PXR_LIB_DIR "C:/Program Files/Nuke15.1v3/FnUSD/lib")
    set(AR_PXR_LIB_PREFIX "usd_")
    set(AR_PXR_INCLUDE_DIR "C:/Program Files/Nuke15.1v3/FnUSD/include")
    set(AR_PXR_PYTHON_LIB_SITEPACKAGES "C:/Program Files/Nuke15.1v3/FnUSD/lib/python")

and I added :

if("$ENV{AR_DCC_NAME}" STREQUAL "HOUDINI")
    link_directories(${AR_HOUDINI_LIB_DIR})
endif()
if("$ENV{AR_DCC_NAME}" STREQUAL "NUKE")
    link_directories("C:/Users/toto/NUKEBO/boost/lib")
endif()  

My build.bat :

set PYTHON_ROOT=C:\Program Files\Python310
set AR_RESOLVER_NAME=cachedResolver
set AR_DCC_NAME=NUKE
cmake . -B build -G "Visual Studio 16 2019" -A x64 -T v142
cmake --build build  --clean-first --config Release

When doing the build I get this error :

 Building Custom Rule C:/Users/toto/VFX-UsdAssetResolver/src/CachedResolver/CMakeLists.txt
cl : command line warning D9025: overriding '/W1' with '/w' [C:\Users\toto\VFX-UsdAssetResolver\build\src\CachedResolver\cachedResolver.vcxproj]
  debugCodes.cpp
  resolver.cpp
C:\Program Files\Nuke15.1v3\FnUSD\include\pxr/base/tf/diagnosticMgr.h(46,10): fatal error C1083: Cannot open include file: 'tbb/enumerable_thread_specific.h': No such file or directory [C:\Users\toto\VFX-UsdAssetResolver\build\src\CachedResolver\cachedResolver.vcxproj]
  resolverContext.cpp
C:\Program Files\Nuke15.1v3\FnUSD\include\pxr/base/tf/diagnosticMgr.h(46,10): fatal error C1083: Cannot open include file: 'tbb/enumerable_thread_specific.h': No such file or directory [C:\Users\toto\VFX-UsdAssetResolver\build\src\CachedResolver\cachedResolver.vcxproj]
  resolverTokens.cpp
  module.cpp
  moduleDeps.cpp
  wrapResolver.cpp
  wrapResolverContext.cpp
  wrapResolverTokens.cpp
  Generating Code...
dovanbel commented 14 hours ago

Still trying : Nuke's USD include directory C:\Program Files\Nuke15.1v3\FnUSD\include has no "tbb" subdir I copied the "tbb" folder from Maya's USD devkit include folder

Re-did the build. Now it fails with :

LINK : fatal error LNK1181: cannot open input file 'boost_python310-vc143-mt-x64-1_80.lib' [C:\Users\toto\VFX-UsdAssetResolver\build\src\CachedResolver
\cachedResolver.vcxproj]
dovanbel commented 14 hours ago

I managed to build the CachedResolver, however I did not yet test it in Nuke 15.1v3 (will do tomorrow I hope)

Here's my modifications to the CMakeLists.txt :

elseif("$ENV{AR_DCC_NAME}" STREQUAL "NUKE")
    # Nuke
    # Python
    set(AR_PYTHON_ROOT $ENV{PYTHON_ROOT} CACHE PATH "Python install directory")
    set(AR_PYTHON_LIB python3.10)
    set(AR_PYTHON_LIB_NUMBER python310)

    set(AR_PYTHON_LIB_DIR ${AR_PYTHON_ROOT}/libs)
    set(AR_PYTHON_INCLUDE_DIR ${AR_PYTHON_ROOT}/include)
    set(AR_PYTHON_EXECUTABLE ${AR_PYTHON_ROOT}/python.exe) 

    # Boost
    set(AR_BOOST_NAMESPACE boost)
    set(AR_BOOST_PYTHON_LIB foundryboost_${AR_PYTHON_LIB_NUMBER}-vc143-mt-x64-1_80)

    set(AR_BOOST_INCLUDE_DIR "C:/Users/toto/NUKEBO/boost/include/boost-1_80")

    # Usd
    set(AR_PXR_LIB_DIR "C:/Program Files/Nuke15.1v3/FnUSD/lib")
    set(AR_PXR_LIB_PREFIX "usd_")
    set(AR_PXR_INCLUDE_DIR "C:/Program Files/Nuke15.1v3/FnUSD/include")
    set(AR_PXR_PYTHON_LIB_SITEPACKAGES "C:/Program Files/Nuke15.1v3/FnUSD/lib/python")

and after lineinclude_directories(${CMAKE_SOURCE_DIR}/src/utils)

# Houdini
if("$ENV{AR_DCC_NAME}" STREQUAL "HOUDINI")
    link_directories(${AR_HOUDINI_LIB_DIR})
endif()
if("$ENV{AR_DCC_NAME}" STREQUAL "NUKE")
    link_directories("C:/Users/toto/NUKEBO/boost/lib")
endif()  

My build.bat :

set PYTHON_ROOT=C:\Program Files\Python310
set AR_RESOLVER_NAME=cachedResolver
set AR_DCC_NAME=NUKE
cmake . -B build -G "Visual Studio 16 2019" -A x64 -T v142
cmake --build build  --clean-first --config Release
cmake --install build

However : the build first failed because of some missing files. To make it work I copied over some files and dirs from Maya's USD devkit over to the C:\Program Files\Nuke15.1v3\FnUSD directory, specifically : copied dir 'tbb' C:\Program Files\Autodesk\MayaUSD\Maya2025\0.29.0\mayausd\USD\devkit\include\tbb to C:\Program Files\Nuke15.1v3\FnUSD\include\ and copied file 'tbb.lib' from C:\Program Files\Autodesk\MayaUSD\Maya2025\0.29.0\mayausd\USD\devkit\lib\tbb.lib to C:\Program Files\Nuke15.1v3\FnUSD\lib

This is from Maya latest usd devkit, so I anticipate problems because it will probably not be the same usd version as the one in Nuke, but anyway I'll try. If it doesn't work I'll try to download those 'tbb' libraries for the correct usd version

Fingers crossed :-)

Edit : I couldn't wait... It works : I can confirm the CachedResolver works in Nuke 15.1v3... A-ma-zing ! I got lucky with the files that I took from Maya's usd devkit I suppose, I checked and they are from the same version of USD (0.23.11) as Nuke's USD version