From 1e0b3f91f6dffad6bfc262528c14bf459c6a63c8 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 15 Sep 2023 08:32:30 +0200 Subject: [PATCH] refinements to `build-reelase.sh` - use `echo` where feasible to avoid explicit newlines - use `function` syntax out of habit - deduplicate release invocation - make `venv` based invocation less verbose - make help-text in non-venv more prominent --- build-release.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/build-release.sh b/build-release.sh index cbf0e91a9..5840e4472 100755 --- a/build-release.sh +++ b/build-release.sh @@ -5,18 +5,22 @@ set -eEu +function release_with() { + $1 -m build --sdist --wheel +} + if test -n "${VIRTUAL_ENV:-}"; then deps=(build twine) # Install twine along with build, as we need it later. - printf 'Virtual environment detected. Adding packages: %s\n' "${deps[*]}" - pip install -U "${deps[@]}" - printf 'Starting the build.\n' - python -m build --sdist --wheel + echo "Virtual environment detected. Adding packages: ${deps[*]}" + pip install --quiet --upgrade "${deps[@]}" + echo 'Starting the build.' + release_with python else - suggest_venv() { + function suggest_venv() { venv_cmd='python -m venv env && source env/bin/activate' - printf "Use a virtual-env with '%s' instead.\n" "$venv_cmd" + printf "HELP: To avoid this error, use a virtual-env with '%s' instead.\n" "$venv_cmd" } trap suggest_venv ERR # This keeps the original exit (error) code. - printf 'Starting the build.\n' - python3 -m build --sdist --wheel # Outside a venv, use python3. + echo 'Starting the build.' + release_with python3 # Outside a venv, use python3. fi