From af7e82c43be1826775e48d7429f1be22a4955b64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjam=C3=ADn=20Guzm=C3=A1n?= Date: Wed, 2 Sep 2026 11:43:07 -0600 Subject: [PATCH 1/2] fix(ebuild): fix installation script when using venv MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The installation script failed with no helpful message when a virtual environment was used. Plus, there were style errors (whitespaces) detected by ruff, that were also fixed. Signed-off-by: Benjamín Guzmán --- install.sh | 22 +++++++++++++++++----- tests/unit/cli/test_commands_utils.py | 26 +++++++++++++------------- 2 files changed, 30 insertions(+), 18 deletions(-) mode change 100644 => 100755 install.sh diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index 2b3d32ba..9a525ed9 --- a/install.sh +++ b/install.sh @@ -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..." @@ -44,8 +46,12 @@ 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="" @@ -53,7 +59,8 @@ for candidate in \ "$HOME/.local/bin/ebuild" \ "/usr/local/bin/ebuild" \ "/usr/bin/ebuild" \ - "$(python3 -m site --user-base 2>/dev/null)/bin/ebuild"; do + "$(python3 -m site --user-base 2>/dev/null)/bin/ebuild" \ + "$VIRTUAL_ENV/bin/ebuild"; do if [ -x "$candidate" ]; then EBUILD_BIN="$candidate" break @@ -65,6 +72,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 diff --git a/tests/unit/cli/test_commands_utils.py b/tests/unit/cli/test_commands_utils.py index 9ce8dabb..c6a52825 100644 --- a/tests/unit/cli/test_commands_utils.py +++ b/tests/unit/cli/test_commands_utils.py @@ -40,7 +40,7 @@ def test_resolve_runner_args_unit(tmp_path, monkeypatch, config_val, env_val, cl monkeypatch.setenv(env_key, env_val) else: monkeypatch.delenv(env_key, raising=False) - + config_file = tmp_path / "build.yaml" if config_val is not None: if isinstance(config_val, list): @@ -48,13 +48,13 @@ def test_resolve_runner_args_unit(tmp_path, monkeypatch, config_val, env_val, cl config_file.write_text(f'project:\n name: test\nsystem:\n test_args: [{args_str}]\n', encoding="utf-8") else: config_file.write_text(f'project:\n name: test\nsystem:\n test_args: {config_val}\n', encoding="utf-8") - + res = _resolve_runner_args( - cli_args=cli_val, - env_key=env_key, - cfg_loader=create_loader(str(config_file)), - config_section="system_config", - config_key="test_args", + cli_args=cli_val, + env_key=env_key, + cfg_loader=create_loader(str(config_file)), + config_section="system_config", + config_key="test_args", log=DummyLogger(), clear_args=clear_args_val, ) @@ -64,13 +64,13 @@ def test_resolve_runner_args_null_safety(): """Verify null safety with empty or non-dict sections.""" class FakeConfig: system_config = None # Explicitly None to test null safety - + res = _resolve_runner_args( - cli_args=(), - env_key="TEST_ENV_KEY", - cfg_loader=lambda: FakeConfig(), - config_section="system_config", - config_key="test_args", + cli_args=(), + env_key="TEST_ENV_KEY", + cfg_loader=lambda: FakeConfig(), + config_section="system_config", + config_key="test_args", log=DummyLogger() ) assert res == [] From 5c6dada5077fcdf9419b80ec0064cba00dce2b34 Mon Sep 17 00:00:00 2001 From: Srikanth Patchava Date: Thu, 1 Oct 2026 18:29:28 -0700 Subject: [PATCH 2/2] fix(install): prefer the active venv's pip and ebuild; skip empty VIRTUAL_ENV candidate Inside a venv, ~/.local/bin/pip3 was picked first, so the package was installed outside the venv. With VIRTUAL_ENV unset, the new candidate expanded to /bin/ebuild. --- install.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 9a525ed9..777c5f5a 100755 --- a/install.sh +++ b/install.sh @@ -33,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" @@ -55,13 +57,14 @@ 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" \ - "$VIRTUAL_ENV/bin/ebuild"; do - if [ -x "$candidate" ]; then + "$(python3 -m site --user-base 2>/dev/null)/bin/ebuild"; do + if [ -n "$candidate" ] && [ -x "$candidate" ]; then EBUILD_BIN="$candidate" break fi