From 9c356758025e91de74e23170b95253818c21192e Mon Sep 17 00:00:00 2001 From: "Schneider, Bjoern /tesa scribos GmbH HDB" Date: Tue, 3 Mar 2020 21:20:31 +0100 Subject: [PATCH 1/2] Resolved issue if a local Python source is referenced Also added the PIP_OPTIONS to the pip upgrade call; otherwise the upgrade might fail if the user needs a special configuration to reach the package index (e.g. coproprate proxy...). --- linuxdeploy-plugin-python.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/linuxdeploy-plugin-python.sh b/linuxdeploy-plugin-python.sh index 03d0921..027ff64 100755 --- a/linuxdeploy-plugin-python.sh +++ b/linuxdeploy-plugin-python.sh @@ -111,16 +111,22 @@ cd "${PYTHON_BUILD_DIR}" # Install Python from sources -source_dir=$(basename "${PYTHON_SOURCE}") +source_file=$(basename "${PYTHON_SOURCE}") if [[ "${PYTHON_SOURCE}" == http* ]] || [[ "${PYTHON_SOURCE}" == ftp* ]]; then wget -c --no-check-certificate "${PYTHON_SOURCE}" else - cp -r "${source_dir}" "." + cp -r "${PYTHON_SOURCE}" "." fi -if [[ "${source_dir}" == *.tgz ]] || [[ "${source_dir}" == *.tar.gz ]]; then - filename="${source_dir%.*}" - [[ -f $filename ]] || tar -xzf "${source_dir}" - source_dir="$filename" +if [[ "${source_file}" == *.tgz ]] || [[ "${source_file}" == *.tar.gz ]]; then + if [[ "${source_file}" == *.tgz ]]; then + dirname="${source_file%.*}" + else + dirname="${source_file%.*.*}" + fi + [[ -f $dirname ]] || tar -xzf "${source_file}" + source_dir="$dirname" +else + source_dir="$source_file" fi prefix="usr/python" @@ -133,7 +139,7 @@ HOME="${PYTHON_BUILD_DIR}" make -j"$NPROC" DESTDIR="$APPDIR" install if [ ! -z "${PIP_REQUIREMENTS}" ]; then cd "${APPDIR}/${prefix}/bin" pythons=( "python"?"."? ) - HOME="${PYTHON_BUILD_DIR}" PYTHONHOME=$(readlink -f ${PWD}/..) ./${pythons[0]} -m pip install --upgrade pip + HOME="${PYTHON_BUILD_DIR}" PYTHONHOME=$(readlink -f ${PWD}/..) ./${pythons[0]} -m pip install ${PIP_OPTIONS} --upgrade pip HOME="${PYTHON_BUILD_DIR}" PYTHONHOME=$(readlink -f ${PWD}/..) ./${pythons[0]} -m pip install ${PIP_OPTIONS} ${PIP_REQUIREMENTS} fi From dcd8f14ba5007fe45f0b95174720bef189b58d87 Mon Sep 17 00:00:00 2001 From: "Schneider, Bjoern /tesa scribos GmbH HDB" Date: Tue, 3 Mar 2020 21:32:07 +0100 Subject: [PATCH 2/2] Allow relative PYTHON_SOURCE path --- linuxdeploy-plugin-python.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/linuxdeploy-plugin-python.sh b/linuxdeploy-plugin-python.sh index 027ff64..14997b9 100755 --- a/linuxdeploy-plugin-python.sh +++ b/linuxdeploy-plugin-python.sh @@ -106,6 +106,13 @@ else mkdir -p "${PYTHON_BUILD_DIR}" fi +# check if the given sources are a local file or directory; if yes, +# "save" the full path. It might've been given relative to the current +# directory. +if [ -e "${PYTHON_SOURCE}" ]; then + PYTHON_SOURCE=$( readlink -f "${PYTHON_SOURCE}" ) +fi + cd "${PYTHON_BUILD_DIR}"