New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pwndbg: fix runtime python deps, fixes #71071 #71219
Conversation
@n4074 please test this |
pwndbg is a Python module for gdb. The built-in interpreter is used and pwndbg offers additional routines. Packaging this is tricky because that interpreter needs to be used. Using `python3.withPackages` won't work. By setting `NIX_PYTHONPATH`, the interpreter should pick up pwndbg and its dependencies. If `NIX_PYTHONPATH` does not function we can fall back to `PYTHONPATH`. An example of when that won't work is if pwndbg runs a script of itself in a subshell. `NIX_PYTHONPATH` would be unset, but `PYTHONPATH` not.
backport: [detached HEAD 57f68f7] pythonPackages.capstone: add missing setuptools dep |
I was trying to use `python-arango` in one of my experiments with NixOS (23.05). I got the following error: ```console [rm_me] λ nix-shell -p python311Packages.python-arango [nix-shell:/data/rm_me]$ python -c 'import arango' Traceback (most recent call last): File "<string>", line 1, in <module> File "/nix/store/4n18qmv3dfx8gja79rvrlmrxzv1acmx9-python3.11-python-arango-7.5.7/lib/python3.11/site-packages/arango/__init__.py", line 2, in <module> from arango.client import ArangoClient # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/4n18qmv3dfx8gja79rvrlmrxzv1acmx9-python3.11-python-arango-7.5.7/lib/python3.11/site-packages/arango/client.py", line 6, in <module> from pkg_resources import get_distribution ModuleNotFoundError: No module named 'pkg_resources' ``` To fix it, I have to pass an additional package to the nix shell: ```console [rm_me] λ nix-shell -p python311Packages.python-arango python311Packages.setuptools [nix-shell:/data/rm_me]$ python -c 'import arango' [nix-shell:/data/rm_me]$ ``` I found a similar issue with `pwndbg` in the past has been resolved in NixOS#71219. But I think in this case, we only need to change the Python side, not everything. This is my first nixpkgs PR, apologies if it is not correct. Will try to make it work :)
I was trying to use `python-arango` in one of my experiments with NixOS (23.05). I got the following error: ```console [rm_me] λ nix-shell -p python311Packages.python-arango [nix-shell:/data/rm_me]$ python -c 'import arango' Traceback (most recent call last): File "<string>", line 1, in <module> File "/nix/store/4n18qmv3dfx8gja79rvrlmrxzv1acmx9-python3.11-python-arango-7.5.7/lib/python3.11/site-packages/arango/__init__.py", line 2, in <module> from arango.client import ArangoClient # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/4n18qmv3dfx8gja79rvrlmrxzv1acmx9-python3.11-python-arango-7.5.7/lib/python3.11/site-packages/arango/client.py", line 6, in <module> from pkg_resources import get_distribution ModuleNotFoundError: No module named 'pkg_resources' ``` To fix it, I have to pass an additional package to the nix shell: ```console [rm_me] λ nix-shell -p python311Packages.python-arango python311Packages.setuptools [nix-shell:/data/rm_me]$ python -c 'import arango' [nix-shell:/data/rm_me]$ ``` I found a similar issue with `pwndbg` in the past has been resolved in NixOS#71219. But I think in this case, we only need to change the Python side, not everything. This is my first nixpkgs PR, apologies if it is not correct. Will try to make it work :) Signed-off-by: Mihai Maruseac <mihai.maruseac@gmail.com>
I was trying to use `python-arango` in one of my experiments with NixOS (23.05). I got the following error: ```console [rm_me] λ nix-shell -p python311Packages.python-arango [nix-shell:/data/rm_me]$ python -c 'import arango' Traceback (most recent call last): File "<string>", line 1, in <module> File "/nix/store/4n18qmv3dfx8gja79rvrlmrxzv1acmx9-python3.11-python-arango-7.5.7/lib/python3.11/site-packages/arango/__init__.py", line 2, in <module> from arango.client import ArangoClient # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/4n18qmv3dfx8gja79rvrlmrxzv1acmx9-python3.11-python-arango-7.5.7/lib/python3.11/site-packages/arango/client.py", line 6, in <module> from pkg_resources import get_distribution ModuleNotFoundError: No module named 'pkg_resources' ``` To fix it, I have to pass an additional package to the nix shell: ```console [rm_me] λ nix-shell -p python311Packages.python-arango python311Packages.setuptools [nix-shell:/data/rm_me]$ python -c 'import arango' [nix-shell:/data/rm_me]$ ``` I found a similar issue with `pwndbg` in the past has been resolved in NixOS#71219. But I think in this case, we only need to change the Python side, not everything. This is my first nixpkgs PR, apologies if it is not correct. Will try to make it work :) Signed-off-by: Mihai Maruseac <mihai.maruseac@gmail.com>
I was trying to use `python-arango` in one of my experiments with NixOS (23.05). I got the following error: ```console [rm_me] λ nix-shell -p python311Packages.python-arango [nix-shell:/data/rm_me]$ python -c 'import arango' Traceback (most recent call last): File "<string>", line 1, in <module> File "/nix/store/4n18qmv3dfx8gja79rvrlmrxzv1acmx9-python3.11-python-arango-7.5.7/lib/python3.11/site-packages/arango/__init__.py", line 2, in <module> from arango.client import ArangoClient # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/4n18qmv3dfx8gja79rvrlmrxzv1acmx9-python3.11-python-arango-7.5.7/lib/python3.11/site-packages/arango/client.py", line 6, in <module> from pkg_resources import get_distribution ModuleNotFoundError: No module named 'pkg_resources' ``` To fix it, I have to pass an additional package to the nix shell: ```console [rm_me] λ nix-shell -p python311Packages.python-arango python311Packages.setuptools [nix-shell:/data/rm_me]$ python -c 'import arango' [nix-shell:/data/rm_me]$ ``` I found a similar issue with `pwndbg` in the past has been resolved in #71219. But I think in this case, we only need to change the Python side, not everything. This is my first nixpkgs PR, apologies if it is not correct. Will try to make it work :) Signed-off-by: Mihai Maruseac <mihai.maruseac@gmail.com>
pwndbg is a Python module for gdb. The built-in interpreter is used and
pwndbg offers additional routines. Packaging this is tricky because that
interpreter needs to be used. Using
python3.withPackages
won't work.By setting
NIX_PYTHONPATH
, the interpreter should pick up pwndbg andits dependencies.
If
NIX_PYTHONPATH
does not function we can fall back toPYTHONPATH
.An example of when that won't work is if pwndbg runs a script of itself
in a subshell.
NIX_PYTHONPATH
would be unset, butPYTHONPATH
not.Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)Notify maintainers
cc @n4074 @Mic92