From ddf31d74ef75ef68755591074fb3910ae89c7813 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 27 Nov 2025 16:41:18 +0100 Subject: [PATCH] build-system: function to simplify build modules with pip3 added --- CHANGELOG.md | 2 ++ Pmodules/libpbuild.bash | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5ee90e..e5548ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ (#1316) ### build system +* Function to simplify building modules with pip3 added. + (#1329) * pbuild::install_docfiles() is now obsolete. If called it exists with an error message. (#1327) diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index 2f2ceb4..e5ce846 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -485,7 +485,11 @@ pbuild::prep() { # create build directory mkdir -p "${BUILD_DIR}" } +pbuild::prep_pip3(){ + python3 -m venv "${PREFIX}" + source "${PREFIX}/bin/activate" +} ############################################################################### # # functions to configure the sources @@ -691,6 +695,27 @@ pbuild::pre_install() { pbuild::post_install() { : } +pbuild::post_install_pip3(){ + mkdir -p "${PREFIX}/.bin" + mv "${PREFIX}/bin/python3" "${PREFIX}/.bin" + rm -vf \ + "${PREFIX}"/bin/activate*\ + "${PREFIX}"/bin/python*\ + "${PREFIX}"/bin/pip\ + "${PREFIX}"/bin/pip3*\ + "${PREFIX}"/bin/normalizer + local -a scripts=() + if [[ -d "${PREFIX}/bin" ]]; then + scripts=( $(find "${PREFIX}/bin" -type f -exec grep -Il '^#!.*python' {} \;) ) + fi + if [[ -d "${PREFIX}/sbin" ]]; then + scripts+=( $(find "${PREFIX}/sbin" -type f -exec grep -Il '^#!.*python' {} \;) ) + fi + for script in "${scripts[@]}"; do + sed -i "1s|^#!.*|#!${PREFIX}/.bin/python3|" "${script}" + done +} + pbuild::install() { ${make} install || \ std::die 3 \