diff --git a/config/functions b/config/functions index cbd44b4dd4..e77c5a59eb 100644 --- a/config/functions +++ b/config/functions @@ -1046,6 +1046,22 @@ source_package() { 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_path() {