We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[BUG] vendored importlib.metadata of setuptools 60.9.0 fails with 'PathDistribution' object has no attribute '_normalized_name'
### setuptools version

setuptools==60.9.0

### Python version

3.7.1

### OS

Linux

### Additional environment information

Pip freeze

```
argcomplete==1.12.3
colorlog==6.6.0
distlib==0.3.4
filelock==3.4.2
importlib-metadata==4.2.0
nox==2022.1.7
packaging==21.3
pip==22.0.3
platformdirs==2.5.0
py==1.11.0
pyparsing==3.0.7
setuptools==60.9.0
six==1.16.0
typing_extensions==4.1.1
virtualenv==20.13.1
wheel==0.37.1
zipp==3.7.0
```

### Description

If I use the below python dependencies (mainly virtualenv, setuptools and importlib.metadata), setuptools fails with an error.

It works fine with the previous version of setuptools and newer versions of importlib.metadata. It seems like, that the current vendored version of importlib.metadata is not compatible with my environment. 

### Expected behavior

It should work fine

### How to Reproduce

1. Install the above dependencies
2. Run `nox -s`

### Output

```console
Traceback (most recent call last):
  File "/usr/lib64/python3.7/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib64/python3.7/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/lib64/python3.7/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/__init__.py", line 3, in <module>
    from .run import cli_run, session_via_cli
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/run/__init__.py", line 14, in <module>
    from .plugin.creators import CreatorSelector
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/run/plugin/creators.py", line 6, in <module>
    from virtualenv.create.via_global_ref.builtin.builtin_way import VirtualenvBuiltin
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/create/via_global_ref/builtin/builtin_way.py", line 7, in <module>
    from virtualenv.create.creator import Creator
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/create/creator.py", line 15, in <module>
    from virtualenv.discovery.cached_py_info import LogCmd
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/discovery/cached_py_info.py", line 23, in <module>
    _CACHE[Path(sys.executable)] = PythonInfo()
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/discovery/py_info.py", line 86, in __init__
    self.distutils_install = {u(k): u(v) for k, v in self._distutils_install().items()}
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/discovery/py_info.py", line 152, in _distutils_install
    d = dist.Distribution({"script_args": "--no-user-cfg"})  # conf files not parsed so they do not hijack paths
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/setuptools/dist.py", line 456, in __init__
    for ep in metadata.entry_points(group='distutils.setup_keywords'):
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/setuptools/_vendor/importlib_metadata/__init__.py", line 1003, in entry_points
    return SelectableGroups.load(eps).select(**params)
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/setuptools/_vendor/importlib_metadata/__init__.py", line 453, in load
    ordered = sorted(eps, key=by_group)
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/setuptools/_vendor/importlib_metadata/__init__.py", line 1001, in <genexpr>
    dist.entry_points for dist in unique(distributions())
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/setuptools/_vendor/importlib_metadata/_itertools.py", line 16, in unique_everseen
    k = key(element)
AttributeError: 'PathDistribution' object has no attribute '_normalized_name'
```
[BUG] vendored importlib.metadata of setuptools 60.9.0 fails with 'PathDistribution' object has no attribute '_normalized_name'
### setuptools version

setuptools==60.9.0

### Python version

3.7.1

### OS

Linux

### Additional environment information

Pip freeze

```
argcomplete==1.12.3
colorlog==6.6.0
distlib==0.3.4
filelock==3.4.2
importlib-metadata==4.2.0
nox==2022.1.7
packaging==21.3
pip==22.0.3
platformdirs==2.5.0
py==1.11.0
pyparsing==3.0.7
setuptools==60.9.0
six==1.16.0
typing_extensions==4.1.1
virtualenv==20.13.1
wheel==0.37.1
zipp==3.7.0
```

### Description

If I use the below python dependencies (mainly virtualenv, setuptools and importlib.metadata), setuptools fails with an error.

It works fine with the previous version of setuptools and newer versions of importlib.metadata. It seems like, that the current vendored version of importlib.metadata is not compatible with my environment. 

### Expected behavior

It should work fine

### How to Reproduce

1. Install the above dependencies
2. Run `nox -s`

### Output

