Skip to content

Commit ab5c7b0

Browse files
committed
SCons: Python 3 compatibility
1 parent 3c7da2b commit ab5c7b0

File tree

2 files changed

+61
-59
lines changed

2 files changed

+61
-59
lines changed

build/SConscript.configure

Lines changed: 59 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import re, multiprocessing
23

34
Import('sys', 'os', 'SCons', 'resources')
@@ -20,14 +21,14 @@ if parallelize == True:
2021
SetOption('num_jobs', multiprocessing.cpu_count())
2122

2223
if not os.path.exists(configFile):
23-
print '\nA configuration file must be selected! Have a look at http://www.mitsuba-renderer.org/docs.html'
24+
print('\nA configuration file must be selected! Have a look at http://www.mitsuba-renderer.org/docs.html')
2425
Exit(1)
2526

2627
needsBuildDependencies = (sys.platform == 'win32' or sys.platform == 'darwin')
2728

2829
if needsBuildDependencies and not os.path.exists(GetBuildPath('#dependencies')):
29-
print '\nThe required build dependency files are missing. Please see the documentation'
30-
print 'at http://www.mitsuba-renderer.org/docs.html for details on how to get them.\n'
30+
print('\nThe required build dependency files are missing. Please see the documentation')
31+
print('at http://www.mitsuba-renderer.org/docs.html for details on how to get them.\n')
3132
Exit(1)
3233

3334
python_versions = ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4", "3.5", "3.6", "3.7"]
@@ -94,11 +95,11 @@ vars.Add('INTEL_COMPILER', 'Should the Intel C++ compiler be used?')
9495

9596
try:
9697
env = Environment(options=vars, ENV = os.environ, tools=['default', 'qt5'], toolpath=['#data/scons'])
97-
print 'Checking for Qt 5.x... yes'
98+
print('Checking for Qt 5.x... yes')
9899
hasQt = True
99100
except Exception:
100101
env = Environment(options=vars, ENV = os.environ, tools=['default'], toolpath=['#data/scons'])
101-
print 'Unable to detect a Qt installation -- not building the GUI!'
102+
print('Unable to detect a Qt installation -- not building the GUI!')
102103
hasQt = False
103104

104105
hasCollada=True
@@ -108,19 +109,19 @@ env.Append(CPPPATH=env['BASEINCLUDE'])
108109
env.Append(CPPFLAGS=[])
109110
env.Append(LIBPATH=[])
110111
env.Append(LIBS=env['BASELIB'])
111-
if env.has_key('BOOSTINCLUDE'):
112+
if 'BOOSTINCLUDE' in env:
112113
env.Prepend(CPPPATH=env['BOOSTINCLUDE'])
113-
if env.has_key('BOOSTLIBDIR'):
114+
if 'BOOSTLIBDIR' in env:
114115
env.Prepend(LIBPATH=env['BOOSTLIBDIR'])
115-
if env.has_key('BOOSTLIB'):
116+
if 'BOOSTLIB' in env:
116117
env.Prepend(LIBS=env['BOOSTLIB'])
117-
if env.has_key('BASELIBDIR'):
118+
if 'BASELIBDIR' in env:
118119
env.Append(LIBPATH=env['BASELIBDIR'])
119-
if env.has_key('OEXRINCLUDE'):
120+
if 'OEXRINCLUDE' in env:
120121
env.Prepend(CPPPATH=env['OEXRINCLUDE'])
121-
if env.has_key('OEXRLIBDIR'):
122+
if 'OEXRLIBDIR' in env:
122123
env.Prepend(LIBPATH=env['OEXRLIBDIR'])
123-
if env.has_key('EIGENINCLUDE'):
124+
if 'EIGENINCLUDE' in env:
124125
env.Prepend(CPPPATH=env['EIGENINCLUDE'])
125126

