From: Debian Python Team <team+python@tracker.debian.org>
Date: Sat, 4 Nov 2023 10:34:21 +0200
Subject: Write a pydistutils configuration file before executing pip

This avoids tripping over Debian's posix_prefix default installation
scheme

Forwarded: not-needed

--- a/test/test.py
+++ b/test/test.py
@@ -1334,6 +1334,9 @@
 class TestBashZshGlobalBase(TestBashZshBase):
     install_cmd = 'eval "$(activate-global-python-argcomplete --dest=-)"'
 
+    def tearDown(self):
+        self.sh.run_command('rm -f ~/.pydistutils.cfg')
+
     def test_redirection_completion(self):
         with TempDir(prefix="test_dir_py", dir="."):
             self.sh.run_command("cd " + os.getcwd())
@@ -1382,6 +1385,7 @@
             self.sh.run_command("cd " + os.getcwd())
             self.sh.run_command("export PATH=$PATH:./bin")
             self.sh.run_command("export PYTHONPATH=.:$PYTHONPATH")
+            self.sh.run_command('echo -e "[install]\nprefix=" > ~/.pydistutils.cfg')
             test_package = os.path.join(TEST_DIR, "test_package")
             command = "pip3 install {} --target .".format(test_package)
             if not wheel:
