Reputation: 20569
What is the best practice in 2020 to make SConstruct
Python 3 compatible?
For example, running old SConstruct
gives errors like this.
✗ python ~/scons/scripts/scons.py
scons: Reading SConscript files ...
File "/home/techtonik/Folding@home/fah-control/SConstruct", line 17
except Exception, e:
^
SyntaxError: invalid syntax
Upvotes: 0
Views: 292
Reputation: 909
2to3
or modernize
ought to help. it's just Python syntax that's at issue.
2to3
is shipped with Python, and can also be executed as a Python module:
python -m lib2to3 -w SConstruct
Here's the patch 2to3
suggested, looks pretty minor:
RefactoringTool: Refactored SConstruct
--- SConstruct (original)
+++ SConstruct (refactored)
@@ -3,8 +3,8 @@
env = Environment(ENV = os.environ)
try:
env.Tool('config', toolpath = [os.environ.get('CBANG_HOME')])
-except Exception, e:
- raise Exception, 'CBANG_HOME not set?\n' + str(e)
+except Exception as e:
+ raise Exception('CBANG_HOME not set?\n' + str(e))
env.CBLoadTools('packager run_distutils osx fah-client-version')
env.CBAddVariables(
@@ -14,7 +14,7 @@
# Version
try:
version = env.FAHClientVersion()
-except Exception, e:
+except Exception as e:
print(e)
version = '0.0.0'
env.Replace(PACKAGE_VERSION = version)
RefactoringTool: Files that need to be modified:
RefactoringTool: SConstruct
Upvotes: 2