Skip to content

Instantly share code, notes, and snippets.

@BigRoy
Last active May 5, 2020 14:37
Show Gist options
  • Save BigRoy/4593ef47f39a3589308454088a0a2753 to your computer and use it in GitHub Desktop.
Save BigRoy/4593ef47f39a3589308454088a0a2753 to your computer and use it in GitHub Desktop.
Notes on compiling maya-usd repository on Windows 10 - as was posted on CG-Wire Slack channel by Tomas Poveda
I have done multiple tests trying to compile usd_maya repo. I have achieved to compile it in 2 different ways.
* With CMake. Using CMake directly is cool because you can setup all variables in UI and you can easily check the values of the different arguments for compilation. The problem
is that the libraries are generated in different folders and you need to a lot of manual work to create a proper data folder structure to make everything work as expected.
* Using build.py usd_maya script. This is the quickest and easy way of building the library.
1. Make sure that you have devkit installed in your Maya installation folder.
2. Make sure that your Python has installed PyOpenGL and PySide
2.1. Go to Scripts folder in your Python directory and call pip install PySide (necessary to work with usdview)
2.2. Go to Scripts folder in your Python directory and call pip install PyOpenGL (necessary to work usdview)
3. Launch command line and make sure vcvarsall.bat is launched. You can do in 2 different ways:
3.1. Launch cmd and call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat"
3.2. Launch vs2015 x64 native system tool symbols command line. This will automatically call vcvarsall.bat for you.
4. Clone USD Pixar repository: https://github.com/PixarAnimationStudios/USD
1.1. We MUST use the same USD version that Maya USD plugin is supporting.
1.1.1. git clone https://github.com/PixarAnimationStudios/USD
1.1.2. cd USD
1.1.3. git checkout v19.05
5. Open cmd and go to: USD\build_scripts
6. In that folder, call in cmd: "C:\Python27\python.exe" build_usd.py --build-args boost,"--with-date_time --with-thread --with-system --with-filesystem" --no-maya C:\usd
NOTE: It's important to intall those specific Boost libraries because AL_USD needs them.
7. Wait until the process finishes. This can take some time.
8. Check output in cmd, it will tell you to add some paths into environment variables. Do it.
7.1. Add C:\usd\lib\python into PYTHONPATH
7.2. Add C:\usd\bin
7.3. Add C:\usd\lib
9. Clone USD_Maya repository: git clone https://github.com/Autodesk/maya-usd.git
10. USD in Windows has a problem with pxrTargets.cmake. Some libraries (hdStream, usdObj & usdShaders) are dynamic libs and have no .lib files on Windows.
9.1. Go to C:\usd\cmake and open pxrTargets.cmake
9.2. Search for "if(NOT EXISTS "${file}" 433
9.3. Replace that line with the following code:
# =============================================================================================
get_filename_component(barename "${file}" NAME_WE)
# HACK - the following are dynamic libs in Windows (no .lib) - these will be dll's only
set(skip_dynamic_libs "hdStream" "usdObj" "usdShaders")
list(FIND skip_dynamic_libs ${barename} _index)
if(NOT EXISTS "${file}" AND NOT ((${_index} GREATER -1) AND WIN32))
# =============================================================================================
11. I have also detected some problems during build when FindUSD does not find usdGenSchema file.
10.1. Go to your USD repo folder (not the installation) and go to USD\pxr\usd\lib\usd. There you will find a file called usdGenSchema.py
10.2. Copy that file and paste it in C:\usd\bin
10.3. Also remove the .py extension from that file and rename only to usdGenSchema
12. Open cmd and go to maya-usd root repositoy folder
13. In that folder, call in cmd: "C:\Python27\python.exe" build.py --maya-location "C:\Program Files\Autodesk\maya2018" --pxrusd-location C:\usd C:\usd-maya
14. Wait until the process finishes. This can take some time.
15. Go to C:\usd-maya\install\RelWithDebInfo. In that folder you will find mayaUSD.mod file.
16. Copy that file and paste in documents/maya/2018/modules
17. Open that file in your text editor and replace it with the following context:
# =============================================================================================
+ USD 19.05 C:\usd
PYTHONPATH+:=lib/python
PATH+:=bin
PATH+:=lib
+ PXR_USDMAYA 19.05 C:\usd-maya\install\RelWithDebInfo\plugin\pxr
PYTHONPATH+:=lib/python
PATH+:=maya/lib
XBMLANGPATH+:=maya/lib/usd/usdMaya/resources
MAYA_SCRIPT_PATH+:=maya/lib/usd/usdMaya/resources
MAYA_PLUG_IN_PATH+:=maya/plugin
PXR_PLUGINPATH_NAME+:=lib/usd
+ AL_USDMaya 0.34.0 C:\usd-maya\install\RelWithDebInfo\plugin\al
PYTHONPATH+:=lib/python
PATH+:=lib
MAYA_PLUG_IN_PATH+:=plugin
PXR_PLUGINPATH_NAME+:=lib/usd
# =============================================================================================
18. Launch Maya 2018
19. Now you need to load AL_USD plugin
# =============================================================================================
from maya import cmds
cmds.loadPlugin('AL_USDMayaPlugin')
# =============================================================================================
20. USD menu will be created and you will be able to create Proxy Shapes
@BigRoy
Copy link
Author

BigRoy commented Sep 16, 2019

I've followed along with these notes and have succesfully compiled the plug-in for Maya 2019 on Windows 10 using Visual Studio 2017.

The only additional thing I hit along the way was that I needed jinja2 to build maya-usd. To do so you'll need to do a pip install jinja2 for that Python interpreter.

I shared the compiled binaries on the Avalon Gitter.

@BigRoy
Copy link
Author

BigRoy commented Sep 17, 2019

Point 11. of the compiling notes seem to be the same as this issue which states that you won't hit that issue if your have jinja2 installed for the Python process before compiling USD.

@BigRoy
Copy link
Author

BigRoy commented Oct 9, 2019

Compiling maya-usd with the refactoring_sandbox branch with USD commit b85ddac2

When compiling the refactoring_sandbox branch I still hit this issue here with the workaround however now with USD commit b85ddac2 (as per the branch Developer doc) and this refactoring_sandbox branch it didn't completely fix it. It also failed on usdDancingCubesExample and usdRecursivePayloadsExample as described here. Yet it also failed on hdStorm with that specific commit of USD so somehow I had to skip it too.

It seemed to continue compilation by forcing to exclude those too, changing the fix code into this:

get_filename_component(barename "${file}" NAME_WE)
    # HACK - the following are dynamic libs in Windows (no .lib) - these will be dll's only
    set(skip_dynamic_libs "hdStream" "usdObj" "usdShaders" "usdDancingCubesExample" "usdRecursivePayloadsExample" "hdStorm")
    list(FIND skip_dynamic_libs ${barename} _index)
    if(NOT EXISTS "${file}" AND NOT ((${_index} GREATER -1) AND WIN32))

Note that it now also discards those two additional example libs. This issue is fixed in the latest USD commits however the original workaround then still applies.


Compiling still fails, see: Autodesk/maya-usd#50

Compiling now works fine on Windows with the latest maya-usd/refactoring_sandbox without any local code changes.

@BigRoy
Copy link
Author

BigRoy commented Oct 30, 2019

With the latest maya-usd/refactoring_sandbox which also uses a much more up-to-date version USD you should be able to compile everything without manual fixes. 🚀

You might still need to have jinja2 installed in the Python you're using to compile USD to ensure it correctly creates the required schemas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment