summaryrefslogtreecommitdiff
path: root/unittests/pythontests.py
diff options
context:
space:
mode:
authorL. E. Segovia <amy@amyspark.me>2025-01-31 01:06:55 +0000
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2025-02-04 08:16:23 +0530
commite793b1bc1aa5f44b67199a845c126e3ab459c8c6 (patch)
tree93420f4bb3e081a41287195e81137d178e69bc23 /unittests/pythontests.py
parentf75e45887c86c8c73a38f387bd93467dda36df3c (diff)
downloadmeson-e793b1bc1aa5f44b67199a845c126e3ab459c8c6.tar.gz
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.
Diffstat (limited to 'unittests/pythontests.py')
-rw-r--r--unittests/pythontests.py9
1 files 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)