Skip to content

Commit

Permalink
Always run compileall module with -b option
Browse files Browse the repository at this point in the history
This was necessary for compatibility with Python 2.x versions of the
`compileall` module, which we no longer support.
  • Loading branch information
chrisnovakovic committed Oct 14, 2024
1 parent a60f461 commit b5b330b
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions build_defs/python.build_defs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ def python_library(name:str, srcs:list=[], resources:list=[], deps:list=[], visi
if srcs or resources:
cmd = '$TOOLS_ARCAT z -d -o ${OUTS} -i .'
if srcs:
# This is a bit of a hack, but rather annoying. We want to put bytecode in its 'legacy' location
# in python3 because zipimport doesn't look in __pycache__. Unfortunately the flag doesn't exist
# in python2 so we have to guess whether we should apply it or not.
bytecode_flag = '-b' if 'python3' in interpreter or 'pypy3' in interpreter else ''
compile_cmd = f'$TOOLS_INT -S -m compileall {bytecode_flag} -f $SRCS_SRCS'
compile_cmd = f'$TOOLS_INT -S -m compileall -b -f $SRCS_SRCS'
if strip:
cmd = ' && '.join([compile_cmd, 'rm -f $SRCS_SRCS', cmd])
else:
Expand Down

0 comments on commit b5b330b

Please sign in to comment.