-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Brief description
When running with static Python build (in my setup it's pkgsStatic.python314 package from nixpkgs), scapy CLI fails. it happens because ctypes are not available, and scapy.all import pulls modules that eagerly load .so libraries.
I think it would be better if CLI can start in this environment, even if in degraded mode (some functionality not available).
Scapy version
2.7.0
Python version
3.14
Operating system
Linux 6.18.16; NixOS unstable
Additional environment information
No response
How to reproduce
Run scapy using static Python build. I only know how to get a static Python build using Nix...
In Nix environment, it's: nix run .#pkgsStatic.python313Packages.scapy
Note: at the moment, the command requires this nixpkgs patch: NixOS/nixpkgs#502064
Actual result
$ ./result/bin/scapy
INFO: Can't import PyX. Won't be able to use psdump() or pdfdump().
Traceback (most recent call last):
File "/nix/store/jwyqphmzah1dxpxvca2l90525bfvbjmx-python3.14-scapy-2.7.0-x86_64-unknown-linux-musl/bin/.scapy-wrapped", line 9, in <module>
sys.exit(interact())
~~~~~~~~^^
File "/nix/store/jwyqphmzah1dxpxvca2l90525bfvbjmx-python3.14-scapy-2.7.0-x86_64-unknown-linux-musl/lib/python3.14/site-packages/scapy/main.py", line 711, in interact
SESSION = init_session(mydict=mydict, ret=True)
File "/nix/store/jwyqphmzah1dxpxvca2l90525bfvbjmx-python3.14-scapy-2.7.0-x86_64-unknown-linux-musl/lib/python3.14/site-packages/scapy/main.py", line 517, in init_session
scapy_builtins = _scapy_builtins()
File "/nix/store/jwyqphmzah1dxpxvca2l90525bfvbjmx-python3.14-scapy-2.7.0-x86_64-unknown-linux-musl/lib/python3.14/site-packages/scapy/main.py", line 473, in _scapy_builtins
for k, v in importlib.import_module(".all", "scapy").__dict__.copy().items()
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/nix/store/pz96bx1swwkv32yy2flpxg8sdcj707q1-python3-static-x86_64-unknown-linux-musl-3.14.3/lib/python3.14/importlib/__init__.py", line 88, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1398, in _gcd_import
File "<frozen importlib._bootstrap>", line 1371, in _find_and_load
File "<frozen importlib._bootstrap>", line 1342, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 938, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 759, in exec_module
File "<frozen importlib._bootstrap>", line 491, in _call_with_frames_removed
File "/nix/store/jwyqphmzah1dxpxvca2l90525bfvbjmx-python3.14-scapy-2.7.0-x86_64-unknown-linux-musl/lib/python3.14/site-packages/scapy/all.py", line 16, in <module>
from scapy.arch import *
File "/nix/store/jwyqphmzah1dxpxvca2l90525bfvbjmx-python3.14-scapy-2.7.0-x86_64-unknown-linux-musl/lib/python3.14/site-packages/scapy/arch/__init__.py", line 28, in <module>
from scapy.libs.extcap import load_extcap
File "/nix/store/jwyqphmzah1dxpxvca2l90525bfvbjmx-python3.14-scapy-2.7.0-x86_64-unknown-linux-musl/lib/python3.14/site-packages/scapy/libs/extcap.py", line 28, in <module>
from scapy.supersocket import SuperSocket
File "/nix/store/jwyqphmzah1dxpxvca2l90525bfvbjmx-python3.14-scapy-2.7.0-x86_64-unknown-linux-musl/lib/python3.14/site-packages/scapy/supersocket.py", line 11, in <module>
import ctypes
File "/nix/store/pz96bx1swwkv32yy2flpxg8sdcj707q1-python3-static-x86_64-unknown-linux-musl-3.14.3/lib/python3.14/ctypes/__init__.py", line 565, in <module>
pythonapi = PyDLL(None)
File "/nix/store/pz96bx1swwkv32yy2flpxg8sdcj707q1-python3-static-x86_64-unknown-linux-musl-3.14.3/lib/python3.14/ctypes/__init__.py", line 433, in __init__
self._handle = self._load_library(name, mode, handle, winmode)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/pz96bx1swwkv32yy2flpxg8sdcj707q1-python3-static-x86_64-unknown-linux-musl-3.14.3/lib/python3.14/ctypes/__init__.py", line 473, in _load_library
return _dlopen(name, mode)
OSError: Dynamic loading not supported
Expected result
CLI starts and gives access to some / most scapy functionality that doesn't depend on dynamic library loading.
Related resources
No response