Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: remove distutils dependency #3417

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pxr/usd/bin/usdedit/usdedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ def _findEditorTools(usdFileName, readOnly):
sys.exit("Error: Couldn't find 'usdcat'. Expected it to be in PATH.")

# Ensure we have a suitable editor available
from distutils.spawn import find_executable
import shutil
editorCmd = (os.getenv("USD_EDITOR") or
os.getenv("EDITOR") or
find_executable("emacs") or
find_executable("vim") or
find_executable("notepad"))
shutil.which("emacs") or
shutil.which("vim") or
shutil.which("notepad"))

if not editorCmd:
sys.exit("Error: Couldn't find a suitable text editor to use. Expected "
Expand Down
8 changes: 4 additions & 4 deletions pxr/usd/usdUtils/toolPaths.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os
import platform
import sys
from distutils.spawn import find_executable
import shutil

def FindUsdBinary(name):
"""Returns the full path to the named executable if it can be found, or
Expand All @@ -20,18 +20,18 @@ def FindUsdBinary(name):
"""

# First search PATH
binpath = find_executable(name)
binpath = shutil.which(name)
if binpath:
return binpath

# Then look relative to the current executable
binpath = find_executable(name,
binpath = shutil.which(name,
path=os.path.abspath(os.path.dirname(sys.argv[0])))
if binpath:
return binpath

if platform.system() == 'Windows':
# find_executable under Windows only returns *.EXE files so we need to
# shutil.which under Windows only returns *.EXE files so we need to
# traverse the tool path.
path = os.environ.get('PATH', '').split(os.pathsep)
for base in [os.path.join(p, name) for p in path]:
Expand Down
22 changes: 19 additions & 3 deletions pxr/usd/usdUtils/updateSchemaWithSdrNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,23 @@ def _SetSchemaUserDocFields(spec, doc):
# (example: https://openusd.org/release/user_guides/schemas/index.html)
spec.customData[UserDocConstants.USERDOC_FULL] = doc


def StringToBool(val):
"""Convert a string representation of truth to True or False.

True values are 'y', 'yes', 't', 'true', 'on', and '1';
False values are 'n', 'no', 'f', 'false', 'off', and '0'.

Raises ValueError if `val` is anything else.
"""
val = val.lower()
if val in ('y', 'yes', 't', 'true', 'on', '1'):
return True
elif val in ('n', 'no', 'f', 'false', 'off', '0'):
return False
else:
raise ValueError(f"Invalid truth value: {val}")

def UpdateSchemaWithSdrNode(schemaLayer, sdrNode, renderContext="",
overrideIdentifier=""):
"""
Expand Down Expand Up @@ -271,7 +288,6 @@ def UpdateSchemaWithSdrNode(schemaLayer, sdrNode, renderContext="",
SdfPropertySpec's CONNECTABILITY.
"""

import distutils.util
import os

# Early exit on invalid parameters
Expand Down Expand Up @@ -350,7 +366,7 @@ def UpdateSchemaWithSdrNode(schemaLayer, sdrNode, renderContext="",
if SchemaDefiningKeys.PROVIDES_USD_SHADE_CONNECTABLE_API_BEHAVIOR in \
sdrNodeMetadata:
providesUsdShadeConnectableAPIBehavior = \
distutils.util.strtobool(sdrNodeMetadata[SchemaDefiningKeys. \
StringToBool(sdrNodeMetadata[SchemaDefiningKeys. \
PROVIDES_USD_SHADE_CONNECTABLE_API_BEHAVIOR])

apiSchemasForAttrPruning = None
Expand Down Expand Up @@ -460,7 +476,7 @@ def UpdateSchemaWithSdrNode(schemaLayer, sdrNode, renderContext="",
# Since we want to assign the types for these to bool and
# because in python boolean type is a subset of int, we need to
# do following instead of assign the propValue directly.
propValue = distutils.util.strtobool(sdrNodeMetadata[propKey])
propValue = StringToBool(sdrNodeMetadata[propKey])
extraPlugInfo[propKey] = bool(propValue)

primSpecCustomData['extraPlugInfo'] = extraPlugInfo
Expand Down