From e793b1bc1aa5f44b67199a845c126e3ab459c8c6 Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" Date: Fri, 31 Jan 2025 01:06:55 +0000 Subject: unittests: Unbreak Python bytecompile tests with Xcode Python Apple sets sys.pycache_prefix to an user-wide cache folder, so it needs to be prepended to the root for the glob to work correctly. --- unittests/pythontests.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/unittests/pythontests.py b/unittests/pythontests.py index aaea906ea..96864ffd8 100644 --- a/unittests/pythontests.py +++ b/unittests/pythontests.py @@ -1,7 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 # Copyright 2016-2021 The Meson development team -import glob, os, pathlib, shutil, subprocess, unittest +import glob, os, pathlib, shutil, subprocess, sys, unittest from run_tests import ( Backend @@ -64,7 +64,12 @@ python = pymod.find_installation('python3', required: true) for file in files: realfile = os.path.join(root, file) if file.endswith('.py'): - cached = glob.glob(realfile+'?') + glob.glob(os.path.join(root, '__pycache__', os.path.splitext(file)[0] + '*.pyc')) + # FIXME: relpath must be adjusted for windows path behaviour + if hasattr(sys, "pycache_prefix"): + root = os.path.join(sys.pycache_prefix, os.path.relpath(root, '/')) + else: + root = os.path.join(root, '__pycache__') + cached = glob.glob(realfile+'?') + glob.glob(os.path.join(root, os.path.splitext(file)[0] + '*.pyc')) if py2 and cc.get_id() == 'msvc': # MSVC python installs python2/python3 into the same directory self.assertLength(cached, 4) -- cgit v1.2.3