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

better detection of python lib / include dirs in build_usd.py #1692

Merged
Merged
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
34 changes: 26 additions & 8 deletions build_scripts/build_usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,20 +226,38 @@ def _GetPythonLibraryFilename(context):
pythonLibPath = os.path.join(pythonBaseDir, "lib",
_GetPythonLibraryFilename(context))
else:
pythonIncludeDir = sysconfig.get_config_var("INCLUDEPY")
if Windows():
pythonIncludeDir = sysconfig.get_path("include")
if not pythonIncludeDir or not os.path.isdir(pythonIncludeDir):
# as a backup, and for legacy reasons - not preferred because
# it may be baked at build time
pythonIncludeDir = sysconfig.get_config_var("INCLUDEPY")

# if in a venv, installed_base will be the "original" python,
# which is where the libs are ("base" will be the venv dir)
pythonBaseDir = sysconfig.get_config_var("installed_base")
if not pythonBaseDir or not os.path.isdir(pythonBaseDir):
# for python-2.7
pythonBaseDir = sysconfig.get_config_var("base")

if Windows():
pythonLibPath = os.path.join(pythonBaseDir, "libs",
_GetPythonLibraryFilename(context))
elif Linux():
pythonLibDir = sysconfig.get_config_var("LIBDIR")
pythonMultiarchSubdir = sysconfig.get_config_var("multiarchsubdir")
if pythonMultiarchSubdir:
pythonLibDir = pythonLibDir + pythonMultiarchSubdir
pythonLibPath = os.path.join(pythonLibDir,
_GetPythonLibraryFilename(context))
# Try multiple ways to get the python lib dir
for pythonLibDir in (sysconfig.get_config_var("LIBDIR"),
os.path.join(pythonBaseDir, "lib")):
if pythonMultiarchSubdir:
pythonLibPath = \
os.path.join(pythonLibDir + pythonMultiarchSubdir,
_GetPythonLibraryFilename(context))
if os.path.isfile(pythonLibPath):
break
pythonLibPath = os.path.join(pythonLibDir,
_GetPythonLibraryFilename(context))
if os.path.isfile(pythonLibPath):
break
elif MacOS():
pythonBaseDir = sysconfig.get_config_var("base")
pythonLibPath = os.path.join(pythonBaseDir, "lib",
_GetPythonLibraryFilename(context))
else:
Expand Down