From 75346298be961bd29bd1a5fcf8e5356ec91095e9 Mon Sep 17 00:00:00 2001 From: Jeremy Kloth Date: Tue, 17 May 2022 17:00:46 -0600 Subject: [PATCH] gh-92906: Enable test_cppext on Windows --- Lib/test/test_cppext.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_cppext.py b/Lib/test/test_cppext.py index 9ed90616b0eab5b..b568790a743580b 100644 --- a/Lib/test/test_cppext.py +++ b/Lib/test/test_cppext.py @@ -16,14 +16,16 @@ @support.requires_subprocess() class TestCPPExt(unittest.TestCase): - # With MSVC, the linker fails with: cannot open file 'python311.lib' - # https://github.com/python/cpython/pull/32175#issuecomment-1111175897 - @unittest.skipIf(MS_WINDOWS, 'test fails on Windows') # the test uses venv+pip: skip if it's not available @support.requires_venv_with_pip() def test_build(self): # Build in a temporary directory - with os_helper.temp_cwd(): + with os_helper.temp_cwd(), os_helper.EnvironmentVarGuard() as env: + # Recent setuptools versions have a bug that prevents being + # used to compile from a source build virtual environment. + # [BUG](https://github.com/pypa/setuptools/issues/3325) + # The stdlib distutils does not have this problem. + env['SETUPTOOLS_USE_DISTUTILS'] = 'stdlib' self._test_build() def _test_build(self): @@ -37,9 +39,7 @@ def _test_build(self): subprocess.run(cmd, check=True) # Get the Python executable of the venv - python_exe = 'python' - if sys.executable.endswith('.exe'): - python_exe += '.exe' + python_exe = os.path.basename(sys.executable) if MS_WINDOWS: python = os.path.join(venv_dir, 'Scripts', python_exe) else: @@ -56,7 +56,8 @@ def _test_build(self): if proc.returncode: print(proc.stdout, end='') self.fail(f"Build failed with exit code {proc.returncode}") - + elif support.verbose: + print(proc.stdout, end='') if __name__ == "__main__": unittest.main()