From 5294f460bf252e63c0f4adf888d03450942989b2 Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Sun, 10 Mar 2024 22:41:51 +0000 Subject: [PATCH] macros: Sync with boulder-rs Signed-off-by: Ikey Doherty --- data/macros/actions/python.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/data/macros/actions/python.yml b/data/macros/actions/python.yml index 765763d257..be0b072be2 100644 --- a/data/macros/actions/python.yml +++ b/data/macros/actions/python.yml @@ -1,7 +1,7 @@ actions: # Perform python setup and build with the default options - - python: + - python_setup: command: | test -e ./setup.py || ( echo "%%python: The ./setup.py script could not be found" ; exit 1 ) python3 setup.py build @@ -31,3 +31,20 @@ actions: dependencies: - python - python-installer + + # Compile .pyc bytecode files from any miscellaneous .py files in the install directory. + # TODO: Investigate whether providing additional -opt1.pyc and -opt2.pyc from increasing + # the optimization level is worth it. Python itself has to be invoked with -O/-OO + # in order to use opt1/opt2 .pyc files. + - python_compile: + command: | + function python_compile() { + if [ -z "$1" ]; then + python -m compileall -q %(installroot) || exit 1 + else + python -m compileall -q $* || exit 1 + fi + } + python_compile + dependencies: + - python