diff --git a/config/asdf/python-packages b/config/asdf/python-packages deleted file mode 100644 index 377042c..0000000 --- a/config/asdf/python-packages +++ /dev/null @@ -1,4 +0,0 @@ -ansible -pipenv -neovim -libtmux diff --git a/scripts/install-pip-packages.md b/scripts/install-pip-packages.md deleted file mode 100644 index ee818f4..0000000 --- a/scripts/install-pip-packages.md +++ /dev/null @@ -1,11 +0,0 @@ -# install-pip-packages - -Installs Python packages from `config/pip/packages` using `pip`. - -## Usage - -```bash -scripts/install-pip-packages.sh -``` - -The script uses `pip install --user` for each package entry. diff --git a/scripts/install-pip-packages.sh b/scripts/install-pip-packages.sh deleted file mode 100755 index b355016..0000000 --- a/scripts/install-pip-packages.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash -# @description Install python/pip packages. -# -# shellcheck source=shared.sh -source "${DOTFILES}/config/shared.sh" - -# Enable verbosity with VERBOSE=1 -VERBOSE="${VERBOSE:-0}" - -msgr run "Starting to install pip packages" - -if ! command -v python3 &> /dev/null; then - msgr err "Could not find python3, something really weird is going on." - exit 1 -fi - -msgr nested "Upgrading pip" -python3 -m pip install --user --upgrade pip - -packages=( - "pipx" - "libtmux" -) - -# Function to install pip packages -install_packages() -{ - for pkg in "${packages[@]}"; do - # Trim spaces - pkg=${pkg// /} - # Skip comments - if [[ ${pkg:0:1} == "#" ]]; then continue; fi - - msgr nested "Installing pip package: $pkg" - python3 -m pip install --user --upgrade "$pkg" - echo "" - done -} - -install_packages -msgr run_done "Run pip package installations" diff --git a/scripts/install-python-packages.md b/scripts/install-python-packages.md new file mode 100644 index 0000000..379bdb6 --- /dev/null +++ b/scripts/install-python-packages.md @@ -0,0 +1,18 @@ +# install-python-packages + +Install Python packages defined in the script using `uv`. + +## Usage + +```bash +scripts/install-python-packages.sh +``` + +## What it does + +1. Checks that `uv` is available; if missing, installs it via the official installer. +2. Installs each CLI tool from the inline `tools` array using `uv tool install --upgrade`. +3. Installs each library from the inline `libraries` array using `uv pip install --system --upgrade`. +4. Upgrades all uv-managed tools with `uv tool upgrade --all`. + +To add or remove packages, edit the `tools` or `libraries` arrays in `scripts/install-python-packages.sh`. diff --git a/scripts/install-python-packages.sh b/scripts/install-python-packages.sh new file mode 100755 index 0000000..801e487 --- /dev/null +++ b/scripts/install-python-packages.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +# @description Install Python packages using uv. +# +# shellcheck source=shared.sh +source "$DOTFILES/config/shared.sh" + +# Enable verbosity with VERBOSE=1 +VERBOSE="${VERBOSE:-0}" + +msgr run "Starting to install Python packages" + +# Ensure uv is available +if ! command -v uv &> /dev/null; then + msgr nested "uv not found, installing via official installer" + curl -LsSf https://astral.sh/uv/install.sh | sh + export PATH="$HOME/.local/bin:$PATH" +fi + +# CLI tools — installed isolated with `uv tool install` +tools=( + ansible # IT automation and configuration management +) + +# Library packages — installed into system Python with `uv pip install --system` +libraries=( + libtmux # Python API for tmux + pynvim # Neovim Python client +) + +# Function to install CLI tools via uv tool install +install_tools() +{ + msgr run "Installing Python CLI tools" + for pkg in "${tools[@]}"; do + # Strip inline comments and trim whitespace + pkg="${pkg%%#*}" + pkg="${pkg// /}" + [[ -z "$pkg" ]] && continue + + msgr nested "Installing tool: $pkg" + uv tool install --upgrade "$pkg" + echo "" + done +} + +# Function to install library packages via uv pip install +install_libraries() +{ + msgr run "Installing Python libraries" + for pkg in "${libraries[@]}"; do + # Strip inline comments and trim whitespace + pkg="${pkg%%#*}" + pkg="${pkg// /}" + [[ -z "$pkg" ]] && continue + + msgr nested "Installing library: $pkg" + uv pip install --system --upgrade "$pkg" + echo "" + done +} + +# Function to upgrade all uv-managed tools +upgrade_tools() +{ + msgr run "Upgrading all uv-managed tools" + uv tool upgrade --all +} + +main() +{ + install_tools + install_libraries + upgrade_tools + msgr yay "Python package installations complete" +} + +main "$@"