code: def start_host(session=None):
      
      plugins = []
      for arg in sys.argv:
          _, ext = os.path.splitext(arg)
          if ext == '.py':
              plugins.append(arg)
          elif os.path.isdir(arg):
              init = os.path.join(arg, '__init__.py')
              if os.path.isfile(init):
                  plugins.append(arg)
  
      # This is a special case to support the old workaround of
      # adding an empty .py file to make a package directory
      # visible, and it should be removed soon.
      for path in list(plugins):
          dup = path + ".py"
          if os.path.isdir(path) and dup in plugins:
              plugins.remove(dup)
  
      # Special case: the legacy scripthost receives a single relative filename
      # while the rplugin host will receive absolute paths.
      if plugins == ["script_host.py"]:
          name = "script"
      else:
          name = "rplugin"
  
      setup_logging(name)
  
      if not session:
          session = stdio_session()
      nvim = Nvim.from_session(session)
  
      if nvim.version.api_level < 1:
          sys.stderr.write("This version of pynvim "
                           "requires nvim 0.1.6 or later")
          sys.exit(1)
  
      host = Host(nvim)
      host.start(plugins)
docs: Promote the current process into python plugin host for Nvim.
  
      Start msgpack-rpc event loop for `session`, listening for Nvim requests
      and notifications. It registers Nvim commands for loading/unloading
      python plugins.
  
      The sys.stdout and sys.stderr streams are redirected to Nvim through
      `session`. That means print statements probably won't work as expected
      while this function doesn't return.
  
      This function is normally called at program startup and could have been
      defined as a separate executable. It is exposed as a library function for
      testing purposes only.