-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d24f74
commit e59ffa5
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
chezmoi/dot_local/bin/executable_dotfiles-install-python-pkgs.tmpl
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,52 @@ | ||
#!/bin/bash | ||
# {{ template "scripts-library" }} | ||
|
||
# check if --update or -u flag is set | ||
set +u | ||
if [[ "${1}" == "--update" ]] || [[ "${1}" == "-u" ]]; then | ||
UPDATE=true | ||
else | ||
UPDATE=false | ||
fi | ||
set -u | ||
log_task "Installing python packages" | ||
|
||
# shellcheck source=/dev/null | ||
source "${HOME}/.config/shrc/05-package-list" | ||
|
||
ensure_path_entry "${HOME}/.local/bin" | ||
|
||
DOTFILES_PKGS_PIP=${DOTFILES_PKGS_PIP:-()} | ||
DOTFILES_PKGS_PIPX=${DOTFILES_PKGS_PIPX:-()} | ||
DOTFILES_PKGS_TO_INSTALL=${DOTFILES_PKGS_TO_INSTALL:-()} | ||
|
||
wanted_packages=() | ||
for package in "${DOTFILES_PKGS_PIP[@]}"; do | ||
if is_item_in_array "${package}" "${DOTFILES_PKGS_PIP[@]}"; then | ||
wanted_packages+=("${package}") | ||
fi | ||
done | ||
log_info "Wanted packages: ${wanted_packages[*]}" | ||
|
||
{{- range .packages }} | ||
{{- if and (hasKey . "pip") ( .pip ) }} | ||
# installing {{ .name }} | ||
PKG_NAME="{{ .name }}" | ||
if is_item_in_array "${PKG_NAME}" "${wanted_packages[@]}"; then | ||
if {{ if and (hasKey . "check_prereqs") ( .check_prereqs ) }}{{ .check_prereqs }}{{ else }}true{{ end }}; then | ||
if [[ "${UPDATE}" == "true" ]]; then | ||
c /usr/bin/pip3 install --user --upgrade "${PKG_NAME}" | ||
elif {{ if and (hasKey . "check_installed") ( .check_installed ) }}{{ .check_installed }}{{ else }}false{{ end }}; then | ||
log_info "Package ${PKG_NAME} is already installed" | ||
else | ||
log_task "Installing ${PKG_NAME}" | ||
c /usr/bin/pip3 install --user --upgrade "${PKG_NAME}" | ||
fi | ||
else | ||
log_error "Prerequisites for ${PKG_NAME} not met" | ||
fi | ||
fi | ||
{{- end }} | ||
{{- end }} | ||
|
||
log_green "✅ Python packages installed successfully. ✨ 🌟 ✨" |