-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break out python setup to separate file
- Loading branch information
Showing
2 changed files
with
46 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
# Install python pipx / venv packages | ||
# | ||
# Usage: install_python_packages | ||
|
||
# Make sure to load `command_exists` helper as well as local paths | ||
# shellcheck source=../stowed-files/bash/.profile | ||
. "$HOME/dotfiles/stowed-files/bash/.profile" | ||
|
||
install_python_packages() { | ||
declare -r venv_path="$HOME/.local/venv" | ||
|
||
if ! command_exists pipx; then | ||
>&2 echo "⨯ pipx not installed!" | ||
exit 1 | ||
fi | ||
|
||
echo "Installing global pipx packages …" | ||
# `--quiet` added to `pipx` in late 2023, waiting for version bump | ||
# in Debian stable | ||
grep -v "^#" "$HOME/dotfiles/scripts/pipx-packages" | \ | ||
xargs --no-run-if-empty -L 1 pipx install --force | ||
echo "Pipx packages installed!" | ||
|
||
if [[ ! -d "${venv_path}" ]]; then | ||
echo "Creating default venv …" | ||
python3 -m venv "${venv_path}" | ||
echo "Default venv created!" | ||
fi | ||
|
||
# shellcheck source=/dev/null | ||
. "${venv_path}/bin/activate" | ||
|
||
echo "Installing venv libraries …" | ||
grep -v "^#" "$HOME/dotfiles/scripts/python-libraries" | \ | ||
xargs --no-run-if-empty \ | ||
"${venv_path}/bin/python" -m pip install --quiet --upgrade | ||
echo "venv libraries installed!" | ||
} | ||
|
||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then | ||
install_python_packages "${@}" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters