parameters: (pyinstaller_command, options)
return_statement: return True
docstring: Call PyInstaller to package a script using provided arguments and options.
      :param pyinstaller_command: Command to supply to PyInstaller
      :param options: auto-py-to-exe specific options for setup and cleaning up
      :return: Whether packaging was successful
docstring_summary: Call PyInstaller to package a script using provided arguments and options.
      :param pyinstaller_command: Command to supply to PyInstaller
      :param options: auto-py-to-exe specific options for setup and cleaning up
      :return: Whether packaging was successful
docstring_tokens: Call PyInstaller to package a script using provided arguments and options . : param pyinstaller_command : Command to supply to PyInstaller : param options : auto - py - to - exe specific options for setup and cleaning up : return : Whether packaging was successful
function: def package(pyinstaller_command, options):
      """
      Call PyInstaller to package a script using provided arguments and options.
      :param pyinstaller_command: Command to supply to PyInstaller
      :param options: auto-py-to-exe specific options for setup and cleaning up
      :return: Whether packaging was successful
      """
  
      # Show current version
      logger.info("Running auto-py-to-exe v" + version)
  
      # Notify the user of the workspace and setup building to it
      logger.info("Building directory: {}".format(config.temporary_directory))
  
      # Override arguments
      dist_path = os.path.join(config.temporary_directory, 'application')
      build_path = os.path.join(config.temporary_directory, 'build')
      extra_args = ['--distpath', dist_path] + ['--workpath', build_path] + ['--specpath', config.temporary_directory]
  
      logger.info('Provided command: {}'.format(pyinstaller_command))
  
      # Setup options
      increase_recursion_limit = options['increaseRecursionLimit']
      output_directory = os.path.abspath(options['outputDirectory'])
  
      if increase_recursion_limit:
          sys.setrecursionlimit(5000)
          logger.info("Recursion Limit is set to 5000")
      else:
          sys.setrecursionlimit(config.DEFAULT_RECURSION_LIMIT)
  
      # Run PyInstaller
      fail = False
      try:
          # Since we allow manual argument input, we cannot pass arguments to PyInstaller as a list as we can't
          # guarantee that the arguments will be parsed correctly. To get around this, we can set sys.argv here with our
          # command to trick PyInstaller to reading the command as if we are using the cli tool.
          sys.argv = shlex.split(pyinstaller_command) + extra_args  # Put command into sys.argv and extra args
  
          # Display the command we are using and leave a space to separate out PyInstallers logs
          logger.info('Executing: {}'.format(' '.join(sys.argv)))
          logger.info('')
  
          run_pyinstaller()
      except:
          fail = True
          logger.exception("An error occurred while packaging")
  
      # Move project if there was no failure
      logger.info("")
      if not fail:
          logger.info("Moving project to: {0}".format(output_directory))
          try:
              __move_package(dist_path, output_directory)
          except:
              logger.error("Failed to move project")
              logger.exception(traceback.format_exc())
      else:
          logger.info("Project output will not be moved to output folder")
          return False
  
      # Set complete
      return True
function_tokens: def package ( pyinstaller_command , options ) : # Show current version logger . info ( "Running auto-py-to-exe v" + version ) # Notify the user of the workspace and setup building to it logger . info ( "Building directory: {}" . format ( config . temporary_directory ) ) # Override arguments dist_path = os . path . join ( config . temporary_directory , 'application' ) build_path = os . path . join ( config . temporary_directory , 'build' ) extra_args = [ '--distpath' , dist_path ] + [ '--workpath' , build_path ] + [ '--specpath' , config . temporary_directory ] logger . info ( 'Provided command: {}' . format ( pyinstaller_command ) ) # Setup options increase_recursion_limit = options [ 'increaseRecursionLimit' ] output_directory = os . path . abspath ( options [ 'outputDirectory' ] ) if increase_recursion_limit : sys . setrecursionlimit ( 5000 ) logger . info ( "Recursion Limit is set to 5000" ) else : sys . setrecursionlimit ( config . DEFAULT_RECURSION_LIMIT ) # Run PyInstaller fail = False try : # Since we allow manual argument input, we cannot pass arguments to PyInstaller as a list as we can't # guarantee that the arguments will be parsed correctly. To get around this, we can set sys.argv here with our # command to trick PyInstaller to reading the command as if we are using the cli tool. sys . argv = shlex . split ( pyinstaller_command ) + extra_args # Put command into sys.argv and extra args # Display the command we are using and leave a space to separate out PyInstallers logs logger . info ( 'Executing: {}' . format ( ' ' . join ( sys . argv ) ) ) logger . info ( '' ) run_pyinstaller ( ) except : fail = True logger . exception ( "An error occurred while packaging" ) # Move project if there was no failure logger . info ( "" ) if not fail : logger . info ( "Moving project to: {0}" . format ( output_directory ) ) try : __move_package ( dist_path , output_directory ) except : logger . error ( "Failed to move project" ) logger . exception ( traceback . format_exc ( ) ) else : logger . info ( "Project output will not be moved to output folder" ) return False # Set complete return True