OLD | NEW |
1 # | 1 # |
2 # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The SCons Foundat
ion | 2 # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons F
oundation |
3 # | 3 # |
4 # Permission is hereby granted, free of charge, to any person obtaining | 4 # Permission is hereby granted, free of charge, to any person obtaining |
5 # a copy of this software and associated documentation files (the | 5 # a copy of this software and associated documentation files (the |
6 # "Software"), to deal in the Software without restriction, including | 6 # "Software"), to deal in the Software without restriction, including |
7 # without limitation the rights to use, copy, modify, merge, publish, | 7 # without limitation the rights to use, copy, modify, merge, publish, |
8 # distribute, sublicense, and/or sell copies of the Software, and to | 8 # distribute, sublicense, and/or sell copies of the Software, and to |
9 # permit persons to whom the Software is furnished to do so, subject to | 9 # permit persons to whom the Software is furnished to do so, subject to |
10 # the following conditions: | 10 # the following conditions: |
11 # | 11 # |
12 # The above copyright notice and this permission notice shall be included | 12 # The above copyright notice and this permission notice shall be included |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 We name the compatibility modules with an initial '_scons_' (for example, | 54 We name the compatibility modules with an initial '_scons_' (for example, |
55 _scons_subprocess.py is our compatibility module for subprocess) so | 55 _scons_subprocess.py is our compatibility module for subprocess) so |
56 that we can still try to import the real module name and fall back to | 56 that we can still try to import the real module name and fall back to |
57 our compatibility module if we get an ImportError. The import_as() | 57 our compatibility module if we get an ImportError. The import_as() |
58 function defined below loads the module as the "real" name (without the | 58 function defined below loads the module as the "real" name (without the |
59 '_scons'), after which all of the "import {module}" statements in the | 59 '_scons'), after which all of the "import {module}" statements in the |
60 rest of our code will find our pre-loaded compatibility module. | 60 rest of our code will find our pre-loaded compatibility module. |
61 """ | 61 """ |
62 | 62 |
63 __revision__ = "src/engine/SCons/compat/__init__.py 3842 2008/12/20 22:59:52 sco
ns" | 63 __revision__ = "src/engine/SCons/compat/__init__.py 3897 2009/01/13 06:45:54 sco
ns" |
64 | 64 |
65 def import_as(module, name): | 65 def import_as(module, name): |
66 """ | 66 """ |
67 Imports the specified module (from our local directory) as the | 67 Imports the specified module (from our local directory) as the |
68 specified name. | 68 specified name. |
69 """ | 69 """ |
70 import imp | 70 import imp |
71 import os.path | 71 import os.path |
72 dir = os.path.split(__file__)[0] | 72 dir = os.path.split(__file__)[0] |
73 file, filename, suffix_mode_type = imp.find_module(module, [dir]) | 73 file, filename, suffix_mode_type = imp.find_module(module, [dir]) |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 import string | 235 import string |
236 version_string = string.split(sys.version)[0] | 236 version_string = string.split(sys.version)[0] |
237 version_ints = map(int, string.split(version_string, '.')) | 237 version_ints = map(int, string.split(version_string, '.')) |
238 sys.version_info = tuple(version_ints + ['final', 0]) | 238 sys.version_info = tuple(version_ints + ['final', 0]) |
239 | 239 |
240 try: | 240 try: |
241 import UserString | 241 import UserString |
242 except ImportError: | 242 except ImportError: |
243 # Pre-1.6 Python has no UserString module. | 243 # Pre-1.6 Python has no UserString module. |
244 import_as('_scons_UserString', 'UserString') | 244 import_as('_scons_UserString', 'UserString') |
OLD | NEW |