| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,6 +34,11 @@ YUM_DNF=$(command -v dnf) | |||
| 34 | 34 | USER_MODE='--user' | |
| 35 | 35 | SUDO='' | |
| 36 | 36 | ||
| 37 | + #Old versions of pip default to pypi.python.org and fail to install anything | ||
| 38 | + PYPI_URL="https://pypi.org/simple" | ||
| 39 | + PIP_MIN_VER="10.0" | ||
| 40 | + PIP_BOOTSTRAP_URL="https://bootstrap.pypa.io/get-pip.py" | ||
| 41 | + | ||
| 37 | 42 | [[ -z "${GDB}" ]] | |
| 38 | 43 | BACKEND_GDB=$? | |
| 39 | 44 | [[ -z "${LLDB}" ]] | |
@@ -140,6 +145,36 @@ function install_packages { | |||
| 140 | 145 | install_yum | |
| 141 | 146 | } | |
| 142 | 147 | ||
| 148 | + function curl_get_pip { | ||
| 149 | + echo "Attempting to curl pip bootstrapt script from $PIP_BOOTSTRAP_URL" | ||
| 150 | + curl "$PIP_BOOTSTRAP_URL" | ${SUDO} ${LLDB_PYTHON} - --upgrade "$USER_MODE" || return $? | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + function ensure_pip { | ||
| 154 | + # Check if pip is installed already | ||
| 155 | + ${LLDB_PYTHON} -m pip --version >/dev/null 2>&1 | ||
| 156 | + if [ $? -ne 0 ]; | ||
| 157 | + then | ||
| 158 | + # If not, attempt to install it using ensurepip | ||
| 159 | + echo "Attempting to install pip using 'ensurepip'." | ||
| 160 | + ${SUDO} ${LLDB_PYTHON} -m ensurepip $USER_MODE || return $? | ||
| 161 | + fi | ||
| 162 | + # Some really old pip installations default to the old pypi.python.org, which no longer works. | ||
| 163 | + echo "Attempting to upgrade pip." | ||
| 164 | + ${SUDO} ${LLDB_PYTHON} -m pip install "pip>=$PIP_MIN_VER" $USER_MODE -U --index-url "$PYPI_URL" | ||
| 165 | + if [ $? != 0 ]; | ||
| 166 | + then | ||
| 167 | + # We may still fail here due to TLS incompatibility | ||
| 168 | + # TLS 1.x got turned off 2018-04-11 | ||
| 169 | + # https://status.python.org/incidents/hdx7w97m5hr8 | ||
| 170 | + # Curl may be new enough to support TLS 1.2, so try to curl the pip installer from pypa.io | ||
| 171 | + # It's able to download and install pip without TLS errors somehow | ||
| 172 | + echo "Failed to upgrade pip." | ||
| 173 | + echo "Attempting to fall back to installation via curl." | ||
| 174 | + curl_get_pip || return $? | ||
| 175 | + fi | ||
| 176 | + } | ||
| 177 | + | ||
| 143 | 178 | function get_lldb_python_exe { | |
| 144 | 179 | # Find the Python version used by LLDB | |
| 145 | 180 | local lldb_pyver=$(${LLDB} -Q -x -b --one-line 'script import platform; print(".".join(platform.python_version_tuple()[:2]))'|tail -1) | |
@@ -196,8 +231,9 @@ fi | |||
| 196 | 231 | ||
| 197 | 232 | if [ "${BACKEND_LLDB}" -eq 1 ]; then | |
| 198 | 233 | ||
| 199 | - LLDB_PYTHON=$(get_lldb_python_exe) | ||
| 200 | - ${LLDB_PYTHON} -m pip install --user --upgrade six | ||
| 234 | + LLDB_PYTHON=$(get_lldb_python_exe) || quit "Failed to locate python interpreter." 1 | ||
| 235 | + ensure_pip || quit "Failed to install pip." 1 | ||
| 236 | + ${LLDB_PYTHON} -m pip install --user --upgrade six || quit "Failed to install or upgrade 'six' python package." 1 | ||
| 201 | 237 | ||
| 202 | 238 | if [ -n "${VENV}" ]; then | |
| 203 | 239 | echo "Creating virtualenv..." | |
@@ -206,18 +242,18 @@ if [ "${BACKEND_LLDB}" -eq 1 ]; then | |||
| 206 | 242 | LLDB_PYTHON="${VENV}/bin/python" | |
| 207 | 243 | LLDB_SITE_PACKAGES=$(find "${VENV}" -name site-packages) | |
| 208 | 244 | elif [ -z "${USER_MODE}" ]; then | |
| 209 | - LLDB_SITE_PACKAGES=$(${LLDB} -Q -x -b --one-line 'script import site; print(site.getsitepackages()[0])'|tail -1) | ||
| 245 | + LLDB_SITE_PACKAGES=$(${LLDB} -Q -x -b --one-line 'script import site; print(site.getsitepackages()[0])'|tail -1) || quit "Failed to locate site-packages." 1 | ||
| 210 | 246 | else | |
| 211 | - LLDB_SITE_PACKAGES=$(${LLDB} -Q -x -b --one-line 'script import site; print(site.getusersitepackages())'|tail -1) | ||
| 247 | + LLDB_SITE_PACKAGES=$(${LLDB} -Q -x -b --one-line 'script import site; print(site.getusersitepackages())'|tail -1) || quit "Failed to locate site-packages." 1 | ||
| 212 | 248 | fi | |
| 213 | 249 | ||
| 214 | - install_packages | ||
| 250 | + install_packages || quit "Failed to install packages." 1 | ||
| 215 | 251 | ||
| 216 | 252 | if [ "$LLDB_SITE_PACKAGES" == "$GDB_SITE_PACKAGES" ]; then | |
| 217 | 253 | echo "Skipping installation for LLDB - same site-packages directory" | |
| 218 | 254 | else | |
| 219 | 255 | # Install Voltron and dependencies | |
| 220 | - ${SUDO} ${LLDB_PYTHON} -m pip install -U $USER_MODE $DEV_MODE . | ||
| 256 | + ${SUDO} ${LLDB_PYTHON} -m pip install -U $USER_MODE $DEV_MODE . || quit "Failed to install voltron." 1 | ||
| 221 | 257 | fi | |
| 222 | 258 | ||
| 223 | 259 | # Add Voltron to lldbinit | |
| Back | FazBrowse Home | New Git URL |
0 commit comments