class_docstr: Abstraction for GDAL and AWS configuration
  
  The GDAL library is stateful: it has a registry of format drivers,
  an error stack, and dozens of configuration options.
  
  Fiona's approach to working with GDAL is to wrap all the state
  up using a Python context manager (see PEP 343,
  https://www.python.org/dev/peps/pep-0343/). When the context is
  entered GDAL drivers are registered, error handlers are
  configured, and configuration options are set. When the context
  is exited, drivers are removed from the registry and other
  configurations are removed.
  
  Example:
  
      with fiona.Env(GDAL_CACHEMAX=512) as env:
          # All drivers are registered, GDAL's raster block cache
          # size is set to 512MB.
          # Commence processing...
          ...
          # End of processing.
  
      # At this point, configuration options are set to their
      # previous (possible unset) values.
  
  A boto3 session or boto3 session constructor arguments
  `aws_access_key_id`, `aws_secret_access_key`, `aws_session_token`
  may be passed to Env's constructor. In the latter case, a session
  will be created as soon as needed. AWS credentials are configured
  for GDAL as needed.
class_docstr_tok: ["Abstraction","for","GDAL","and","AWS","configuration","The","GDAL","library","is","stateful",":","it","has","a","registry","of","format","drivers",",","an","error","stack",",","and","dozens","of","configuration","options",".","Fiona","'s","approach","to","working","with","GDAL","is","to","wrap","all","the","state","up","using","a","Python","context","manager","(","see","PEP","343",",","https",":","\/\/www.python.org\/dev\/peps\/pep-0343\/",")",".","When","the","context","is","entered","GDAL","drivers","are","registered",",","error","handlers","are","configured",",","and","configuration","options","are","set",".","When","the","context","is","exited",",","drivers","are","removed","from","the","registry","and","other","configurations","are","removed",".","Example",":","with","fiona.Env","(","GDAL_CACHEMAX=512",")","as","env",":","#","All","drivers","are","registered",",","GDAL","'s","raster","block","cache","#","size","is","set","to","512MB",".","#","Commence","processing","...","...","#","End","of","processing",".","#","At","this","point",",","configuration","options","are","set","to","their","#","previous","(","possible","unset",")","values",".","A","boto3","session","or","boto3","session","constructor","arguments","`","aws_access_key_id","`",",","`","aws_secret_access_key","`",",","`","aws_session_token","`","may","be","passed","to","Env","'s","constructor",".","In","the","latter","case",",","a","session","will","be","created","as","soon","as","needed",".","AWS","credentials","are","configured","for","GDAL","as","needed","."]
docstr: Create a new GDAL/AWS environment.
  Note: this class is a context manager. GDAL isn't configured
  until the context is entered via `with fiona.Env():`
  
  Parameters
  ----------
  session : optional
      A Session object.
  aws_unsigned : bool, optional
      Do not sign cloud requests.
  profile_name : str, optional
      A shared credentials profile name, as per boto3.
  session_class : Session, optional
      A sub-class of Session.
  **options : optional
      A mapping of GDAL configuration options, e.g.,
      `CPL_DEBUG=True, CHECK_WITH_INVERT_PROJ=False`.
  
  Returns
  -------
  Env
  
  Notes
  -----
  We raise EnvError if the GDAL config options
  AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY are given. AWS
  credentials are handled exclusively by boto3.
  
  Examples
  --------
  >>> with Env(CPL_DEBUG=True, CPL_CURL_VERBOSE=True):
  ...     with fiona.open("zip+https://example.com/a.zip") as col:
  ...         print(col.profile)
  
  For access to secured cloud resources, a Fiona Session or a
  foreign session object may be passed to the constructor.
  
  >>> import boto3
  >>> from fiona.session import AWSSession
  >>> boto3_session = boto3.Session(...)
  >>> with Env(AWSSession(boto3_session)):
  ...     with fiona.open("zip+s3://example/a.zip") as col:
  ...         print(col.profile
docstr_tok: ["Create","a","new","GDAL\/AWS","environment",".","Note",":","this","class","is","a","context","manager",".","GDAL","is","n't","configured","until","the","context","is","entered","via","`","with","fiona.Env","(",")",":","`","Parameters","--","--","--","--","--","session",":","optional","A","Session","object",".","aws_unsigned",":","bool",",","optional","Do","not","sign","cloud","requests",".","profile_name",":","str",",","optional","A","shared","credentials","profile","name",",","as","per","boto3",".","session_class",":","Session",",","optional","A","sub-class","of","Session",".","*","*","options",":","optional","A","mapping","of","GDAL","configuration","options",",","e.g.",",","`","CPL_DEBUG=True",",","CHECK_WITH_INVERT_PROJ=False","`",".","Returns","--","--","--","-","Env","Notes","--","--","-","We","raise","EnvError","if","the","GDAL","config","options","AWS_ACCESS_KEY_ID","or","AWS_SECRET_ACCESS_KEY","are","given",".","AWS","credentials","are","handled","exclusively","by","boto3",".","Examples","--","--","--","--",">",">",">","with","Env","(","CPL_DEBUG=True",",","CPL_CURL_VERBOSE=True",")",":","...","with","fiona.open","(","``","zip+https",":","\/\/example.com\/a.zip","''",")","as","col",":","...","print","(","col.profile",")","For","access","to","secured","cloud","resources",",","a","Fiona","Session","or","a","foreign","session","object","may","be","passed","to","the","constructor",".",">",">",">","import","boto3",">",">",">","from","fiona.session","import","AWSSession",">",">",">","boto3_session","=","boto3.Session","(","...",")",">",">",">","with","Env","(","AWSSession","(","boto3_session",")",")",":","...","with","fiona.open","(","``","zip+s3",":","\/\/example\/a.zip","''",")","as","col",":","...","print","(","col.profile"]
code: def __init__(
      self,
      session=None,
      aws_unsigned=False,
      profile_name=None,
      session_class=Session.aws_or_dummy,
      **options,
  ):
      """Create a new GDAL/AWS environment.
      Note: this class is a context manager. GDAL isn't configured
      until the context is entered via `with fiona.Env():`
  
      Parameters
      ----------
      session : optional
          A Session object.
      aws_unsigned : bool, optional
          Do not sign cloud requests.
      profile_name : str, optional
          A shared credentials profile name, as per boto3.
      session_class : Session, optional
          A sub-class of Session.
      **options : optional
          A mapping of GDAL configuration options, e.g.,
          `CPL_DEBUG=True, CHECK_WITH_INVERT_PROJ=False`.
  
      Returns
      -------
      Env
  
      Notes
      -----
      We raise EnvError if the GDAL config options
      AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY are given. AWS
      credentials are handled exclusively by boto3.
  
      Examples
      --------
      >>> with Env(CPL_DEBUG=True, CPL_CURL_VERBOSE=True):
      ...     with fiona.open("zip+https://example.com/a.zip") as col:
      ...         print(col.profile)
  
      For access to secured cloud resources, a Fiona Session or a
      foreign session object may be passed to the constructor.
  
      >>> import boto3
      >>> from fiona.session import AWSSession
      >>> boto3_session = boto3.Session(...)
      >>> with Env(AWSSession(boto3_session)):
      ...     with fiona.open("zip+s3://example/a.zip") as col:
      ...         print(col.profile
  
      """
      aws_access_key_id = options.pop("aws_access_key_id", None)
      # Warn deprecation in 1.9, remove in 2.0.
      if aws_access_key_id:
          warnings.warn(
              "Passing abstract session keyword arguments is deprecated. "
              "Pass a Fiona AWSSession object instead.",
              FionaDeprecationWarning,
          )
  
      aws_secret_access_key = options.pop("aws_secret_access_key", None)
      aws_session_token = options.pop("aws_session_token", None)
      region_name = options.pop("region_name", None)
  
      if not {"AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY"}.isdisjoint(
          options
      ):
          raise EnvError(
              "GDAL's AWS config options can not be directly set. "
              "AWS credentials are handled exclusively by boto3."
          )
  
      if session:
          # Passing a session via keyword argument is the canonical
          # way to configure access to secured cloud resources.
          # Warn deprecation in 1.9, remove in 2.0.
          if not isinstance(session, Session):
              warnings.warn(
                  "Passing a boto3 session is deprecated. Pass a Fiona AWSSession object instead.",
                  FionaDeprecationWarning,
              )
              session = Session.aws_or_dummy(session=session)
  
          self.session = session
  
      elif aws_access_key_id or profile_name or aws_unsigned:
          self.session = Session.aws_or_dummy(
              aws_access_key_id=aws_access_key_id,
              aws_secret_access_key=aws_secret_access_key,
              aws_session_token=aws_session_token,
              region_name=region_name,
              profile_name=profile_name,
              aws_unsigned=aws_unsigned,
          )
  
      elif {"AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY"}.issubset(
          os.environ.keys()
      ):
          self.session = Session.from_environ()
  
      else:
          self.session = DummySession()
  
      self.options = options.copy()
      self.context_options = {}
  
imports: from functools import wraps, total_ordering
  from inspect import getfullargspec
  import logging
  import os
  import re
  import threading
  import warnings
  import attr
  from fiona._env import GDALDataFinder, GDALEnv, PROJDataFinder, calc_gdal_version_num, get_gdal_config, get_gdal_release_name, get_gdal_version_num, set_gdal_config, set_proj_data_search_path
  from fiona.errors import EnvError, FionaDeprecationWarning, GDALVersionError
  from fiona.session import Session, DummySession
label_desc: Use image node_id 2 to create a new Env object  with example: obj = Env(session, aws_unsigned, profile_name, session_class)