aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--setuptools/command/easy_install.py6
-rw-r--r--setuptools/tests/test_easy_install.py6
2 files changed, 4 insertions, 8 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index a82b1655..15e46cfc 100644
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -2070,9 +2070,7 @@ class ScriptWriter:
gui apps.
"""
- try:
- from importlib.metadata import distribution # noqa: F401
-
+ if sys.version_info >= (3, 8):
template = textwrap.dedent(r"""
# EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r
__requires__ = %(spec)r
@@ -2086,7 +2084,7 @@ class ScriptWriter:
if entry_point.group == %(group)r and entry_point.name == %(name)r:
sys.exit(entry_point.load()())
""").lstrip() # noqa: E501
- except ImportError:
+ else:
template = textwrap.dedent(r"""
# EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r
__requires__ = %(spec)r
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py
index 58108db6..9aa2bd63 100644
--- a/setuptools/tests/test_easy_install.py
+++ b/setuptools/tests/test_easy_install.py
@@ -71,9 +71,7 @@ class TestEasyInstallTest:
def test_get_script_args(self):
header = ei.CommandSpec.best().from_environment().as_header()
- try:
- from importlib.metadata import distribution # noqa: F401
-
+ if sys.version_info >= (3, 8):
expected = header + DALS(r"""
# EASY-INSTALL-ENTRY-SCRIPT: 'spec','console_scripts','name'
__requires__ = 'spec'
@@ -87,7 +85,7 @@ class TestEasyInstallTest:
if entry_point.group == 'console_scripts' and entry_point.name == 'name':
sys.exit(entry_point.load()())
""") # noqa: E501
- except ImportError:
+ else:
expected = header + DALS(r"""
# EASY-INSTALL-ENTRY-SCRIPT: 'spec','console_scripts','name'
__requires__ = 'spec'