|
#!/bin/bash |
|
|
|
|
|
|
|
|
|
set -eEu |
|
|
|
function release_with() { |
|
"$1" -m build --sdist --wheel |
|
} |
|
|
|
function suggest_venv() { |
|
local venv_cmd='python -m venv env && source env/bin/activate' |
|
printf "HELP: To avoid this error, use a virtual-env with '%s' instead.\n" "$venv_cmd" |
|
} |
|
|
|
if test -n "${VIRTUAL_ENV-}"; then |
|
deps=(build twine) |
|
echo "Virtual environment detected. Adding packages: ${deps[*]}" |
|
pip install --quiet --upgrade "${deps[@]}" |
|
echo 'Starting the build.' |
|
release_with python |
|
else |
|
trap suggest_venv ERR |
|
echo 'Starting the build.' |
|
release_with python3 |
|
fi |
|
|