From 919d7404151b3478a5505e1f6d646c5d00eaae9b 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: Tue, 11 Jun 2024 20:45:16 +0530 Subject: [PATCH] Using Poetry to install all dependencies (#2221) * Switch to Poetry for dependency management in setup * Added curl dependency and removed python-pip and python3-pip --------- Co-authored-by: B1N4RY-P4R45173 --- setup-dev.sh | 5 ----- setup.sh | 38 +++++++++++++++++++++----------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/setup-dev.sh b/setup-dev.sh index 8ee1ab523..be02cfc38 100755 --- a/setup-dev.sh +++ b/setup-dev.sh @@ -221,11 +221,6 @@ if linux; then fi echo "Using virtualenv from path: ${PWNDBG_VENV_PATH}" - # Install poetry if not already installed - if ! hash poetry 2> /dev/null; then - curl -sSL https://install.python-poetry.org | python3 - - fi - source "${PWNDBG_VENV_PATH}/bin/activate" ~/.local/bin/poetry install --with dev fi diff --git a/setup.sh b/setup.sh index 68354a41d..9fc78c4ab 100755 --- a/setup.sh +++ b/setup.sh @@ -20,7 +20,7 @@ osx() { install_apt() { sudo apt-get update || true - sudo apt-get install -y git gdb gdbserver python3-dev python3-venv python3-pip python3-setuptools libglib2.0-dev libc6-dbg + sudo apt-get install -y git gdb gdbserver python3-dev python3-venv python3-setuptools libglib2.0-dev libc6-dbg curl if uname -m | grep x86_64 > /dev/null; then sudo dpkg --add-architecture i386 || true @@ -31,25 +31,25 @@ install_apt() { install_dnf() { sudo dnf update || true - sudo dnf -y install gdb gdb-gdbserver python-devel python3-devel python-pip python3-pip glib2-devel make + sudo dnf -y install gdb gdb-gdbserver python-devel python3-devel glib2-devel make curl sudo dnf -y debuginfo-install glibc } install_xbps() { sudo xbps-install -Su - sudo xbps-install -Sy gdb gcc python-devel python3-devel python-pip python3-pip glibc-devel make + sudo xbps-install -Sy gdb gcc python-devel python3-devel glibc-devel make curl sudo xbps-install -Sy glibc-dbg } install_swupd() { sudo swupd update || true - sudo swupd bundle-add gdb python3-basic make c-basic + sudo swupd bundle-add gdb python3-basic make c-basic curl } install_zypper() { sudo zypper mr -e repo-oss-debug || sudo zypper mr -e repo-debug sudo zypper refresh || true - sudo zypper install -y gdb gdbserver python-devel python3-devel python3-pip glib2-devel make glibc-debuginfo + sudo zypper install -y gdb gdbserver python-devel python3-devel glib2-devel make glibc-debuginfo curl sudo zypper install -y python2-pip || true # skip py2 installation if it doesn't exist if uname -m | grep x86_64 > /dev/null; then @@ -58,24 +58,24 @@ install_zypper() { } install_emerge() { - sudo emerge --oneshot --deep --newuse --changed-use --changed-deps dev-lang/python dev-python/pip dev-debug/gdb + sudo emerge --oneshot --deep --newuse --changed-use --changed-deps dev-lang/python dev-debug/gdb } install_pacman() { read -p "Do you want to do a full system update? (y/n) [n] " answer - # user want to perfom a full system upgrade + # user want to perform a full system upgrade answer=${answer:-n} # n is default if [[ "$answer" == "y" ]]; then sudo pacman -Syu || true fi - sudo pacman -S --noconfirm --needed git gdb python python-pip python-capstone python-unicorn python-pycparser python-psutil python-ptrace python-pyelftools python-six python-pygments which debuginfod + sudo pacman -S --noconfirm --needed git gdb python python-capstone python-unicorn python-pycparser python-psutil python-ptrace python-pyelftools python-six python-pygments which debuginfod curl if ! grep -q "^set debuginfod enabled on" ~/.gdbinit; then echo "set debuginfod enabled on" >> ~/.gdbinit fi } install_freebsd() { - sudo pkg install git gdb python py39-pip cmake gmake + sudo pkg install git gdb python py39-pip cmake gmake curl which rustc || sudo pkg install rust } @@ -179,20 +179,24 @@ if ! osx; then PYTHON+="${PYVER}" fi -# Create Python virtualenv +# Install Poetry +if ! command -v poetry &> /dev/null; then + echo "Poetry not found. Installing Poetry..." + curl -sSL https://install.python-poetry.org | python3 - + export PATH="$HOME/.local/bin:$PATH" +else + echo "Poetry is already installed." +fi + +# Create the Python virtual environment and install dependencies using poetry if [[ -z "${PWNDBG_VENV_PATH}" ]]; then PWNDBG_VENV_PATH="./.venv" fi echo "Creating virtualenv in path: ${PWNDBG_VENV_PATH}" ${PYTHON} -m venv -- ${PWNDBG_VENV_PATH} -PYTHON=${PWNDBG_VENV_PATH}/bin/python - -# Upgrade pip itself -${PYTHON} -m pip install --upgrade pip - -# Create Python virtual environment and install dependencies in it -${PWNDBG_VENV_PATH}/bin/pip install -e . +source ${PWNDBG_VENV_PATH}/bin/activate +poetry install if [ -z "$UPDATE_MODE" ]; then # Comment old configs out