old_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  """Checks for optional dependencies using lazy import from
  `PEP 562 <https://www.python.org/dev/peps/pep-0562/>`_.
  """
  import importlib
  
  
  __all__ = [  # noqa
      'HAS_bleach', 'HAS_bottleneck', 'HAS_bs4', 'HAS_bz2', 'HAS_h5py',
      'HAS_html5lib', 'HAS_IPython', 'HAS_jplephem', 'HAS_lxml', 'HAS_matplotlib',
      'HAS_mpmath', 'HAS_pandas', 'HAS_PIL', 'HAS_pkg_resources', 'HAS_pytz',
      'HAS_scipy', 'HAS_skyfield', 'HAS_sortedcontainers', 'HAS_lzma', 'HAS_yaml'
  ]
  
  
  def __getattr__(name):
      if name in __all__:
          module_name = name[4:]
  
          try:
              importlib.import_module(module_name)
          except (ImportError, ModuleNotFoundError):
              return False
          return True
  
      raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
  
new_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  """Checks for optional dependencies using lazy import from
  `PEP 562 <https://www.python.org/dev/peps/pep-0562/>`_.
  """
  import importlib
  
  # TODO: This is a duplicate of the dependencies in setup.cfg "all", but some of
  # the package names are different from the pip-install name (e.g.,
  # beautifulsoup4 -> bs4).
  _optional_deps = ['bleach', 'bottleneck', 'bs4', 'bz2', 'h5py', 'html5lib',
                    'IPython', 'jplephem', 'lxml', 'matplotlib', 'mpmath',
                    'pandas', 'PIL', 'pkg_resources', 'pytz', 'scipy', 'skyfield',
                    'sortedcontainers', 'lzma', 'yaml']
  
  __all__ = [f"HAS_{pkg}" for pkg in _optional_deps]
  
  
  def __getattr__(name):
      if name in __all__:
          module_name = name[4:]
  
          try:
              importlib.import_module(module_name)
          except (ImportError, ModuleNotFoundError):
              return False
          return True
  
      # I don't think we can ever get here, because if a name doesn't exist, it
      # should fail to import from this module. But adding this for safety!
      raise AttributeError(f"Module {__name__!r} has no attribute {name!r}. To "
                           "add support for checking if a package name is "
                           "available for import, add the package name")
  
subject: modify to maintain a list of optional package names, and make the HAS_ names separately