From a1c4bb47e7979a958f13764f8f8dd2267b11b778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=82=EF=BE=8C=E5=8D=82=E3=84=9A=20=D2=9C=E3=84=96?= =?UTF-8?q?=E5=8D=A9=E5=8D=A9=E5=8D=82=D2=9C=E5=8D=82?= Date: Thu, 20 Jun 2024 02:06:32 +0530 Subject: [PATCH] Using full PATH length to install poetry (#2238) Co-authored-by: B1N4RY-P4R45173 Co-authored-by: Gulshan Singh --- gdbinit.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/gdbinit.py b/gdbinit.py index 16d14fc70..2184f0da5 100644 --- a/gdbinit.py +++ b/gdbinit.py @@ -3,6 +3,7 @@ from __future__ import annotations import cProfile import hashlib import os +import shutil import site import subprocess import sys @@ -34,7 +35,20 @@ def calculate_hash(file_path): def run_poetry_install(dev=False): - command = ["poetry", "install"] + poetry_path = shutil.which("poetry") + if poetry_path is None: + # Additional check: Look for poetry at $HOME/.local/bin/poetry + home_poetry_path = os.path.expanduser("~/.local/bin/poetry") + if os.path.exists(home_poetry_path): + print(f"Found Poetry at {home_poetry_path}") + poetry_path = home_poetry_path + else: + print( + "Poetry was not found on the $PATH. Please ensure it is installed and on the path, or run `./setup.sh` to update Python dependencies." + ) + return "", "", 1 + + command = [poetry_path, "install"] if dev: command.extend(("--with", "dev")) result = subprocess.run(command, capture_output=True, text=True) @@ -80,8 +94,6 @@ if venv_path != "PWNDBG_PLEASE_SKIP_VENV" and not path.exists( print(f"Cannot find Pwndbg virtualenv directory: {venv_path}: please re-run setup.sh") sys.exit(1) - update_deps(__file__) - site_pkgs_path = glob(os.path.join(venv_path, "lib/*/site-packages"))[0] # add virtualenv's site-packages to sys.path and run .pth files @@ -96,6 +108,8 @@ if venv_path != "PWNDBG_PLEASE_SKIP_VENV" and not path.exists( bin_path = os.path.join(venv_path, "bin") os.environ["PATH"] = bin_path + os.pathsep + os.environ.get("PATH", "") + update_deps(__file__) + # Add pwndbg directory to sys.path so it can be imported sys.path.insert(0, directory)