USD in the Labs

Building OpenUSD in the Labs

The first thing we need is to setup our version of python to allow us to have a correct environment to build USD. We will use pyenv to manage our python versions.

If we are doing a lot of python development we maya also need to use pyenv to create a virtual environment for our project, in this case I will just build directly for a suitable version.

At present the version of python that USD requires is Python >=3.6, <3.11 so we need a version in this range. For simplicity we can use Python 3.9 which is the same as maya, and also setup for the labs via the install_python.sh script.

install_python.sh 

This will download and setup pyenv then set the default python to 3.9.7. If you need other versions you can set the pyenv local to the correct version.

pyenv global 3.9.7

pip install pyside2 pyopengl

Downloading USD

The first thing we need to do is to download the USD source code. We can do this by cloning the USD repository from github.

cd ~
git clone https://github.com/PixarAnimationStudios/OpenUSD

Once this is installed we have to decide which elements of USD we wish to install. If you just want simple quick build you can use the default choices. If you need more features this will take longer.

Installation

As the lab machines are setup to build software using different tools such as vcpkg and cmake by default we need to unset some of these features before we start building our version of USD as they may clash.

The first thing we need to do is unset the CMAKE_TOOLCHAIN_FILE environment variable, this is only active in the current shell and will be re-set next time you open a shell.

unset CMAKE_TOOLCHAIN_FILE

Build Options

We can see all the possible build options by running the following command

python OpenUSD/build_scripts/build_usd.py --help

There are a lot of options here, but the most important ones are the ones that allow us to build the components we need.

We can use either flags in the format –option or –no-option to enable or disable a feature. (Note for some reason blosc and opencolorio are not working so we can’t enable it unless we edit the source files and fix the compiler bus)


To build all of the features we can use the following command 

```bash
python OpenUSD/build_scripts/build_usd.py --openimageio --embree --prman   --prman-location /opt/pixar/RenderManProServer-26.1/ --alembic   --openvdb --ptex   ~/USD/

With ~/USD being the location we want to install USD, this will take a long time to build (around 30 minutes) so you may want to get a coffee.

Building with settings:
  USD source directory          /home/jmacey/OpenUSD
  USD install directory         /home/jmacey/USD
  3rd-party source directory    /home/jmacey/USD/src
  3rd-party install directory   /home/jmacey/USD
  Build directory               /home/jmacey/USD/build
  CMake generator               Default
  CMake toolset                 Default
  Downloader                    curl

  Building                      Shared libraries
    Variant                     Release
    Target
    Imaging                     On
      Ptex support:             On
      OpenVDB support:          On
      OpenImageIO support:      On
      OpenColorIO support:      Off
      PRMan support:            On
    UsdImaging                  On
      usdview:                  On
    MaterialX support           On
    Python support              On
      Python Debug:             Off
      Python docs:              Off
    Documentation               Off
    Tests                       Off
      Mayapy Tests:             Off
      AnimX Tests:              Off
    Examples                    On
    Tutorials                   On
    Tools                       On
    Alembic Plugin              On
      HDF5 support:             Off
    Draco Plugin                Off

  Dependencies                  None
STATUS: Installing USD...

Success! To use USD, please ensure that you have:

Once this is done we can add the following to our .bashrc file to allow us to use USD in the labs.

export USD_ROOT=~/USD
export PATH=$USD_ROOT/bin:$PATH
export PYTHONPATH=$USD_ROOT/lib/python:$PYTHONPATH

we can then source our .bashrc file to make the changes active and we should now have a selection of usd tools available to us.

Previous

Related