Skip to content
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

Merged
merged 2 commits into from Oct 16, 2019
Merged

Conversation

FRidh
Copy link
Member

@FRidh FRidh commented Oct 16, 2019

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.

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @n4074 @Mic92

@FRidh
Copy link
Member Author

FRidh commented Oct 16, 2019

@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.
@Mic92
Copy link
Member

Mic92 commented Oct 16, 2019

backport:

[detached HEAD 57f68f7] pythonPackages.capstone: add missing setuptools dep
Author: Frederik Rietdijk fridh@fridh.nl
Date: Wed Oct 16 09:59:47 2019 +0200
1 file changed, 3 insertions(+)
Press Enter to continue
[detached HEAD 0f9b2d9] pwndbg: fix runtime python deps, fixes #71071
Author: Frederik Rietdijk fridh@fridh.nl
Date: Wed Oct 16 09:55:01 2019 +0200
2 files changed, 22 insertions(+), 32 deletions(-)

@FRidh FRidh deleted the pwndbg branch October 16, 2019 11:48
mihaimaruseac added a commit to mihaimaruseac/nixpkgs that referenced this pull request Jul 12, 2023
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 :)
mihaimaruseac added a commit to mihaimaruseac/nixpkgs that referenced this pull request Jul 12, 2023
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>
mihaimaruseac added a commit to mihaimaruseac/nixpkgs that referenced this pull request Jul 14, 2023
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>
dotlambda pushed a commit that referenced this pull request Jul 18, 2023
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants