docs: def write_library_constants():
      """Write libtcod constants into the tcod.constants module."""
      from tcod._libtcod import lib, ffi
      import tcod.color
  
      with open("tcod/constants.py", "w") as f:
          all_names = []
          f.write(CONSTANT_MODULE_HEADER)
          for name in dir(lib):
              value = getattr(lib, name)
              if name[:5] == "TCOD_":
                  if name.isupper():  # const names
                      f.write("%s = %r\n" % (name[5:], value))
                      all_names.append(name[5:])
              elif name.startswith("FOV"):  # fov const names
                  f.write("%s = %r\n" % (name, value))
                  all_names.append(name)
              elif name[:6] == "TCODK_":  # key name
                  f.write("KEY_%s = %r\n" % (name[6:], value))
                  all_names.append("KEY_%s" % name[6:])
  
          f.write("\n# --- colors ---\n")
          for name in dir(lib):
              if name[:5] != "TCOD_":
                  continue
              value = getattr(lib, name)
              if not isinstance(value, ffi.CData):
                  continue
              if ffi.typeof(value) != ffi.typeof("TCOD_color_t"):
                  continue
              color = tcod.color.Color._new_from_cdata(value)
              f.write("%s = %r\n" % (name[5:], color))
              all_names.append(name[5:])
  
          all_names = ",\n    ".join('"%s"' % name for name in all_names)
          f.write("\n__all__ = [\n    %s,\n]\n" % (all_names,))
  
      with open("tcod/event_constants.py", "w") as f:
          all_names = []
          f.write(EVENT_CONSTANT_MODULE_HEADER)
          f.write("# --- SDL scancodes ---\n")
          f.write(
              "%s\n_REVERSE_SCANCODE_TABLE = %s\n"
              % parse_sdl_attrs("SDL_SCANCODE", all_names)
          )
  
          f.write("\n# --- SDL keyboard symbols ---\n")
          f.write(
              "%s\n_REVERSE_SYM_TABLE = %s\n"
              % parse_sdl_attrs("SDLK", all_names)
          )
  
          f.write("\n# --- SDL keyboard modifiers ---\n")
          f.write(
              "%s\n_REVERSE_MOD_TABLE = %s\n"
              % parse_sdl_attrs("KMOD", all_names)
          )
  
          f.write("\n# --- SDL wheel ---\n")
          f.write(
              "%s\n_REVERSE_WHEEL_TABLE = %s\n"
              % parse_sdl_attrs("SDL_MOUSEWHEEL", all_names)
          )
          all_names = ",\n    ".join('"%s"' % name for name in all_names)
          f.write("\n__all__ = [\n    %s,\n]\n" % (all_names,))