diff options
author | Greg Noel <GregNoel@tigris.org> | 2010-04-25 00:15:27 (GMT) |
---|---|---|
committer | Greg Noel <GregNoel@tigris.org> | 2010-04-25 00:15:27 (GMT) |
commit | 1c13a030e39109c5343046d0d555f48b7cc61126 (patch) | |
tree | 74471e800cf3cbd7e01f387a216530cea6280fe9 /src/script | |
parent | bcdc9a412521ae0b9f9aea7997a880af6dbda2a6 (diff) | |
download | SCons-1c13a030e39109c5343046d0d555f48b7cc61126.zip SCons-1c13a030e39109c5343046d0d555f48b7cc61126.tar.gz SCons-1c13a030e39109c5343046d0d555f48b7cc61126.tar.bz2 |
Add compat support for renaming '_winreg' as 'winreg' in Python 3.x.
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/scons-post-install.py | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/script/scons-post-install.py b/src/script/scons-post-install.py index e8fad53..a6a6035 100644 --- a/src/script/scons-post-install.py +++ b/src/script/scons-post-install.py @@ -33,8 +33,17 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import os.path +import os import sys +import imp + +try: + # Before Python 3.0, the 'winreg' module was named '_winreg' + sys.modules['winreg'] = \ + imp.load_module('winreg', *imp.find_module('_winreg')) +except ImportError: + # No '_winreg' module: either 3.x or not Windows + pass scons_bat_path = os.path.join(sys.prefix, 'Scripts', 'scons.bat') @@ -43,15 +52,15 @@ app_paths_key = r'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\SCons.bat' def install(): if sys.platform == 'win32': try: - import _winreg + import winreg except ImportError: pass else: print 'Writing "App Paths" registry entry for %s' % scons_bat_path - _winreg.SetValue( - _winreg.HKEY_LOCAL_MACHINE, + winreg.SetValue( + winreg.HKEY_LOCAL_MACHINE, app_paths_key, - _winreg.REG_SZ, + winreg.REG_SZ, scons_bat_path) print 'Done.' @@ -59,12 +68,12 @@ def install(): def remove(): if sys.platform == 'win32': try: - import _winreg + import winreg except ImportError: pass else: # print 'Remove "App Paths" registry entry' - _winreg.DeleteKey(_winreg.HKEY_LOCAL_MACHINE, app_paths_key) + winreg.DeleteKey(winreg.HKEY_LOCAL_MACHINE, app_paths_key) if len(sys.argv) > 1: |