From: Stefano Rivera <stefanor@debian.org>
Date: Fri, 25 Mar 2022 18:21:36 -0400
Subject: Debian: Fix editable installs with setuptools < 60.0.1

Work-around a setuptools bug, where it failed to configure all necessary
substitution variables in easy_install.

Bug-setuptools: https://github.com/pypa/setuptools/issues/2938
Forwarded: not-needed
---
 lib-python/3/distutils/util.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib-python/3/distutils/util.py b/lib-python/3/distutils/util.py
index 2ce5c5b..4a96013 100644
--- a/lib-python/3/distutils/util.py
+++ b/lib-python/3/distutils/util.py
@@ -194,6 +194,15 @@ def subst_vars (s, local_vars):
     certain values: see 'check_environ()'.  Raise ValueError for any
     variables not found in either 'local_vars' or 'os.environ'.
     """
+
+    # Debian: hack around https://github.com/pypa/setuptools/issues/2938
+    # Fixed in setuptools 60.0.1
+    def _get_implementation():
+        if sys.implementation.name == 'pypy':
+            return 'PyPy'
+        return 'Python'
+    local_vars.setdefault('implementation_lower', _get_implementation().lower())
+
     check_environ()
     def _subst (match, local_vars=local_vars):
         var_name = match.group(1)
