Skip to content

Commit 304f1da

Browse files
SConstruct : Fix linking with USD 25.05
In this version, the Python bindings use Pixar's fork of Boost Python unconditionally, so we need to link to that instead.
1 parent aff406b commit 304f1da

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

SConstruct

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,46 +1167,47 @@ def pythonVersion( pythonEnv ) :
11671167
universal_newlines = True
11681168
).strip()
11691169

1170-
pythonEnv = env.Clone()
1170+
basePythonEnv = env.Clone()
11711171

11721172
# decide where python is
1173-
if pythonEnv["PYTHON"]=="" :
1173+
if basePythonEnv["PYTHON"]=="" :
11741174
if env["PLATFORM"] == "win32" :
11751175
sys.stderr.write( "ERROR : Python executable path must be set with PYTHON option.\n" )
11761176
Exit( 1 )
11771177
else:
1178-
pythonEnv["PYTHON"] = getPythonConfig( pythonEnv, "--exec-prefix" ) + "/bin/python"
1178+
basePythonEnv["PYTHON"] = getPythonConfig( basePythonEnv, "--exec-prefix" ) + "/bin/python"
11791179

11801180
# run it to determine version
1181-
pythonEnv["PYTHON_VERSION"] = pythonVersion( pythonEnv )
1181+
basePythonEnv["PYTHON_VERSION"] = pythonVersion( basePythonEnv )
11821182

11831183
# get the include path for python if we haven't been told it explicitly
11841184
# Windows does not have python-config so rely the user setting the appropriate options
11851185
if env["PLATFORM"] != "win32" :
1186-
if pythonEnv["PYTHON_INCLUDE_PATH"]=="" :
1187-
pythonEnv["PYTHON_INCLUDE_FLAGS"] = getPythonConfig( pythonEnv, "--includes" ).split()
1186+
if basePythonEnv["PYTHON_INCLUDE_PATH"]=="" :
1187+
basePythonEnv["PYTHON_INCLUDE_FLAGS"] = getPythonConfig( basePythonEnv, "--includes" ).split()
11881188
else :
1189-
pythonEnv["PYTHON_INCLUDE_FLAGS"] = [ systemIncludeArgument, "$PYTHON_INCLUDE_PATH" ]
1189+
basePythonEnv["PYTHON_INCLUDE_FLAGS"] = [ systemIncludeArgument, "$PYTHON_INCLUDE_PATH" ]
11901190

1191-
pythonEnv.Append( CXXFLAGS = "$PYTHON_INCLUDE_FLAGS" )
1191+
basePythonEnv.Append( CXXFLAGS = "$PYTHON_INCLUDE_FLAGS" )
11921192

11931193
if env["PLATFORM"] == "posix" :
11941194
## We really want to not have the -Wno-strict-aliasing flag, but it's necessary to stop boost
11951195
# python warnings that don't seem to be prevented by including boost via -isystem even. Better to
11961196
# be able to have -Werror but be missing one warning than to have no -Werror.
11971197
## \todo This is probably only necessary for specific gcc versions where -isystem doesn't
11981198
# fully work. Reenable when we encounter versions that work correctly.
1199-
pythonEnv.Append( CXXFLAGS = [ "-Wno-strict-aliasing" ] )
1199+
basePythonEnv.Append( CXXFLAGS = [ "-Wno-strict-aliasing" ] )
12001200

12011201
# get the python link flags
1202-
if pythonEnv["PYTHON_LINK_FLAGS"]=="" :
1203-
pythonEnv["PYTHON_LINK_FLAGS"] = getPythonConfig( pythonEnv, "--ldflags" )
1204-
pythonEnv["PYTHON_LINK_FLAGS"] = pythonEnv["PYTHON_LINK_FLAGS"].replace( "Python.framework/Versions/" + pythonEnv["PYTHON_VERSION"] + "/Python", "" )
1202+
if basePythonEnv["PYTHON_LINK_FLAGS"]=="" :
1203+
basePythonEnv["PYTHON_LINK_FLAGS"] = getPythonConfig( basePythonEnv, "--ldflags" )
1204+
basePythonEnv["PYTHON_LINK_FLAGS"] = basePythonEnv["PYTHON_LINK_FLAGS"].replace( "Python.framework/Versions/" + basePythonEnv["PYTHON_VERSION"] + "/Python", "" )
12051205

1206-
pythonEnv.Append( SHLINKFLAGS = pythonEnv["PYTHON_LINK_FLAGS"].split() )
1206+
basePythonEnv.Append( SHLINKFLAGS = basePythonEnv["PYTHON_LINK_FLAGS"].split() )
12071207
else :
1208-
pythonEnv["PYTHON_INCLUDE_FLAGS"] = ""
1208+
basePythonEnv["PYTHON_INCLUDE_FLAGS"] = ""
12091209

1210+
pythonEnv = basePythonEnv.Clone()
12101211
pythonEnv.Append( CPPFLAGS = "-DBOOST_PYTHON_MAX_ARITY=20" )
12111212

12121213
# if BOOST_PYTHON_LIB_SUFFIX is provided, use it
@@ -2066,9 +2067,9 @@ usdEnvSets = {
20662067
"IECORE_NAME" : "IECoreUSD"
20672068
}
20682069

2069-
# We are deliberately cloning from `pythonEnv` rather than
2070+
# We are deliberately cloning from `basePythonEnv` rather than
20702071
# `env` because USD itself has dependencies on Python.
2071-
usdEnv = pythonEnv.Clone( **usdEnvSets )
2072+
usdEnv = basePythonEnv.Clone( **usdEnvSets )
20722073

20732074
if usdEnv["WITH_USD_MONOLITHIC"] :
20742075
usdLibs = [ "usd_ms" ]
@@ -2097,10 +2098,20 @@ else :
20972098
if usdEnv["USD_LIB_PREFIX"] :
20982099
usdLibs = [ usdEnv["USD_LIB_PREFIX"] + x for x in usdLibs ]
20992100

2101+
usdPythonLib = env.subst( "boost_python$BOOST_PYTHON_LIB_SUFFIX" )
2102+
pxrVersionHeader = env.FindFile( "pxr/pxr.h", dependencyIncludes )
2103+
if pxrVersionHeader is not None and "#define PXR_USE_INTERNAL_BOOST_PYTHON\n" in open( str( pxrVersionHeader ) ) :
2104+
usdPythonLib = usdEnv["USD_LIB_PREFIX"] + "python"
2105+
2106+
usdLibs.append( usdPythonLib )
2107+
21002108
usdEnvAppends = {
21012109
"CXXFLAGS" : [
21022110
"-Wno-deprecated" if env["PLATFORM"] != "win32" else "",
21032111
"/Zc:inline-" if env["PLATFORM"] == "win32" else "",
2112+
# This warning is already disabled generally for release builds,
2113+
# but also requires disabling for debug builds with USD.
2114+
"/wd4702" if env["PLATFORM"] == "win32" else "",
21042115
"-DIECoreUSD_EXPORTS",
21052116
systemIncludeArgument, "$USD_INCLUDE_PATH",
21062117
systemIncludeArgument, "$PYTHON_INCLUDE_PATH",

0 commit comments

Comments
 (0)