Repository: pypa/setuptools

Issue:
[BUG] "configuration would be ignored" warning not emitted for scripts
### setuptools version

setuptools==68.0.0

### Python version

Python 3.11.4

### OS

Windows 11

### Additional environment information

_No response_

### Description

setuptools currently emits a "configuration would be ignored/result in error due to `pyproject.toml`" warning when a `project` section in `pyproject.toml` doesn't declare a setting as dynamic, and that setting is specified in `setup.py`.

However, this doesn't happen for the `scripts` or `gui_scripts` settings.


### Expected behavior

The warning should be shown when `setup.py` defines the `console_scripts` or `gui_scripts` entry point groups, but `scripts`/`gui_scripts` is not included in the `dynamic` key in `pyproject.toml`.


### How to Reproduce

Create `pyproject.toml`:

```toml
[project]
name = "testproj"
version = "0"

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
```

Create `setup.py`:

```python
from setuptools import setup

setup(
    entry_points={
        "console_scripts": [
            "foobar=foobar:main",
        ],
        "gui_scripts": [
            "bazquux=bazquux:main",
        ],
    },
)
```

Run `setup.py bdist_wheel`.


### Output

```console
running bdist_wheel
running build
C:\Users\dpb\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\setuptools\_distutils\cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` directly.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
        ********************************************************************************

!!
  self.initialize_options()
installing to build\bdist.win-amd64\wheel
running install
running install_egg_info
running egg_info
writing testproj.egg-info\PKG-INFO
writing dependency_links to testproj.egg-info\dependency_links.txt
writing entry points to testproj.egg-info\entry_points.txt
writing top-level names to testproj.egg-info\top_level.txt
reading manifest file 'testproj.egg-info\SOURCES.txt'
writing manifest file 'testproj.egg-info\SOURCES.txt'
Copying testproj.egg-info to build\bdist.win-amd64\wheel\.\testproj-0-py3.11.egg-info
running install_scripts
creating build\bdist.win-amd64\wheel\testproj-0.dist-info\WHEEL
creating 'dist\testproj-0-py3-none-any.whl' and adding 'build\bdist.win-amd64\wheel' to it
adding 'testproj-0.dist-info/METADATA'
adding 'testproj-0.dist-info/WHEEL'
adding 'testproj-0.dist-info/entry_points.txt'
adding 'testproj-0.dist-info/top_level.txt'
adding 'testproj-0.dist-info/RECORD'
removing build\bdist.win-amd64\wheel
```



Discussion:
Related: #3862.

Resolving patch:
diff --git a/setuptools/config/_apply_pyprojecttoml.py b/setuptools/config/_apply_pyprojecttoml.py
--- a/setuptools/config/_apply_pyprojecttoml.py
+++ b/setuptools/config/_apply_pyprojecttoml.py
@@ -296,6 +296,16 @@ def _get_previous_entrypoints(dist: "Distribution") -> Dict[str, list]:
     return {k: v for k, v in value.items() if k not in ignore}
 
 
+def _get_previous_scripts(dist: "Distribution") -> Optional[list]:
+    value = getattr(dist, "entry_points", None) or {}
+    return value.get("console_scripts")
+
+
+def _get_previous_gui_scripts(dist: "Distribution") -> Optional[list]:
+    value = getattr(dist, "entry_points", None) or {}
+    return value.get("gui_scripts")
+
+
 def _attrgetter(attr):
     """
     Similar to ``operator.attrgetter`` but returns None if ``attr`` is not found
@@ -371,6 +381,8 @@ def _acessor(obj):
     "classifiers": _attrgetter("metadata.classifiers"),
     "urls": _attrgetter("metadata.project_urls"),
     "entry-points": _get_previous_entrypoints,
+    "scripts": _get_previous_scripts,
+    "gui-scripts": _get_previous_gui_scripts,
     "dependencies": _some_attrgetter("_orig_install_requires", "install_requires"),
     "optional-dependencies": _some_attrgetter("_orig_extras_require", "extras_require"),
 }


Test patch:
diff --git a/setuptools/tests/config/test_apply_pyprojecttoml.py b/setuptools/tests/config/test_apply_pyprojecttoml.py
--- a/setuptools/tests/config/test_apply_pyprojecttoml.py
+++ b/setuptools/tests/config/test_apply_pyprojecttoml.py
@@ -330,6 +330,8 @@ def pyproject(self, tmp_path, dynamic, extra_content=""):
         [
             ("install_requires", "dependencies", ["six"]),
             ("classifiers", "classifiers", ["Private :: Classifier"]),
+            ("entry_points", "scripts", {"console_scripts": ["foobar=foobar:main"]}),
+            ("entry_points", "gui-scripts", {"gui_scripts": ["bazquux=bazquux:main"]}),
         ],
     )
     def test_not_listed_in_dynamic(self, tmp_path, attr, field, value):