Skip to content

Commit a2b490b

Browse files
Disable Python compilation cache during build (#7057)
* Disable Python compilation cache during build * More pythonic check for none
1 parent 7c2e4f2 commit a2b490b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

scripts/mk_util.py

+10
Original file line numberDiff line numberDiff line change
@@ -2994,9 +2994,19 @@ def cp_z3py_to_build():
29942994
for f in files:
29952995
if f.endswith('.pyc'):
29962996
rmf(os.path.join(root, f))
2997+
# We do not want a second copy of the compiled files in the system-wide cache,
2998+
# so we disable it temporarily. This is an issue with recent versions of MacOS
2999+
# where XCode's Python has a cache, but the build scripts don't have access to
3000+
# it (e.g. during OPAM package installation).
3001+
have_cache = hasattr(sys, 'pycache_prefix') and sys.pycache_prefix is not None
3002+
if have_cache:
3003+
pycache_prefix_before = sys.pycache_prefix
3004+
sys.pycache_prefix = None
29973005
# Compile Z3Py files
29983006
if compileall.compile_dir(z3py_src, force=1) != 1:
29993007
raise MKException("failed to compile Z3Py sources")
3008+
if have_cache:
3009+
sys.pycache_prefix = pycache_prefix_before
30003010
if is_verbose:
30013011
print("Generated python bytecode")
30023012
# Copy sources to build

0 commit comments

Comments
 (0)