126127
env.Decider('MD5-timestamp')
@@ -140,64 +141,64 @@ libPathPrevious = SCons.Util.semi_deepcopy(env['LIBPATH'])
140141
cppFlagsPrevious = SCons.Util.semi_deepcopy(env['CPPFLAGS'])
141142
cxxFlagsPrevious = SCons.Util.semi_deepcopy(env['CXXFLAGS'])
142143

143-
if env.has_key('PNGINCLUDE'):
144+
if 'PNGINCLUDE' in env:
144145
env.Prepend(CPPPATH=env['PNGINCLUDE'])
145-
if env.has_key('PNGLIBDIR'):
146+
if 'PNGLIBDIR' in env:
146147
env.Prepend(LIBPATH=env['PNGLIBDIR'])
147-
if env.has_key('JPEGINCLUDE'):
148+
if 'JPEGINCLUDE' in env:
148149
env.Prepend(CPPPATH=env['JPEGINCLUDE'])
149-
if env.has_key('JPEGLIBDIR'):
150+
if 'JPEGLIBDIR' in env:
150151
env.Prepend(LIBPATH=env['JPEGLIBDIR'])
151-
if env.has_key('OEXRFLAGS'):
152+
if 'OEXRFLAGS' in env:
152153
env.Prepend(CPPFLAGS=env['OEXRFLAGS'])
153-
if env.has_key('OEXRINCLUDE'):
154+
if 'OEXRINCLUDE' in env:
154155
env.Prepend(CPPPATH=env['OEXRINCLUDE'])
155-
if env.has_key('OEXRLIBDIR'):
156+
if 'OEXRLIBDIR' in env:
156157
env.Prepend(LIBPATH=env['OEXRLIBDIR'])
157-
if env.has_key('XERCESINCLUDE'):
158+
if 'XERCESINCLUDE' in env:
158159
env.Prepend(CPPPATH=env['XERCESINCLUDE'])
159-
if env.has_key('XERCESLIBDIR'):
160+
if 'XERCESLIBDIR' in env:
160161
env.Prepend(LIBPATH=env['XERCESLIBDIR'])
161-
if env.has_key('GLINCLUDE'):
162+
if 'GLINCLUDE' in env:
162163
env.Prepend(CPPPATH=env['GLINCLUDE'])
163-
if env.has_key('GLFLAGS'):
164+
if 'GLFLAGS' in env:
164165
env.Prepend(CPPFLAGS=env['GLFLAGS'])
165-
if env.has_key('COLLADAINCLUDE'):
166+
if 'COLLADAINCLUDE' in env:
166167
env.Prepend(CPPPATH=env['COLLADAINCLUDE'])
167-
if env.has_key('COLLADALIBDIR'):
168+
if 'COLLADALIBDIR' in env:
168169
env.Prepend(LIBPATH=env['COLLADALIBDIR'])
169-
if env.has_key('FFTWINCLUDE'):
170+
if 'FFTWINCLUDE' in env:
170171
env.Prepend(CPPPATH=env['FFTWINCLUDE'])
171-
if env.has_key('FFTWLIBDIR'):
172+
if 'FFTWLIBDIR' in env:
172173
env.Prepend(LIBPATH=env['FFTWLIBDIR'])
173174

174175
if not conf.CheckCXX():
175-
print 'Could not compile a simple C++ fragment, verify that ' + \
176+
print('Could not compile a simple C++ fragment, verify that ' + \
176177
env['CXX'] + ' is installed! This could also mean that the ' + \
177178
'Boost libraries are missing. The file "config.log" should ' + \
178-
'contain more information.'
179+
'contain more information.')
179180
Exit(1)
180181
if not conf.CheckCHeader(['png.h']):
181-
print 'libpng is missing (install libpng12-dev for PNG I/O support)'
182+
print('libpng is missing (install libpng12-dev for PNG I/O support)')
182183
else:
183184
env.Append(CPPDEFINES = [['MTS_HAS_LIBPNG', 1]] )
184185

