This is in no way meant to be a “standard, do it this way” kind of a solution, but just one way of making it happen. I don’t like how homebrew and alike plug themselves into default locations and potentially taint your environment, so I default to Python-centric virtual environment handlers like miniconda. With the announcement that usdview now supports Metal, I wanted to have a go at it: so this is how you can compile Pixar’s USD (and usdview) without using Rosetta and run natively on M1 chips.
Prerequisites
Xcode – must be installed and run at least one time to install the platform support. You may be able to just use the command line tools (run xcode-select –install ) but I recommend just going ahead and spending 4 hours downloading and installing Xcode.
Miniconda3 Apple M1 – installer can be downloaded at https://docs.conda.io/en/latest/miniconda.html
I like using /opt for these environments, but it’s up to you where you want yours. Install the M1 version of miniconda, activate it (run path_to_conda/bin/activate), then install conda-forge:
conda config --add channels conda-forge conda config --set channel_priority strict
Install cmake, numpy, pyside6 and pyopengl:
conda install cmake numpy pip install pyside6 PyOpenGL
Download and prepare USD for compiling
Get the ‘dev’ branch if 22.05 isn’t out yet, otherwise ‘release’. This is because 22.05 is the first one to include Metal support for Hydra.
USD doesn’t support PySide6 (and PySide2 won’t work with M1) so you’ll need to trick it into compiling:
# go to your conda bin folder cd /opt/conda/bin ln -s pyside6-uic pyside2-uic cd /opt/conda/lib/python3.*/site-packages ln -s PySide6 PySide2
Patch the build_scripts/build_usd.py file around line 427 and add the one line with DPXR_PY_UNDEFINED_DYNAMIC_LOOKUP:
with CurrentWorkingDirectory(buildDir): Run('cmake ' '-DCMAKE_INSTALL_PREFIX="{instDir}" ' '-DCMAKE_PREFIX_PATH="{depsInstDir}" ' '-DCMAKE_BUILD_TYPE={config} ' '-DPXR_PY_UNDEFINED_DYNAMIC_LOOKUP=ON ' '{osx_rpath} ' '{generator} '
Patching usdview
As one would guess, the PySide2 symlink is just a band-aid – stuff won’t just run like that, especially when OpenGL support is one of the biggest changes in PySide6.
You’ll need to patch two files: qt.py and stageView.py. These might get outdated as soon as an official release comes out, so I’ll briefly explain the changes as well.
Apply the two patches inside the folder you have USD checked out in like this (once for each patch):
patch -p1 <path_to_patch.patch
Run the compile script (again, I just like to put the USD build under /opt/USD but choose wherever you like):
python build_scripts/build_usd.py --build-args TBB,"arch=arm64" --python /opt/USD
Test it
Things may have changed, maybe this method no longer works, for any of a million reasons, but even if you don’t get any errors it’s good to test the newly installed USD with a sample set in a fresh terminal. Pixar’s Kitchen set is a great example: https://graphics.pixar.com/usd/release/dl_kitchen_set.html
# activate your conda environment source /opt/conda/bin/activate # include USD in your env export PYTHONPATH=/opt/USD/lib/python export PATH=/opt/USD/bin:$PATH # test! usdview path_to_kitchen_set.usd
Clean up PySide2 links
Now that everything’s compiled, you can remove the symlinks for PySide2:
# go to your conda bin folder cd /opt/conda/bin rm -f pyside2-uic cd /opt/conda/lib/python3.*/site-packages rm -f PySide2
Leave a Reply