armbian-next: Python tooling: use consolidated+hashed+cached pip base/pycache; don't pip during Dockerfile build, nor cli-requirements

- consolidate at `prepare_python_and_pip()`
- sanity check for Python version 3.9+ regardless of HOSTRELEASE
- TODO: pip vs sudo/root: need pip 22.2+ to curb warning, not doing it
This commit is contained in:
Ricardo Pardini
2023-01-13 04:37:30 +01:00
parent 350cf62ee0
commit 7beeae6219
7 changed files with 108 additions and 68 deletions

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash
function kernel_main_patching_python() {
prepare_pip_packages_for_python_tools
prepare_python_and_pip
# outer scope variables: kernel_drivers_patch_file kernel_drivers_patch_hash
@@ -11,8 +11,7 @@ function kernel_main_patching_python() {
# array with all parameters; will be auto-quoted by bash's @Q modifier below
declare -a params_quoted=(
"PYTHONUNBUFFERED=yes" # Python should not buffer output, so we can see it in real time.
"PYTHONPYCACHEPREFIX=${SRC}/cache/pycache" # Python should not use its own cache, but use our own.
"${PYTHON3_VARS[@]}" # Default vars, from prepare_python_and_pip
"LOG_DEBUG=${patch_debug}" # Logging level for python.
"SRC=${SRC}" # Armbian root
"OUTPUT=${temp_file_for_output}" # Output file for the python script.
@@ -44,11 +43,9 @@ function kernel_main_patching_python() {
"EXTRA_PATCH_HASHES_FIRST=${kernel_drivers_patch_hash}" # Is a space-separated list.
)
display_alert "Calling Python patching script" "for kernel" "info"
declare python3_binary_path
prepare_python3_binary_for_python_tools
# "raw_command" is only for logging purposes.
raw_command="[...shortened kernel...] ${python3_binary_path} ${SRC}/lib/tools/patching.py" \
run_host_command_logged env -i "${params_quoted[@]@Q}" "${python3_binary_path}" "${SRC}/lib/tools/patching.py"
raw_command="[...shortened kernel patching...] ${PYTHON3_INFO[BIN]} ${SRC}/lib/tools/patching.py" \
run_host_command_logged env -i "${params_quoted[@]@Q}" "${PYTHON3_INFO[BIN]}" "${SRC}/lib/tools/patching.py"
run_host_command_logged cat "${temp_file_for_output}"
# shellcheck disable=SC1090
source "${temp_file_for_output}" # SOURCE IT!

View File

@@ -1,13 +1,12 @@
function uboot_main_patching_python() {
prepare_pip_packages_for_python_tools
prepare_python_and_pip
# outer scope variable: uboot_work_dir
temp_file_for_output="$(mktemp)" # Get a temporary file for the output.
# array with all parameters; will be auto-quoted by bash's @Q modifier below
declare -a params_quoted=(
"PYTHONUNBUFFERED=yes" # Python should not buffer output, so we can see it in real time.
"PYTHONPYCACHEPREFIX=${SRC}/cache/pycache" # Python should not use its own cache, but use our own.
"${PYTHON3_VARS[@]}" # Default vars, from prepare_python_and_pip
"LOG_DEBUG=${SHOW_DEBUG}" # Logging level for python.
"SRC=${SRC}" # Armbian root
"OUTPUT=${temp_file_for_output}" # Output file for the python script.
@@ -30,11 +29,10 @@ function uboot_main_patching_python() {
"BRANCH_FOR_PATCHES=u-boot-${BRANCH}-${BOARD}" # When applying patches-to-git, use this branch.
)
display_alert "Calling Python patching script" "for u-boot target" "info"
declare python3_binary_path
prepare_python3_binary_for_python_tools
# "raw_command" is only for logging purposes.
raw_command="[...shortened u-boot...] ${python3_binary_path} ${SRC}/lib/tools/patching.py" \
run_host_command_logged env -i "${params_quoted[@]@Q}" "${python3_binary_path}" "${SRC}/lib/tools/patching.py"
raw_command="[...shortened u-boot patching...] ${PYTHON3_INFO[BIN]} ${SRC}/lib/tools/patching.py" \
run_host_command_logged env -i "${params_quoted[@]@Q}" "${PYTHON3_INFO[BIN]}" "${SRC}/lib/tools/patching.py"
run_host_command_logged cat "${temp_file_for_output}"
# shellcheck disable=SC1090
source "${temp_file_for_output}" # SOURCE IT!