class_docstr: The environment in which the ReST files are translated.
  Stores an inventory of cross-file targets and provides doctree
  transformations to resolve links to them.
class_docstr_tok: ["The","environment","in","which","the","ReST","files","are","translated",".","Stores","an","inventory","of","cross-file","targets","and","provides","doctree","transformations","to","resolve","links","to","them","."]
docstr: Set up BuildEnvironment object.
code: def setup(self, app: Sphinx) -> None:
      """Set up BuildEnvironment object."""
      if self.version and self.version != app.registry.get_envversion(
          app
      ):
          raise BuildEnvironmentError(
              __("build environment version not current")
          )
      if self.srcdir and self.srcdir != app.srcdir:
          raise BuildEnvironmentError(
              __("source directory has changed")
          )
  
      if self.project:
          app.project.restore(self.project)
  
      self.app = app
      self.doctreedir = app.doctreedir
      self.events = app.events
      self.srcdir = app.srcdir
      self.project = app.project
      self.version = app.registry.get_envversion(app)
  
      # initialize domains
      self.domains = _DomainsType()
      for domain in app.registry.create_domains(self):
          self.domains[domain.name] = domain
  
      # setup domains (must do after all initialization)
      for domain in self.domains.values():
          domain.setup()
  
      # initialize config
      self._update_config(app.config)
  
      # initialize settings
      self._update_settings(app.config)
  
imports: from __future__ import annotations
  import functools
  import os
  import pickle
  import time
  from collections import defaultdict
  from copy import copy
  from os import path
  from typing import TYPE_CHECKING, Any, Callable, NoReturn
  from sphinx import addnodes
  from sphinx.environment.adapters import toctree
  from sphinx.errors import BuildEnvironmentError, DocumentError, ExtensionError, SphinxError
  from sphinx.locale import __
  from sphinx.transforms import SphinxTransformer
  from sphinx.util import DownloadFiles, FilenameUniqDict, logging
  from sphinx.util.docutils import LoggingReporter
  from sphinx.util.i18n import CatalogRepository, docname_to_domain
  from sphinx.util.nodes import is_translatable
  from sphinx.util.osutil import canon_path, os_path
label_desc: Use image node_id 4 for calling the BuildEnvironment obj's underlying member method code with example usage: obj.setup(app) without return types