config/functions: add Python bytecode/source code helper functions

This commit is contained in:
MilhouseVH 2019-10-24 22:51:28 +01:00
parent 59857855ac
commit fcfee6ff42

View File

@ -1046,6 +1046,22 @@ source_package() {
fi fi
} }
# arg1: file, or directory to recursively compile.
python_compile() {
local path="${1:-${INSTALL}/usr/lib/${PKG_PYTHON_VERSION}}"
${TOOLCHAIN}/bin/python3 -Wi -t -B ${TOOLCHAIN}/lib/${PKG_PYTHON_VERSION}/compileall.py -f -d "${path#${INSTALL}}" "${path}"
python_remove_source "${path}"
}
# arg1: file, or directory from which to recursively remove all py source code
python_remove_source() {
local path="${1:-${INSTALL}/usr/lib/${PKG_PYTHON_VERSION}}"
if [ -d "${path}" ]; then
find "${path}" -type f -name '*.py' -delete
else
rm -f "${path}"
fi
}
### KERNEL HELPERS ### ### KERNEL HELPERS ###
kernel_path() { kernel_path() {