Skip to content

Commit

Permalink
Install dev dependencies with poetry (pwndbg#2065)
Browse files Browse the repository at this point in the history
* Add dev dependencies to pyproject.toml

* Add poetry.toml file

* Remove dev-requirements and install dev dependencies with poetry

* Update pwndbg.nix
  • Loading branch information
gsingh93 authored Mar 11, 2024
1 parent 2a50da8 commit da817b2
Show file tree
Hide file tree
Showing 9 changed files with 563 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
ADD ./setup.sh /pwndbg/
ADD ./poetry.lock /pwndbg/
ADD ./pyproject.toml /pwndbg/
ADD ./dev-requirements.txt /pwndbg/
ADD ./poetry.toml /pwndbg/

# pyproject.toml requires these files, pip install would fail
RUN touch README.md && mkdir pwndbg && touch pwndbg/empty.py
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.arch
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
ADD ./setup.sh /pwndbg/
ADD ./pyproject.toml /pwndbg/
ADD ./poetry.lock /pwndbg/
ADD ./dev-requirements.txt /pwndbg/
ADD ./poetry.toml /pwndbg/

# pyproject.toml requires these files, pip install would fail
RUN touch README.md && mkdir pwndbg && touch pwndbg/empty.py
Expand Down
16 changes: 0 additions & 16 deletions dev-requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ LINT_FILES="pwndbg tests *.py"
LINT_TOOLS="isort black ruff vermin mypy"

if ! type ${LINT_TOOLS} &> /dev/null; then
PIP_CMD="pip install -Ur dev-requirements.txt"
PIP_CMD="poetry install --with dev"
echo "Missing one of the following tools: ${LINT_TOOLS}"
echo "Running '${PIP_CMD}'"

Expand Down
2 changes: 2 additions & 0 deletions nix/pwndbg.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ let
]);

pyEnv = pkgs.poetry2nix.mkPoetryEnv {
groups = []; # put [ "dev" ] to build "dev" dependencies
checkGroups = []; # put [ "dev" ] to build "dev" dependencies
projectDir = inputs.pwndbg;
python = python3;
overrides = pkgs.poetry2nix.overrides.withDefaults (self: super: {
Expand Down
529 changes: 524 additions & 5 deletions poetry.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions poetry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[virtualenvs]
in-project = true

[keyring]
enabled = false
21 changes: 21 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,27 @@ unicorn = "2.0.1.post1"
requests = "2.31.0"
pt = {git = "https://github.com/martinradev/gdb-pt-dump", rev = "89ea252f6efc5d75eacca16fc17ff8966a389690"}

[tool.poetry.group.dev]
optional = true

[tool.poetry.group.dev.dependencies]
black = "24.2.0"
coverage = {version = "7.4.3", extras = ["toml"]}
isort = "5.13.2"
mypy = "1.8.0"
pytest = "8.0.2"
pytest-cov = "4.1.0"
rich = "13.7.1"
ruff = "0.3.0"
testresources = "2.0.1"
tomli = "2.0.1"
types-gdb = "12.1.4.20240305"
types-psutil = "5.9.5.20240205"
types-pygments = "2.17.0.20240106"
types-requests = "2.31.0.20240218"
types-tabulate = "0.9.0.20240106"
vermin = "1.6.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
10 changes: 8 additions & 2 deletions setup-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ if linux; then
PWNDBG_VENV_PATH="./.venv"
fi
echo "Using virtualenv from path: ${PWNDBG_VENV_PATH}"
PYTHON=${PWNDBG_VENV_PATH}/bin/python
${PYTHON} -m pip install -r dev-requirements.txt

# 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

0 comments on commit da817b2

Please sign in to comment.