Skip to content

Commit 46976ce

Browse files
authored
Merge pull request #23 from brogon/local_file_issue_and_pip_options
Local file issue and pip options
2 parents 8b48c09 + dcd8f14 commit 46976ce

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

linuxdeploy-plugin-python.sh

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,34 @@ else
106106
mkdir -p "${PYTHON_BUILD_DIR}"
107107
fi
108108

109+
# check if the given sources are a local file or directory; if yes,
110+
# "save" the full path. It might've been given relative to the current
111+
# directory.
112+
if [ -e "${PYTHON_SOURCE}" ]; then
113+
PYTHON_SOURCE=$( readlink -f "${PYTHON_SOURCE}" )
114+
fi
115+
109116
cd "${PYTHON_BUILD_DIR}"
110117

111118

112119

113120
# Install Python from sources
114-
source_dir=$(basename "${PYTHON_SOURCE}")
121+
source_file=$(basename "${PYTHON_SOURCE}")
115122
if [[ "${PYTHON_SOURCE}" == http* ]] || [[ "${PYTHON_SOURCE}" == ftp* ]]; then
116123
wget -c --no-check-certificate "${PYTHON_SOURCE}"
117124
else
118-
cp -r "${source_dir}" "."
125+
cp -r "${PYTHON_SOURCE}" "."
119126
fi
120-
if [[ "${source_dir}" == *.tgz ]] || [[ "${source_dir}" == *.tar.gz ]]; then
121-
filename="${source_dir%.*}"
122-
[[ -f $filename ]] || tar -xzf "${source_dir}"
123-
source_dir="$filename"
127+
if [[ "${source_file}" == *.tgz ]] || [[ "${source_file}" == *.tar.gz ]]; then
128+
if [[ "${source_file}" == *.tgz ]]; then
129+
dirname="${source_file%.*}"
130+
else
131+
dirname="${source_file%.*.*}"
132+
fi
133+
[[ -f $dirname ]] || tar -xzf "${source_file}"
134+
source_dir="$dirname"
135+
else
136+
source_dir="$source_file"
124137
fi
125138

126139
prefix="usr/python"
@@ -133,7 +146,7 @@ HOME="${PYTHON_BUILD_DIR}" make -j"$NPROC" DESTDIR="$APPDIR" install
133146
if [ ! -z "${PIP_REQUIREMENTS}" ]; then
134147
cd "${APPDIR}/${prefix}/bin"
135148
pythons=( "python"?"."? )
136-
HOME="${PYTHON_BUILD_DIR}" PYTHONHOME=$(readlink -f ${PWD}/..) ./${pythons[0]} -m pip install --upgrade pip
149+
HOME="${PYTHON_BUILD_DIR}" PYTHONHOME=$(readlink -f ${PWD}/..) ./${pythons[0]} -m pip install ${PIP_OPTIONS} --upgrade pip
137150
HOME="${PYTHON_BUILD_DIR}" PYTHONHOME=$(readlink -f ${PWD}/..) ./${pythons[0]} -m pip install ${PIP_OPTIONS} ${PIP_REQUIREMENTS}
138151
fi
139152

0 commit comments

Comments
 (0)