docs: def freeze_to_tar(script_path, freeze_fn, extra_files=None):
      """Freezes a script to a .tar or .tar.gz file
  
      The script contains all of the files at the root of the tar
  
      Args:
          script_path: Path to python script to be frozen.
          freeze_fn: Tar filename (must end in .tar or .tar.gz)
          extra_files: List of paths to add to the tar (default is None)
  
      Returns:
          List of freeze commands ran
  
      Raises:
          subprocess.CalledProcessError: freeze error.
          OSError: freeze not found.
          NameError: Tar must end in .tar or .tar.gz
      """
      if not extra_files:
          extra_files = []
      freeze_dir = tempfile.mkdtemp()
      try:
          cmds = freeze(script_path, target_dir=freeze_dir)
          if freeze_fn.endswith('.tar.gz'):
              mode = 'w|gz'
          elif freeze_fn.endswith('.tar'):
              mode = 'w'
          else:
              raise NameError('[%s] must end in .tar or .tar.gz' % freeze_fn)
          fp = tarfile.open(freeze_fn, mode)
          proj_name = os.path.basename(script_path)
          proj_name = proj_name[:proj_name.rfind('.')]  # Remove extension
          for x in glob.glob('%s/dist/%s/*' % (freeze_dir, proj_name)) + extra_files:
              fp.add(x, arcname=os.path.basename(x))
          fp.close()
      finally:
          shutil.rmtree(freeze_dir)
      return cmds