def parseOptions(logger): # First, isolate the first non-option arguments. extra_args = [] if is_nuitka_run: count = 0 for count, arg in enumerate(sys.argv): if count == 0: continue if arg[0] != "-": break # Treat "--" as a terminator. if arg == "--": count += 1 break if count > 0: extra_args = sys.argv[count + 1 :] sys.argv = sys.argv[0 : count + 1] # Next, lets activate plugins early, so they can inject more options to the parser. _considerPluginOptions(logger) options, positional_args = parser.parse_args() if options.list_plugins: from nuitka.plugins.Plugins import listPlugins listPlugins() sys.exit(0) if not positional_args: parser.print_help() logger.sysexit( """ Error, need positional argument with python module or main program.""" ) if not options.immediate_execution and len(positional_args) > 1: parser.print_help() logger.sysexit( """ Error, specify only one positional argument unless "--run" is specified to pass them to the compiled program execution.""" ) return is_nuitka_run, options, positional_args, extra_args
def parseOptions(): # First, isolate the first non-option arguments. if is_nuitka_run: count = 0 for count, arg in enumerate(sys.argv): if count == 0: continue if arg[0] != "-": break # Treat "--" as a terminator. if arg == "--": count += 1 break if count > 0: extra_args = sys.argv[count + 1 :] sys.argv = sys.argv[0 : count + 1] else: extra_args = [] options, positional_args = parser.parse_args() if options.list_plugins: from nuitka.plugins.Plugins import listPlugins listPlugins() sys.exit(0) if not positional_args: parser.print_help() sys.exit( """ Error, need positional argument with python module or main program.""" ) if not options.immediate_execution and len(positional_args) > 1: parser.print_help() sys.exit( """ Error, need only one positional argument unless "--run" is specified to pass them to the compiled program execution.""" ) return is_nuitka_run, options, positional_args, extra_args
def parseOptions(logger): # Pretty complex code, having a small options parser and many details as # well as integrating with plugins and run modes, pylint: disable=too-many-branches # First, isolate the first non-option arguments. extra_args = [] if is_nuitka_run: count = 0 for count, arg in enumerate(sys.argv): if count == 0: continue if arg[0] != "-": filename_arg = arg[0] break # Treat "--" as a terminator. if arg == "--": count += 1 break if count > 0: extra_args = sys.argv[count + 1:] sys.argv = sys.argv[0:count + 1] filename_arg = None for count, arg in enumerate(sys.argv): if count == 0: continue if arg[0] != "-": filename_arg = arg break if filename_arg is not None: sys.argv = ([sys.argv[0]] + list( _getProjectOptions(logger, filename_arg, "--module" in sys.argv[1:])) + sys.argv[1:]) # Next, lets activate plugins early, so they can inject more options to the parser. _considerPluginOptions(logger) options, positional_args = parser.parse_args() if options.list_plugins: from nuitka.plugins.Plugins import listPlugins listPlugins() sys.exit(0) if not positional_args: parser.print_help() logger.sysexit(""" Error, need positional argument with python module or main program.""") if not options.immediate_execution and len(positional_args) > 1: parser.print_help() logger.sysexit(""" Error, specify only one positional argument unless "--run" is specified to pass them to the compiled program execution.""") return is_nuitka_run, options, positional_args, extra_args
def parseArgs(): # singleton with many cases, pylint: disable=global-statement,too-many-branches,too-many-statements global options, positional_args, extra_args # First, isolate the first non-option arguments. if is_nuitka_run: count = 0 for count, arg in enumerate(sys.argv): if count == 0: continue if arg[0] != '-': break # Treat "--" as a terminator. if arg == "--": count += 1 break if count > 0: extra_args = sys.argv[count + 1:] sys.argv = sys.argv[0:count + 1] options, positional_args = parser.parse_args() if shallListPlugins(): from nuitka.plugins.Plugins import listPlugins listPlugins() if not positional_args: parser.print_help() sys.exit(""" Error, need positional argument with python module or main program.""") if not options.immediate_execution and len(positional_args) > 1: parser.print_help() sys.exit(""" Error, need only one positional argument unless "--run" is specified to pass them to the compiled program execution.""") if options.verbose: logging.getLogger().setLevel(logging.DEBUG) else: logging.getLogger().setLevel(logging.INFO) # Standalone mode implies an executable, not importing "site" module, which is # only for this machine, recursing to all modules, and even including the # standard library. if options.is_standalone: if not options.executable: sys.exit("""\ Error, conflicting options, cannot make standalone module, only executable.""") options.recurse_all = True if Utils.getOS() == "NetBSD": logging.warning( "Standalone mode on NetBSD is not functional, due to $ORIGIN linkage not being supported." ) for any_case_module in getShallFollowModules(): if any_case_module.startswith('.'): bad = True else: for char in "/\\:": if char in any_case_module: bad = True break else: bad = False if bad: sys.exit( """\ Error, '--recurse-to' takes only module names, not directory path '%s'.""" % \ any_case_module ) for no_case_module in getShallFollowInNoCase(): if no_case_module.startswith('.'): bad = True else: for char in "/\\:": if char in no_case_module: bad = True break else: bad = False if bad: sys.exit( """\ Error, '--recurse-not-to' takes only module names, not directory path '%s'.""" % \ no_case_module ) scons_python = getPythonPathForScons() if scons_python is not None and not os.path.exists(scons_python): sys.exit("Error, no such Python2 binary '%s'." % scons_python)
def parseArgs(): # singleton with many cases, pylint: disable=global-statement,too-many-branches global is_nuitka_run, options, positional_args, extra_args is_nuitka_run, options, positional_args, extra_args = parseOptions() if shallListPlugins(): from nuitka.plugins.Plugins import listPlugins listPlugins() if options.verbose: logging.getLogger().setLevel(logging.DEBUG) else: logging.getLogger().setLevel(logging.INFO) # Standalone mode implies an executable, not importing "site" module, which is # only for this machine, recursing to all modules, and even including the # standard library. if options.is_standalone: if not options.executable: sys.exit("""\ Error, conflicting options, cannot make standalone module, only executable.""") options.recurse_all = True if Utils.getOS() == "NetBSD": logging.warning( "Standalone mode on NetBSD is not functional, due to $ORIGIN linkage not being supported." ) for any_case_module in getShallFollowModules(): if any_case_module.startswith('.'): bad = True else: for char in "/\\:": if char in any_case_module: bad = True break else: bad = False if bad: sys.exit( """\ Error, '--follow-import-to' takes only module names, not directory path '%s'.""" % \ any_case_module ) for no_case_module in getShallFollowInNoCase(): if no_case_module.startswith('.'): bad = True else: for char in "/\\:": if char in no_case_module: bad = True break else: bad = False if bad: sys.exit( """\ Error, '--nofollow-import-to' takes only module names, not directory path '%s'.""" % \ no_case_module ) scons_python = getPythonPathForScons() if scons_python is not None and not os.path.exists(scons_python): sys.exit("Error, no such Python binary '%s'." % scons_python) if options.output_filename is not None and \ (isStandaloneMode() or shallMakeModule()): sys.exit("""\ Error, can only specify output filename for acceleration mode, not for module mode where filenames are mandatory, and not for standalone where there is a sane default used inside the dist folder.""")