185186
if not conf.CheckCHeader(['stdio.h', 'jpeglib.h']):
186-
print 'libjpeg is missing (install libjpeg62-dev for JPEG I/O support)'
187+
print('libjpeg is missing (install libjpeg62-dev for JPEG I/O support)')
187188
else:
188189
env.Append(CPPDEFINES = [['MTS_HAS_LIBJPEG', 1]] )
189190

190191
if not conf.CheckCXXHeader('ImfRgba.h'):
191-
print 'OpenEXR is missing (install libopenexr-dev for OpenEXR I/O support)'
192+
print('OpenEXR is missing (install libopenexr-dev for OpenEXR I/O support)')
192193
else:
193194
env.Append(CPPDEFINES = [['MTS_HAS_OPENEXR', 1]] )
194195

195196
if not conf.CheckCXXHeader('xercesc/dom/DOMLSParser.hpp'):
196-
print 'Xerces-C++ 3.x must be installed (install libxerces-c-dev)!'
197+
print('Xerces-C++ 3.x must be installed (install libxerces-c-dev)!')
197198
Exit(1)
198199
if not conf.CheckCXXHeader('dae.h'):
199200
hasCollada = False
200-
print 'COLLADA DOM is missing: not building the COLLADA importer'
201+
print('COLLADA DOM is missing: not building the COLLADA importer')
201202

202203
hasBreakpad = '-DMTS_HAS_BREAKPAD' in env['CCFLAGS'] or 'MTS_HAS_BREAKPAD' in env['CXXFLAGS']
203204

@@ -211,54 +212,54 @@ for ver in python_versions:
211212
if conf.CheckCXXHeader('pyconfig.h'):
212213
hasPython += [ ver ]
213214
else:
214-
print 'Python ' + ver + ' is missing: not building wrappers'
215+
print('Python ' + ver + ' is missing: not building wrappers')
215216
env['CPPPATH'][:] = [ x for x in env['CPPPATH'] if x not in includePath ]
216217

217218
if not conf.CheckCXXHeader('boost/version.hpp'):
218-
print 'Boost is missing (install libboost-all-dev)!'
219+
print('Boost is missing (install libboost-all-dev)!')
219220
Exit(1)
220221
if not conf.TryCompile("#include <boost/version.hpp>\n#if BOOST_VERSION < 104400\n#error Boost is outdated!\n#endif", ".cpp"):
221-
print 'Boost is outdated (you will need version 1.44 or newer)!'
222+
print('Boost is outdated (you will need version 1.44 or newer)!')
222223
Exit(1)
223224
if not conf.CheckCXXHeader('Eigen/Core'):
224-
print 'Eigen 3.x is missing (install libeigen3-dev)!'
225+
print('Eigen 3.x is missing (install libeigen3-dev)!')
225226
Exit(1)
226227
if not conf.CheckCXXHeader('fftw3.h'):
227-
print 'FFTW3 not found (install for fast image convolution support)'
228+
print('FFTW3 not found (install for fast image convolution support)')
228229
else:
229230
env.Append(CPPDEFINES = [['MTS_HAS_FFTW', 1]] )
230231
if sys.platform == 'win32':
231232
if not (conf.CheckCHeader(['windows.h', 'GL/gl.h']) \
232233
and conf.CheckCHeader(['windows.h', 'GL/glu.h']) \
233234
and conf.CheckCHeader(['windows.h', 'GL/gl.h', 'GL/glext.h'])):
234-
print 'OpenGL headers are missing!'
235+
print('OpenGL headers are missing!')
235236
Exit(1)
236237
if not conf.CheckCHeader('GL/glew.h'):
237-
print 'GLEW headers are missing!'
238+
print('GLEW headers are missing!')
238239
Exit(1)
239240
elif sys.platform == 'linux2':
240241
if not (conf.CheckCHeader('GL/gl.h') and conf.CheckCHeader('GL/glu.h') and conf.CheckCHeader(['GL/gl.h', 'GL/glext.h'])):
241-
print 'OpenGL headers are missing!'
242+
print('OpenGL headers are missing!')
242243
Exit(1)
243244
if not conf.CheckCHeader('GL/glew.h'):
244-
print 'GLEW headers are missing (install libglewmx1.5-dev)!'
245+
print('GLEW headers are missing (install libglewmx1.5-dev)!')
245246
Exit(1)
246247
if not conf.CheckType('GLEWContext', '#include <GL/glew.h>'):
247-
print 'GLEW-MX must be present!'
248+
print('GLEW-MX must be present!')
248249
Exit(1)
249250
if not conf.TryCompile("#include <GL/glew.h>\n int i = GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV;", '.cpp'):
250-
print 'Your version of GLEW-MX seems to be outdated!'
251+
print('Your version of GLEW-MX seems to be outdated!')
251252
Exit(1)
252253
elif sys.platform == 'darwin':
253254
if not (conf.CheckCHeader('OpenGL/gl.h') and conf.CheckCHeader('OpenGL/glu.h') and conf.CheckCHeader(['OpenGL/gl.h', 'OpenGL/glext.h'])):
254-
print 'OpenGL headers are missing!'
255+
print('OpenGL headers are missing!')
255256
Exit(1)
256257
if not conf.CheckCHeader('OpenGL/glew.h'):
257-
print 'GLEW headers are missing!'
258+
print('GLEW headers are missing!')
258259
Exit(1)
259260
if sys.platform == 'linux2':
260261
if not (conf.CheckCHeader(['X11/Xlib.h', 'X11/extensions/xf86vmode.h'])):
261-
print 'X Video Mode selection library headers are missing! (Install libxxf86vm-dev)'
262+
print('X Video Mode selection library headers are missing! (Install libxxf86vm-dev)')
262263
Exit(1)
263264

