code: def finalize_options(self):
      v = beparent.finalize_options(self)
  
      if self.enable_all_extensions:
          exts = [
              "fts4",
              "fts3",
              "fts3_parenthesis",
              "rtree",
              "stat4",
              "json1",
              "fts5",
              "rbu",
          ]
          if find_in_path("icu-config"):
              exts.append("icu")
          if not self.enable:
              self.enable = ",".join(exts)
          else:
              self.enable = self.enable + "," + ",".join(exts)
  
      ext = self.extensions[0]
  
      if not ext.define_macros:
          ext.define_macros = []
      if not ext.depends:
          ext.depends = []
      if not ext.include_dirs:
          ext.include_dirs = []
      if not ext.library_dirs:
          ext.library_dirs = []
      if not ext.libraries:
          ext.libraries = []
  
      # Fixup debug setting
      if self.debug:
          # distutils forces NDEBUG even with --debug so overcome that
          ext.define_macros.append(
              ("APSW_NO_NDEBUG", "1")
          )  # double negatives are bad
          ext.define_macros.append(
              ("APSW_TESTFIXTURES", "1")
          )  # extra test harness code
          ext.define_macros.append(
              ("SQLITE_DEBUG", "1")
          )  # also does NDEBUG mangling
      else:
          ext.define_macros.append(("NDEBUG", "1"))
  
      # fork checker?
      if hasattr(os, "fork"):
          ext.define_macros.append(("APSW_FORK_CHECKER", "1"))
  
      ext.define_macros.append(
          ("SQLITE_MAX_COLUMN", "32767")
      )  # PLASTICITY
      ext.define_macros.append(
          ("SQLITE_MAX_VARIABLE_NUMBER", "99999")
      )  # PLASTICITY
  
      # SQLite 3
      # Look for amalgamation in our directory or in sqlite3 subdirectory
  
      path = findamalgamation()
      if path:
          if sys.platform == "win32":
              # double quotes get consumed by windows arg processing
              ext.define_macros.append(
                  ("APSW_USE_SQLITE_AMALGAMATION", '\\"' + path + '\\"')
              )
          else:
              ext.define_macros.append(
                  ("APSW_USE_SQLITE_AMALGAMATION", '"' + path + '"')
              )
          ext.depends.append(path)
          # we also add the directory to include path since icu tries to use it
          ext.include_dirs.append(os.path.dirname(path))
          write("SQLite: Using amalgamation", path)
          load_extension = True
      else:
          load_extension = False
          d = os.path.join(
              os.path.dirname(os.path.abspath(__file__)), "sqlite3"
          )
          if os.path.isdir(d):
              write(
                  "SQLite: Using include/libraries in sqlite3 subdirectory"
              )
              ext.include_dirs.append(d)
              ext.library_dirs.append(d)
          else:
              write("SQLite: Using system sqlite include/libraries")
          # ext.libraries.append('sqlite3') PLASTICITY
  
      s3config = os.path.join(
          os.path.dirname(os.path.abspath(__file__)),
          "sqlite3",
          "sqlite3config.h",
      )
      if os.path.exists(s3config):
          if sys.platform == "win32":
              ext.define_macros.append(
                  ("APSW_USE_SQLITE_CONFIG", '\\"' + s3config + '\\"')
              )
          else:
              ext.define_macros.append(
                  ("APSW_USE_SQLITE_CONFIG", '"' + s3config + '"')
              )
  
      # enables
      addicuinclib = False
      if self.enable:
          for e in self.enable.split(","):
              e = e.strip()
              if e.lower() == "load_extension":
                  load_extension = True
                  continue
              ext.define_macros.append(
                  ("SQLITE_ENABLE_" + e.upper(), 1)
              )
              if e.upper() == "ICU":
                  addicuinclib = True
              os.putenv("APSW_TEST_" + e.upper(), "1")
              # See issue #55 where I had left off the 3 in fts3.  This code
              # tries to catch misspelling the name of an extension.
              # However the SQLITE_ENABLE prefix is also used by other
              # options - see https://sqlite.org/compile.html but almost
              # all of those have _ in them, so our abbreviated and
              # hopefully future proof test
              if (
                  "_" not in e.lower()
                  and "memsys" not in e.lower()
                  and e.lower()
                  not in (
                      "fts4",
                      "fts3",
                      "rtree",
                      "icu",
                      "iotrace",
                      "stat2",
                      "stat3",
                      "stat4",
                      "dbstat_vtab",
                      "fts5",
                      "json1",
                      "rbu",
                  )
              ):
                  write("Unknown enable " + e, sys.stderr)
                  raise ValueError("Bad enable " + e)
  
      # omits
      if self.omit:
          for e in self.omit.split(","):
              e = e.strip()
              if e.lower() == "load_extension":
                  load_extension = False
              ext.define_macros.append(("SQLITE_OMIT_" + e.upper(), 1))
  
      if not load_extension:
          ext.define_macros.append(("SQLITE_OMIT_LOAD_EXTENSION", 1))
  
      # icu
      if addicuinclib:
          foundicu = False
          kwargs = {}
          if sys.version_info >= (2, 6):
              # if posix is true then quotes get stripped such as from -Dfoo="bar"
              kwargs["posix"] = False
          for part in shlex.split(
              os.popen("icu-config --cppflags", "r").read(), **kwargs
          ):
              if part.startswith("-I"):
                  ext.include_dirs.append(part[2:])
                  foundicu = True
              elif part.startswith("-D"):
                  part = part[2:]
                  if "=" in part:
                      part = tuple(part.split("=", 1))
                  else:
                      part = (part, "1")
                  ext.define_macros.append(part)
                  foundicu = True
  
          for part in shlex.split(
              os.popen("icu-config --ldflags", "r").read(), **kwargs
          ):
              if part.startswith("-L"):
                  ext.library_dirs.append(part[2:])
                  foundicu = True
              elif part.startswith("-l"):
                  ext.libraries.append(part[2:])
                  foundicu = True
  
          if foundicu:
              write(
                  "ICU: Added includes, flags and libraries from icu-config"
              )
          else:
              write(
                  "ICU: Unable to determine includes/libraries for ICU using icu-config"
              )
              write(
                  "ICU: You will need to manually edit setup.py or setup.cfg to set them"
              )
  
      # shell
      if (
          not os.path.exists("src/shell.c")
          or os.path.getmtime("src/shell.c")
          < os.path.getmtime("tools/shell.py")
          or os.path.getmtime(__file__)
          > os.path.getmtime("src/shell.c")
      ):
          create_c_file("tools/shell.py", "src/shell.c")
  
      # done ...
      return v
  
imports: import os
  import sys
  import shlex
  import glob
  import re
  import time
  import zipfile
  import tarfile
  from distutils.command import build_ext, build, sdist
label_desc: Use image node_id 2 for calling the apsw_build_ext obj's underlying member method code with example usage: obj.finalize_options() and returns: v