```console
Traceback (most recent call last):
  File "/usr/lib64/python3.7/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib64/python3.7/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/lib64/python3.7/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/__init__.py", line 3, in <module>
    from .run import cli_run, session_via_cli
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/run/__init__.py", line 14, in <module>
    from .plugin.creators import CreatorSelector
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/run/plugin/creators.py", line 6, in <module>
    from virtualenv.create.via_global_ref.builtin.builtin_way import VirtualenvBuiltin
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/create/via_global_ref/builtin/builtin_way.py", line 7, in <module>
    from virtualenv.create.creator import Creator
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/create/creator.py", line 15, in <module>
    from virtualenv.discovery.cached_py_info import LogCmd
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/discovery/cached_py_info.py", line 23, in <module>
    _CACHE[Path(sys.executable)] = PythonInfo()
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/discovery/py_info.py", line 86, in __init__
    self.distutils_install = {u(k): u(v) for k, v in self._distutils_install().items()}
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/discovery/py_info.py", line 152, in _distutils_install
    d = dist.Distribution({"script_args": "--no-user-cfg"})  # conf files not parsed so they do not hijack paths
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/setuptools/dist.py", line 456, in __init__
    for ep in metadata.entry_points(group='distutils.setup_keywords'):
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/setuptools/_vendor/importlib_metadata/__init__.py", line 1003, in entry_points
    return SelectableGroups.load(eps).select(**params)
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/setuptools/_vendor/importlib_metadata/__init__.py", line 453, in load
    ordered = sorted(eps, key=by_group)
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/setuptools/_vendor/importlib_metadata/__init__.py", line 1001, in <genexpr>
    dist.entry_points for dist in unique(distributions())
  File "/root/git/empty_test/venv/lib/python3.7/site-packages/setuptools/_vendor/importlib_metadata/_itertools.py", line 16, in unique_everseen
    k = key(element)
AttributeError: 'PathDistribution' object has no attribute '_normalized_name'
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `setuptools/_importlib.py`
Content:
```
1 import sys
2 
3 
4 if sys.version_info < (3, 10):
5     from setuptools.extern import importlib_metadata as metadata
6 else:
7     import importlib.metadata as metadata  # noqa: F401
8 
9 
10 if sys.version_info < (3, 9):
11     from setuptools.extern import importlib_resources as resources
12 else:
13     import importlib.resources as resources  # noqa: F401
14
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/setuptools/_importlib.py b/setuptools/_importlib.py
--- a/setuptools/_importlib.py
+++ b/setuptools/_importlib.py
@@ -1,8 +1,31 @@
 import sys
 
 
+def disable_importlib_metadata_finder(metadata):
+    """
+    Ensure importlib_metadata doesn't provide older, incompatible
+    Distributions.
+
+    Workaround for #3102.
+    """
+    try:
+        import importlib_metadata
+    except ImportError:
+        return
+    if importlib_metadata is metadata:
+        return
+    to_remove = [
+        ob
+        for ob in sys.meta_path
+        if isinstance(ob, importlib_metadata.MetadataPathFinder)
+    ]
+    for item in to_remove:
+        sys.meta_path.remove(item)
+
+
 if sys.version_info < (3, 10):
     from setuptools.extern import importlib_metadata as metadata
+    disable_importlib_metadata_finder(metadata)
 else:
     import importlib.metadata as metadata  # noqa: F401

