Skip to content

Instantly share code, notes, and snippets.

@jtmoon79
Created January 21, 2022 06:31
Show Gist options
  • Save jtmoon79/779754ec5342166ecb1ce0a9e1fbbc32 to your computer and use it in GitHub Desktop.
Save jtmoon79/779754ec5342166ecb1ce0a9e1fbbc32 to your computer and use it in GitHub Desktop.
Python pip wrapper
#!/usr/bin/env bash
#
# wrap python pip commands with helpful but tedious-to-write options
#
set -e
set -u
cmd=${1-help}
shift
declare -a args=()
if [[ "${cmd}" == 'install' ]]; then
declare -a args=(
'--disable-pip-version-check'
'--no-python-version-warning'
)
elif [[ "${cmd}" == 'list' ]]; then
declare -a args=(
'--disable-pip-version-check'
'--no-python-version-warning'
)
fi
# https://github.com/pypa/pip/issues/7883
export PYTHON_KEYRING_BACKEND="keyring.backends.null.Keyring"
# https://stackoverflow.com/a/28002687/471376
export PYTHONWARNINGS="ignore:Unverified HTTPS request"
set -x
exec \
${PYTHON-python3} \
-m pip \
"${cmd}" \
"${args[@]}" \
"${@}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment