Repository: twisted/twisted

Issue:
Update package metadata
**Is your feature request related to a problem? Please describe.**

The Python packaging ecosystem has standardized on the interface for build backends ([PEP 517](https://peps.python.org/pep-0517/)/[PEP 660](https://peps.python.org/pep-0660/)) and the format for metadata declaration ([PEP 621](https://peps.python.org/pep-0621/)/[PEP 631](https://peps.python.org/pep-0631/)). As a result, the execution of `setup.py` files is now [deprecated](https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html).

**Describe the solution you'd like**

Use modern packaging standards

**Describe alternatives you've considered**

Doing nothing is an option for now


Discussion:

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -28,7 +28,7 @@
 
 # -- General configuration ------------------------------------------------
 
-# See setup.cfg for the Sphinx version required to build the documentation.
+# See pyproject.toml for the Sphinx version required to build the documentation.
 # needs_sphinx is not use to avoid duplication and getting these values
 # out of sync.
 
diff --git a/hatch_build.py b/hatch_build.py
new file mode 100644
--- /dev/null
+++ b/hatch_build.py
@@ -0,0 +1,20 @@
+# Copyright (c) Twisted Matrix Laboratories.
+# See LICENSE for details.
+from hatchling.metadata.plugin.interface import MetadataHookInterface
+
+
+class CustomMetadataHook(MetadataHookInterface):
+    def update(self, metadata):
+        optional_dependencies = self.config["optional-dependencies"]
+        for feature, dependencies in list(optional_dependencies.items()):
+            if "-" not in feature:
+                continue
+
+            # We define all the legacy dependency targets using the
+            # underscore for backward compatibility.
+            #
+            # See: https://github.com/twisted/twisted/pull/11656#issuecomment-1282855123
+            legacy_feature = feature.replace("-", "_")
+            optional_dependencies[legacy_feature] = dependencies
+
+        metadata["optional-dependencies"] = optional_dependencies
diff --git a/setup.py b/setup.py
deleted file mode 100755
--- a/setup.py
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright (c) Twisted Matrix Laboratories.
-# See LICENSE for details.
-
-"""
-Setuptools installer for Twisted.
-"""
-
-import pathlib
-import re
-
-import setuptools
-
-setuptools.setup(
-    # Munge links of the form `NEWS <NEWS.rst>`_ to point at the appropriate
-    # location on GitHub so that they function when the long description is
-    # displayed on PyPI.
-    long_description=re.sub(
-        r"`([^`]+)\s+<(?!https?://)([^>]+)>`_",
-        r"`\1 <https://github.com/twisted/twisted/blob/trunk/\2>`_",
-        pathlib.Path("README.rst").read_text(encoding="utf8"),
-        flags=re.I,
-    )
-)


Test patch:
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -164,7 +164,7 @@ jobs:
           - python-version: '3.7'
             tox-env: 'alldeps-gtk-withcov-posix'
             trial-target: 'twisted.internet.test'
-            platform-deps: 'gtk_platform'
+            platform-deps: 'gtk-platform'
             tox-wrapper: 'xvfb-run -a'
             job-name: 'gtk-tests'
 
@@ -210,7 +210,7 @@ jobs:
     # Make sure the matrix is defined in such a way that this is triggered
     # only on Linux.
     - name: Install GTK system deps
-      if: matrix.platform-deps == 'gtk_platform'
+      if: matrix.platform-deps == 'gtk-platform'
       run: |
         # *-dev dependencies are for pygobject
         # https://gitlab.gnome.org/GNOME/pygobject/-/blob/3.42.0/setup.py#L129-L134