264265
env.Replace(CPPPATH=cppPathPrevious)
@@ -273,10 +274,10 @@ for line in file:
273274
if line.startswith("#define MTS_VERSION "):
274275
MTS_VERSION = line[21:len(line)-2]
275276
if MTS_VERSION == "":
276-
print 'could not be determined!'
277+
print('could not be determined!')
277278
Exit(1)
278279
else:
279-
print MTS_VERSION
280+
print(MTS_VERSION)
280281
Export('MTS_VERSION')
281282

282283
if needsBuildDependencies:
@@ -293,14 +294,14 @@ if needsBuildDependencies:
293294
versionMismatch = True
294295

295296
if versionMismatch:
296-
print '\nThe dependency directory and your Mitsuba codebase have different version'
297-
print 'numbers! Your copy of Mitsuba has version %s, whereas the dependencies ' % MTS_VERSION
298-
print 'have version %s. Please bring them into sync, either by running\n' % depVersion
299-
print '$ hg update -r v%s\n' % depVersion
300-
print 'in the Mitsuba directory, or by running\n'
301-
print '$ cd dependencies'
302-
print '$ hg pull'
303-
print '$ hg update -r v%s\n' % MTS_VERSION
297+
print('\nThe dependency directory and your Mitsuba codebase have different version')
298+
print('numbers! Your copy of Mitsuba has version %s, whereas the dependencies ' % MTS_VERSION)
299+
print('have version %s. Please bring them into sync, either by running\n' % depVersion)
300+
print('$ hg update -r v%s\n' % depVersion)
301+
print('in the Mitsuba directory, or by running\n')
302+
print('$ cd dependencies')
303+
print('$ hg pull')
304+
print('$ hg update -r v%s\n' % MTS_VERSION)
304305
Exit(1)
305306

306307
env = conf.Finish()

build/SConscript.install

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import fnmatch
23

34
Import('env', 'os', 'sys', 'plugins', 'dist',
@@ -27,7 +28,7 @@ def installAs(target, path, prefix = None):
2728
return result
2829

2930
if not 'DISTDIR' in env:
30-
print 'The \"DISTDIR\" variable is missing. Please update your configuration file!'
31+
print('The \"DISTDIR\" variable is missing. Please update your configuration file!')
3132
Exit(1)
3233

3334
distDir = env.GetBuildPath(env['DISTDIR'])

0 commit comments

Comments
 (0)