From b86949a91b27a03461e991c4606084691bf254c3 Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Sun, 22 Dec 2024 13:45:24 +0100
Subject: [PATCH 119/N] mingw_smoketests: build extension in a venv

ensurepip no longer works since we implement PEP 668, so do
everything in a venv.
---
 mingw_smoketests.py | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/mingw_smoketests.py b/mingw_smoketests.py
index 9ad32b3..5af2764 100644
--- a/mingw_smoketests.py
+++ b/mingw_smoketests.py
@@ -287,10 +287,14 @@ class Tests(unittest.TestCase):
         import sys
         import subprocess
         import textwrap
+        import venv
         from pathlib import Path
 
         with tempfile.TemporaryDirectory() as tmppro:
-            subprocess.check_call([sys.executable, "-m", "ensurepip", "--user"])
+            builder = venv.EnvBuilder(with_pip=True)
+            builder.create(tmppro)
+            venv_exe = os.path.join(tmppro, "bin", os.path.basename(sys.executable))
+
             with Path(tmppro, "setup.py").open("w") as f:
                 f.write(
                     textwrap.dedent(
@@ -342,20 +346,11 @@ class Tests(unittest.TestCase):
                     )
                 )
             subprocess.check_call(
-                [sys.executable, "-c", "import struct"],
-            )
-            subprocess.check_call(
-                [
-                    sys.executable,
-                    "-m",
-                    "pip",
-                    "install",
-                    "wheel",
-                ],
+                [venv_exe, "-c", "import struct"],
             )
             subprocess.check_call(
                 [
-                    sys.executable,
+                    venv_exe,
                     "-m",
                     "pip",
                     "install",
@@ -363,7 +358,7 @@ class Tests(unittest.TestCase):
                 ],
             )
             subprocess.check_call(
-                [sys.executable, "-c", "import cwrapper"],
+                [venv_exe, "-c", "import cwrapper"],
             )
 
 
