Skip to content

Commit a88549a

Browse files
superfuncpixar-oss
authored andcommitted
[Usd] Make python optional in USD.
(Internal change: 1777404)
1 parent fdf6743 commit a88549a

File tree

4 files changed

+67
-25
lines changed

4 files changed

+67
-25
lines changed

BUILDING.md

+11
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@ USD contains several optional components that are enabled by default
7878
but may be disabled when invoking cmake. Disabling these components
7979
removes the need for their dependencies when building USD.
8080

81+
##### Python
82+
83+
Python support in USD refers to:
84+
- [The Usd Toolset](https://graphics.pixar.com/usd/docs/USD-Toolset.html)
85+
- [Third Party Plugins](https://graphics.pixar.com/usd/docs/USD-3rd-Party-Plugins.html)
86+
- Python language bindings for the USD C++ API
87+
- Unit tests using Python
88+
89+
Support for Python can optionally be disabled by specifying the cmake flag
90+
```PXR_ENABLE_PYTHON_SUPPORT=FALSE```.
91+
8192
##### Documentation
8293

8394
Doxygen documentation can optionally be generated by specifying the cmake flag

README.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -50,26 +50,26 @@ have the following dependencies.
5050

5151
| Name | Version |
5252
| ---- | --------- |
53-
| C++ compiler | GCC 4.8, Clang 3.5, MSVC 14.0(VS 2015) |
54-
| C compiler | GCC 4.8, Clang 3.5, MSVC 14.0(VS 2015) |
55-
| [CMake](https://cmake.org/documentation/) | 2.8.8 (Linux/OS X), 3.1.1 (Windows) |
56-
| [Python](https://python.org) | 2.7.5 |
57-
| [Boost](https://boost.org) | 1.55 (Linux), 1.61.0 (OS X/Windows) |
58-
| [Intel TBB](https://www.threadingbuildingblocks.org/) | 4.3.1 |
53+
| C++ compiler | GCC 4.8, Clang 3.5, MSVC 14.0(VS 2015) | |
54+
| C compiler | GCC 4.8, Clang 3.5, MSVC 14.0(VS 2015) | |
55+
| [CMake](https://cmake.org/documentation/) | 2.8.8 (Linux/OS X), 3.1.1 (Windows) | |
56+
| [Python](https://python.org) | 2.7.5 | x |
57+
| [Boost](https://boost.org) | 1.55 (Linux), 1.61.0 (OS X/Windows) | |
58+
| [Intel TBB](https://www.threadingbuildingblocks.org/) | 4.3.1 | |
5959

6060
The Imaging and USD Imaging components (located in pxr/imaging and pxr/usdImaging
6161
respectively) have the following additional dependencies. These components can
6262
be disabled at build-time, for further details see [Advanced Build Configuration](BUILDING.md).
6363

6464
| Name | Version | Optional |
6565
| ---- | --------- | ---------- |
66-
| [OpenSubdiv](https://github.com/PixarAnimationStudios/OpenSubdiv) | 3.0.5 (Linux/OS X), 3.2.0 (Windows) | |
67-
| [GLEW](http://glew.sourceforge.net/) | 1.10.0 | |
68-
| [OpenEXR](http://www.openexr.com) | 2.2.0 | |
69-
| [OpenImageIO](https://sites.google.com/site/openimageio/home) | 1.5.11 | |
70-
| [Ptex](http://ptex.us/) | 2.0.30 | Y |
71-
| [PySide](http://wiki.qt.io/PySide) | 1.2.2 | |
72-
| [PyOpenGL](https://pypi.python.org/pypi/PyOpenGL/3.1.0) | 3.1.0 | |
66+
| [OpenSubdiv](https://github.com/PixarAnimationStudios/OpenSubdiv) | 3.0.5 (Linux/OS X), 3.2.0 (Windows) | |
67+
| [GLEW](http://glew.sourceforge.net/) | 1.10.0 | |
68+
| [OpenEXR](http://www.openexr.com) | 2.2.0 | |
69+
| [OpenImageIO](https://sites.google.com/site/openimageio/home) | 1.5.11 | |
70+
| [Ptex](http://ptex.us/) | 2.0.30 | x |
71+
| [PySide](http://wiki.qt.io/PySide) | 1.2.2 | |
72+
| [PyOpenGL](https://pypi.python.org/pypi/PyOpenGL/3.1.0) | 3.1.0 | |
7373

7474
Getting and Building the Code
7575
-----------------------------

build_scripts/build_usd.py

+42-11
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,11 @@ def InstallUSD(context):
758758
with CurrentWorkingDirectory(context.usdSrcDir):
759759
extraArgs = []
760760

761+
if context.buildPython:
762+
extraArgs.append('-DPXR_ENABLE_PYTHON_SUPPORT=ON')
763+
else:
764+
extraArgs.append('-DPXR_ENABLE_PYTHON_SUPPORT=OFF')
765+
761766
if context.buildShared:
762767
extraArgs.append('-DBUILD_SHARED_LIBS=ON')
763768
elif context.buildMonolithic:
@@ -907,6 +912,12 @@ def InstallUSD(context):
907912
default=False, help="Build documentation")
908913
subgroup.add_argument("--no-docs", dest="build_docs", action="store_false",
909914
help="Do not build documentation (default)")
915+
subgroup = group.add_mutually_exclusive_group()
916+
subgroup.add_argument("--python", dest="build_python", action="store_true",
917+
default=True, help="Build python based components "
918+
"(default)")
919+
subgroup.add_argument("--no-python", dest="build_python", action="store_false",
920+
help="Do not build python based components")
910921

911922
(NO_IMAGING, IMAGING, USD_IMAGING) = (0, 1, 2)
912923

@@ -1021,6 +1032,7 @@ def __init__(self, args):
10211032
# Optional components
10221033
self.buildTests = args.build_tests
10231034
self.buildDocs = args.build_docs
1035+
self.buildPython = args.build_python
10241036

10251037
# - Imaging
10261038
self.buildImaging = (args.build_imaging == IMAGING or
@@ -1053,7 +1065,7 @@ def __init__(self, args):
10531065
self.buildHoudini = args.build_houdini
10541066
self.houdiniLocation = (os.path.abspath(args.houdini_location)
10551067
if args.houdini_location else None)
1056-
1068+
10571069
def MustBuildDependency(self, dep):
10581070
return self.forceBuildAll or dep.name.lower() in self.forceBuild
10591071

@@ -1092,7 +1104,7 @@ def MustBuildDependency(self, dep):
10921104
requiredDependencies += [JPEG, TIFF, PNG, OPENEXR, GLEW,
10931105
OPENIMAGEIO, OPENSUBDIV]
10941106

1095-
if context.buildUsdImaging:
1107+
if context.buildUsdImaging and context.buildPython:
10961108
requiredDependencies += [PYOPENGL, PYSIDE]
10971109

10981110
# Assume zlib already exists on Linux platforms and don't build
@@ -1102,6 +1114,21 @@ def MustBuildDependency(self, dep):
11021114
if Linux():
11031115
requiredDependencies.remove(ZLIB)
11041116

1117+
1118+
# Error out if we try to build any third party plugins with python disabled.
1119+
if not context.buildPython:
1120+
pythonPluginErrorMsg = (
1121+
"%s plugin cannot be built when python support is disabled")
1122+
if context.buildMaya:
1123+
PrintError(pythonPluginErrorMsg % "Maya")
1124+
sys.exit(1)
1125+
if context.buildHoudini:
1126+
PrintError(pythonPluginErrorMsg % "Houdini")
1127+
sys.exit(1)
1128+
if context.buildKatana:
1129+
PrintError(pythonPluginErrorMsg % "Katana")
1130+
sys.exit(1)
1131+
11051132
# Error out if we're building the Maya plugin and have enabled Ptex support
11061133
# in imaging. Maya includes its own copy of Ptex, which we believe is
11071134
# version 2.0.41. We would need to build imaging against this version to
@@ -1182,6 +1209,7 @@ def MustBuildDependency(self, dep):
11821209
Imaging {buildImaging}
11831210
Ptex support: {enablePtex}
11841211
UsdImaging {buildUsdImaging}
1212+
Python support {buildPython}
11851213
Documentation {buildDocs}
11861214
Tests {buildTests}
11871215
Alembic Plugin {buildAlembic}
@@ -1205,6 +1233,7 @@ def MustBuildDependency(self, dep):
12051233
buildImaging=("On" if context.buildImaging else "Off"),
12061234
enablePtex=("On" if context.enablePtex else "Off"),
12071235
buildUsdImaging=("On" if context.buildUsdImaging else "Off"),
1236+
buildPython=("On" if context.buildPython else "Off"),
12081237
buildDocs=("On" if context.buildDocs else "Off"),
12091238
buildTests=("On" if context.buildTests else "Off"),
12101239
buildAlembic=("On" if context.buildAlembic else "Off"),
@@ -1273,16 +1302,18 @@ def MustBuildDependency(self, dep):
12731302
])
12741303

12751304
Print("""
1276-
Success! To use USD, please ensure that you have:
1277-
The following in your PYTHONPATH environment variable:
1278-
{requiredInPythonPath}
1279-
1280-
The following in your PATH environment variable:
1305+
Success! To use USD, please ensure that you have:""")
1306+
1307+
if context.buildPython:
1308+
Print("""
1309+
The following in your PYTHONPATH environment variable:
1310+
{requiredInPythonPath}""".format(
1311+
requiredInPythonPath="\n ".join(sorted(requiredInPythonPath))))
1312+
1313+
Print("""
1314+
The following in your PATH environment variable:
12811315
{requiredInPath}
1282-
"""
1283-
.format(
1284-
requiredInPythonPath="\n ".join(sorted(requiredInPythonPath)),
1285-
requiredInPath="\n ".join(sorted(requiredInPath))))
1316+
""".format(requiredInPath="\n ".join(sorted(requiredInPath))))
12861317

12871318
if context.buildMaya:
12881319
Print("See documentation at http://openusd.org/docs/Maya-USD-Plugins.html "

cmake/defaults/Options.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ option(PXR_BUILD_MAYA_PLUGIN "Build usd maya plugin" OFF)
3232
option(PXR_BUILD_ALEMBIC_PLUGIN "Build the Alembic plugin for USD" OFF)
3333
option(PXR_BUILD_HOUDINI_PLUGIN "Build the Houdini plugin for USD" OFF)
3434
option(PXR_BUILD_DOCUMENTATION "Generate doxygen documentation" OFF)
35+
option(PXR_ENABLE_PYTHON_SUPPORT "Enable Python based components for USD" ON)
3536
option(PXR_ENABLE_MULTIVERSE_SUPPORT "Enable Multiverse backend in the Alembic plugin for USD" OFF)
3637
option(PXR_ENABLE_HDF5_SUPPORT "Enable HDF5 backend in the Alembic plugin for USD" ON)
3738
option(PXR_ENABLE_PTEX_SUPPORT "Enable Ptex support" ON)
@@ -101,4 +102,3 @@ set(PXR_MONOLITHIC_IMPORT ""
101102
"Path to cmake file that imports a usd_ms target"
102103
)
103104

104-
set(PXR_ENABLE_PYTHON_SUPPORT "ON")

0 commit comments

Comments
 (0)