From 9f29c97b80365e69fa9b4b85d1e056be05118c00 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Tue, 24 Jan 2023 12:27:58 -1000 Subject: [PATCH] imp: install: add support for installing python packages --- hledger-install/hledger-install.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/hledger-install/hledger-install.sh b/hledger-install/hledger-install.sh index 6066d715e..190999e71 100755 --- a/hledger-install/hledger-install.sh +++ b/hledger-install/hledger-install.sh @@ -873,7 +873,7 @@ quietly_run() { "$@" 2>/dev/null || true } -# Try to install the executables of the given haskell package(s) and versions, +# Try to install the executables of the given haskell package versions, # using stack or cabal, logging the commands, continuing on failure. # It's assumed that either a new-enough stack or cabal-install is already installed. # stack is preferred. @@ -890,6 +890,17 @@ try_install() { fi } +# Try to install the given python package versions, +# using pip, logging the commands, continuing on failure. +try_install_py() { + cd # ensure we install at user level, not in some project's env + if has_cmd pip ; then + try_info pip install --disable-pip-version-check -U "$@" $PIP_VERBOSITY + else + echo "Failed to install $@" + fi +} + # start # process command-line flags @@ -941,6 +952,7 @@ fi if [[ $VERBOSEFLAG ]]; then CABAL_VERBOSITY=1 # 0-3 STACK_VERBOSITY=info # silent, error, warn, info, debug + PIP_VERBOSITY=-v else CABAL_VERBOSITY=0 # info shows too many warnings, but error hides install plan failure details, @@ -949,7 +961,8 @@ else # Try error again. It looks much better, and it might have improved by now. # If there's trouble, they must rerun with --verbose. STACK_VERBOSITY=error - QUIET="true" + PIP_VERBOSITY=-q + QUIET=true fi date