__init__.py (SCons-4.3.0) | : | __init__.py (SCons-4.4.0) | ||
---|---|---|---|---|
skipping to change at line 84 | skipping to change at line 84 | |||
return 'aix' | return 'aix' | |||
elif sys.platform.find('darwin') != -1: | elif sys.platform.find('darwin') != -1: | |||
return 'darwin' | return 'darwin' | |||
else: | else: | |||
return 'posix' | return 'posix' | |||
elif os.name == 'os2': | elif os.name == 'os2': | |||
return 'os2' | return 'os2' | |||
else: | else: | |||
return sys.platform | return sys.platform | |||
def platform_module(name = platform_default()): | def platform_module(name=platform_default()): | |||
"""Return the imported module for the platform. | """Return the imported module for the platform. | |||
This looks for a module name that matches the specified argument. | This looks for a module name that matches the specified argument. | |||
If the name is unspecified, we fetch the appropriate default for | If the name is unspecified, we fetch the appropriate default for | |||
our execution environment. | our execution environment. | |||
""" | """ | |||
full_name = 'SCons.Platform.' + name | full_name = 'SCons.Platform.' + name | |||
if full_name not in sys.modules: | try: | |||
if os.name == 'java': | return sys.modules[full_name] | |||
eval(full_name) | except KeyError: | |||
else: | try: | |||
# the specific platform module is a relative import | ||||
mod = importlib.import_module("." + name, __name__) | ||||
except ModuleNotFoundError: | ||||
try: | try: | |||
# the specific platform module is a relative import | # This support was added to enable running inside | |||
mod = importlib.import_module("." + name, __name__) | # a py2exe bundle a long time ago - unclear if it's | |||
except ImportError: | # still needed. It is *not* intended to load individual | |||
try: | # platform modules stored in a zipfile. | |||
import zipimport | import zipimport | |||
importer = zipimport.zipimporter( sys.modules['SCons.Platfor | ||||
m'].__path__[0] ) | platform = sys.modules['SCons.Platform'].__path__[0] | |||
importer = zipimport.zipimporter(platform) | ||||
if not hasattr(importer, 'find_spec'): | ||||
# zipimport only added find_spec, exec_module in 3.10, | ||||
# unlike importlib, where they've been around since 3.4. | ||||
# If we don't have 'em, use the old way. | ||||
mod = importer.load_module(full_name) | mod = importer.load_module(full_name) | |||
except ImportError: | else: | |||
raise SCons.Errors.UserError("No platform named '%s'" % name | spec = importer.find_spec(full_name) | |||
) | mod = importlib.util.module_from_spec(spec) | |||
setattr(SCons.Platform, name, mod) | importer.exec_module(mod) | |||
return sys.modules[full_name] | sys.modules[full_name] = mod | |||
except zipimport.ZipImportError: | ||||
raise SCons.Errors.UserError("No platform named '%s'" % name) | ||||
setattr(SCons.Platform, name, mod) | ||||
return mod | ||||
def DefaultToolList(platform, env): | def DefaultToolList(platform, env): | |||
"""Select a default tool list for the specified platform. | """Select a default tool list for the specified platform.""" | |||
""" | ||||
return SCons.Tool.tool_list(platform, env) | return SCons.Tool.tool_list(platform, env) | |||
class PlatformSpec: | class PlatformSpec: | |||
def __init__(self, name, generate): | def __init__(self, name, generate): | |||
self.name = name | self.name = name | |||
self.generate = generate | self.generate = generate | |||
def __call__(self, *args, **kw): | def __call__(self, *args, **kw): | |||
return self.generate(*args, **kw) | return self.generate(*args, **kw) | |||
skipping to change at line 323 | skipping to change at line 337 | |||
print_func = get('PRINT_CMD_LINE_FUNC') | print_func = get('PRINT_CMD_LINE_FUNC') | |||
# use the default action cmd line print if user did not supply one | # use the default action cmd line print if user did not supply one | |||
if not print_func: | if not print_func: | |||
action = SCons.Action._ActionAction() | action = SCons.Action._ActionAction() | |||
action.print_cmd_line(cmdstr, target, source, env) | action.print_cmd_line(cmdstr, target, source, env) | |||
else: | else: | |||
print_func(cmdstr, target, source, env) | print_func(cmdstr, target, source, env) | |||
def Platform(name = platform_default()): | def Platform(name = platform_default()): | |||
"""Select a canned Platform specification. | """Select a canned Platform specification.""" | |||
""" | ||||
module = platform_module(name) | module = platform_module(name) | |||
spec = PlatformSpec(name, module.generate) | spec = PlatformSpec(name, module.generate) | |||
return spec | return spec | |||
# Local Variables: | # Local Variables: | |||
# tab-width:4 | # tab-width:4 | |||
# indent-tabs-mode:nil | # indent-tabs-mode:nil | |||
# End: | # End: | |||
# vim: set expandtab tabstop=4 shiftwidth=4: | # vim: set expandtab tabstop=4 shiftwidth=4: | |||
End of changes. 6 change blocks. | ||||
21 lines changed or deleted | 33 lines changed or added |