Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions install.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'

ok() { echo -e "${GREEN}✅${NC} $*"; }
err() { echo -e "${RED}❌${NC} $*"; }
ok() { echo -e "${GREEN}✅${NC} $*"; }
err() { echo -e "${RED}❌${NC} $*"; }
warn() { echo -e "${YELLOW}⚠️${NC} $*"; }

if [ "$1" = "--check" ]; then
echo "Checking ebuild installation..."
Expand All @@ -31,7 +33,9 @@ fi
echo "Installing ebuild..."

# Step 1: pip install (use user pip if available, fall back to system)
if [ -x "$HOME/.local/bin/pip3" ]; then
if [ -n "$VIRTUAL_ENV" ] && [ -x "$VIRTUAL_ENV/bin/pip" ]; then
PIP="$VIRTUAL_ENV/bin/pip"
elif [ -x "$HOME/.local/bin/pip3" ]; then
PIP="$HOME/.local/bin/pip3"
elif [ -x "$HOME/.local/bin/pip" ]; then
PIP="$HOME/.local/bin/pip"
Expand All @@ -44,17 +48,23 @@ else
exit 1
fi

$PIP install -e "$SCRIPT_DIR" --quiet 2>/dev/null
ok "Python package installed"
if $PIP install -e "$SCRIPT_DIR" --quiet 2>/dev/null; then
ok "Python package installed successfully"
else
err "Python package failed to install. Try running \"$PIP install -e '$SCRIPT_DIR'\" manually"
exit 1
fi

# Step 2: Find where pip put the ebuild script
EBUILD_BIN=""
# An active venv is checked first: pip installed into it, so any other hit is stale.
for candidate in \
"${VIRTUAL_ENV:+$VIRTUAL_ENV/bin/ebuild}" \
"$HOME/.local/bin/ebuild" \
"/usr/local/bin/ebuild" \
"/usr/bin/ebuild" \
"$(python3 -m site --user-base 2>/dev/null)/bin/ebuild"; do
if [ -x "$candidate" ]; then
if [ -n "$candidate" ] && [ -x "$candidate" ]; then
EBUILD_BIN="$candidate"
break
fi
Expand All @@ -65,6 +75,11 @@ if [ -z "$EBUILD_BIN" ]; then
exit 1
fi

if [ -n "$VIRTUAL_ENV" ] && [ "$EBUILD_BIN" = "$VIRTUAL_ENV/bin/ebuild" ]; then
warn "Warning: Installing the ebuild binary from a virtual environment."
warn " This means its successful execution will depend on the virtual env existence."
fi

ok "ebuild binary: $EBUILD_BIN"

# Step 3: Make it globally available
Expand Down
Loading