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