{"golden_diff": "diff --git a/setuptools/_importlib.py b/setuptools/_importlib.py\n--- a/setuptools/_importlib.py\n+++ b/setuptools/_importlib.py\n@@ -1,8 +1,31 @@\n import sys\n \n \n+def disable_importlib_metadata_finder(metadata):\n+    \"\"\"\n+    Ensure importlib_metadata doesn't provide older, incompatible\n+    Distributions.\n+\n+    Workaround for #3102.\n+    \"\"\"\n+    try:\n+        import importlib_metadata\n+    except ImportError:\n+        return\n+    if importlib_metadata is metadata:\n+        return\n+    to_remove = [\n+        ob\n+        for ob in sys.meta_path\n+        if isinstance(ob, importlib_metadata.MetadataPathFinder)\n+    ]\n+    for item in to_remove:\n+        sys.meta_path.remove(item)\n+\n+\n if sys.version_info < (3, 10):\n     from setuptools.extern import importlib_metadata as metadata\n+    disable_importlib_metadata_finder(metadata)\n else:\n     import importlib.metadata as metadata  # noqa: F401\n", "issue": "[BUG] vendored importlib.metadata of setuptools 60.9.0 fails with 'PathDistribution' object has no attribute '_normalized_name'\n### setuptools version\n\nsetuptools==60.9.0\n\n### Python version\n\n3.7.1\n\n### OS\n\nLinux\n\n### Additional environment information\n\nPip freeze\r\n\r\n```\r\nargcomplete==1.12.3\r\ncolorlog==6.6.0\r\ndistlib==0.3.4\r\nfilelock==3.4.2\r\nimportlib-metadata==4.2.0\r\nnox==2022.1.7\r\npackaging==21.3\r\npip==22.0.3\r\nplatformdirs==2.5.0\r\npy==1.11.0\r\npyparsing==3.0.7\r\nsetuptools==60.9.0\r\nsix==1.16.0\r\ntyping_extensions==4.1.1\r\nvirtualenv==20.13.1\r\nwheel==0.37.1\r\nzipp==3.7.0\r\n```\n\n### Description\n\nIf I use the below python dependencies (mainly virtualenv, setuptools and importlib.metadata), setuptools fails with an error.\r\n\r\nIt works fine with the previous version of setuptools and newer versions of importlib.metadata. It seems like, that the current vendored version of importlib.metadata is not compatible with my environment. \n\n### Expected behavior\n\nIt should work fine\n\n### How to Reproduce\n\n1. Install the above dependencies\r\n2. Run `nox -s`\n\n### Output\n\n```console\r\nTraceback (most recent call last):\r\n  File \"/usr/lib64/python3.7/runpy.py\", line 183, in _run_module_as_main\r\n    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)\r\n  File \"/usr/lib64/python3.7/runpy.py\", line 142, in _get_module_details\r\n    return _get_module_details(pkg_main_name, error)\r\n  File \"/usr/lib64/python3.7/runpy.py\", line 109, in _get_module_details\r\n    __import__(pkg_name)\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/__init__.py\", line 3, in <module>\r\n    from .run import cli_run, session_via_cli\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/run/__init__.py\", line 14, in <module>\r\n    from .plugin.creators import CreatorSelector\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/run/plugin/creators.py\", line 6, in <module>\r\n    from virtualenv.create.via_global_ref.builtin.builtin_way import VirtualenvBuiltin\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/create/via_global_ref/builtin/builtin_way.py\", line 7, in <module>\r\n    from virtualenv.create.creator import Creator\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/create/creator.py\", line 15, in <module>\r\n    from virtualenv.discovery.cached_py_info import LogCmd\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/discovery/cached_py_info.py\", line 23, in <module>\r\n    _CACHE[Path(sys.executable)] = PythonInfo()\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/discovery/py_info.py\", line 86, in __init__\r\n    self.distutils_install = {u(k): u(v) for k, v in self._distutils_install().items()}\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/discovery/py_info.py\", line 152, in _distutils_install\r\n    d = dist.Distribution({\"script_args\": \"--no-user-cfg\"})  # conf files not parsed so they do not hijack paths\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/setuptools/dist.py\", line 456, in __init__\r\n    for ep in metadata.entry_points(group='distutils.setup_keywords'):\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/setuptools/_vendor/importlib_metadata/__init__.py\", line 1003, in entry_points\r\n    return SelectableGroups.load(eps).select(**params)\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/setuptools/_vendor/importlib_metadata/__init__.py\", line 453, in load\r\n    ordered = sorted(eps, key=by_group)\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/setuptools/_vendor/importlib_metadata/__init__.py\", line 1001, in <genexpr>\r\n    dist.entry_points for dist in unique(distributions())\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/setuptools/_vendor/importlib_metadata/_itertools.py\", line 16, in unique_everseen\r\n    k = key(element)\r\nAttributeError: 'PathDistribution' object has no attribute '_normalized_name'\r\n```\n[BUG] vendored importlib.metadata of setuptools 60.9.0 fails with 'PathDistribution' object has no attribute '_normalized_name'\n### setuptools version\n\nsetuptools==60.9.0\n\n### Python version\n\n3.7.1\n\n### OS\n\nLinux\n\n### Additional environment information\n\nPip freeze\r\n\r\n```\r\nargcomplete==1.12.3\r\ncolorlog==6.6.0\r\ndistlib==0.3.4\r\nfilelock==3.4.2\r\nimportlib-metadata==4.2.0\r\nnox==2022.1.7\r\npackaging==21.3\r\npip==22.0.3\r\nplatformdirs==2.5.0\r\npy==1.11.0\r\npyparsing==3.0.7\r\nsetuptools==60.9.0\r\nsix==1.16.0\r\ntyping_extensions==4.1.1\r\nvirtualenv==20.13.1\r\nwheel==0.37.1\r\nzipp==3.7.0\r\n```\n\n### Description\n\nIf I use the below python dependencies (mainly virtualenv, setuptools and importlib.metadata), setuptools fails with an error.\r\n\r\nIt works fine with the previous version of setuptools and newer versions of importlib.metadata. It seems like, that the current vendored version of importlib.metadata is not compatible with my environment. \n\n### Expected behavior\n\nIt should work fine\n\n### How to Reproduce\n\n1. Install the above dependencies\r\n2. Run `nox -s`\n\n### Output\n\n```console\r\nTraceback (most recent call last):\r\n  File \"/usr/lib64/python3.7/runpy.py\", line 183, in _run_module_as_main\r\n    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)\r\n  File \"/usr/lib64/python3.7/runpy.py\", line 142, in _get_module_details\r\n    return _get_module_details(pkg_main_name, error)\r\n  File \"/usr/lib64/python3.7/runpy.py\", line 109, in _get_module_details\r\n    __import__(pkg_name)\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/__init__.py\", line 3, in <module>\r\n    from .run import cli_run, session_via_cli\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/run/__init__.py\", line 14, in <module>\r\n    from .plugin.creators import CreatorSelector\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/run/plugin/creators.py\", line 6, in <module>\r\n    from virtualenv.create.via_global_ref.builtin.builtin_way import VirtualenvBuiltin\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/create/via_global_ref/builtin/builtin_way.py\", line 7, in <module>\r\n    from virtualenv.create.creator import Creator\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/create/creator.py\", line 15, in <module>\r\n    from virtualenv.discovery.cached_py_info import LogCmd\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/discovery/cached_py_info.py\", line 23, in <module>\r\n    _CACHE[Path(sys.executable)] = PythonInfo()\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/discovery/py_info.py\", line 86, in __init__\r\n    self.distutils_install = {u(k): u(v) for k, v in self._distutils_install().items()}\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/virtualenv/discovery/py_info.py\", line 152, in _distutils_install\r\n    d = dist.Distribution({\"script_args\": \"--no-user-cfg\"})  # conf files not parsed so they do not hijack paths\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/setuptools/dist.py\", line 456, in __init__\r\n    for ep in metadata.entry_points(group='distutils.setup_keywords'):\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/setuptools/_vendor/importlib_metadata/__init__.py\", line 1003, in entry_points\r\n    return SelectableGroups.load(eps).select(**params)\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/setuptools/_vendor/importlib_metadata/__init__.py\", line 453, in load\r\n    ordered = sorted(eps, key=by_group)\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/setuptools/_vendor/importlib_metadata/__init__.py\", line 1001, in <genexpr>\r\n    dist.entry_points for dist in unique(distributions())\r\n  File \"/root/git/empty_test/venv/lib/python3.7/site-packages/setuptools/_vendor/importlib_metadata/_itertools.py\", line 16, in unique_everseen\r\n    k = key(element)\r\nAttributeError: 'PathDistribution' object has no attribute '_normalized_name'\r\n```\n", "before_files": [{"content": "import sys\n\n\nif sys.version_info < (3, 10):\n    from setuptools.extern import importlib_metadata as metadata\nelse:\n    import importlib.metadata as metadata  # noqa: F401\n\n\nif sys.version_info < (3, 9):\n    from setuptools.extern import importlib_resources as resources\nelse:\n    import importlib.resources as resources  # noqa: F401\n", "path": "setuptools/_importlib.py"}], "after_files": [{"content": "import sys\n\n\ndef disable_importlib_metadata_finder(metadata):\n    \"\"\"\n    Ensure importlib_metadata doesn't provide older, incompatible\n    Distributions.\n\n    Workaround for #3102.\n    \"\"\"\n    try:\n        import importlib_metadata\n    except ImportError:\n        return\n    if importlib_metadata is metadata:\n        return\n    to_remove = [\n        ob\n        for ob in sys.meta_path\n        if isinstance(ob, importlib_metadata.MetadataPathFinder)\n    ]\n    for item in to_remove:\n        sys.meta_path.remove(item)\n\n\nif sys.version_info < (3, 10):\n    from setuptools.extern import importlib_metadata as metadata\n    disable_importlib_metadata_finder(metadata)\nelse:\n    import importlib.metadata as metadata  # noqa: F401\n\n\nif sys.version_info < (3, 9):\n    from setuptools.extern import importlib_resources as resources\nelse:\n    import importlib.resources as resources  # noqa: F401\n", "path": "setuptools/_importlib.py"}]}