indygreg / indygreg/PyOxidizer
pypcap module cannot be embedded
- Dominant language
- Rust
- Stars
- 6.2k
- Forks
- 256
- PR merge metrics
- No merged PRs in 30d
Description
this likely will affect pcapy also. I suspect it is because of what is described in the documentation regarding C native extension modules.
pypcap is a python wrapper for libpcap. The output from either a pip install pypcap or setup.py is a .so called pcap.cpython-{distribution}.so, and a pcap.py file that loads the c module:
`def __bootstrap__():
global __bootstrap__, __loader__, __file__
import sys, pkg_resources, imp
__file__ = pkg_resources.resource_filename(__name__, 'pcap.cpython-37m-x86_64-linux-gnu.so')
__loader__ = None; del __bootstrap__, __loader__
imp.load_dynamic(__name__,__file__)
__bootstrap__()
`
from the pyoxidizer.toml file i have tried a pip install, which appears successfull at build time but the application cannot find the 'pcap' module when it tries to import it at runtime. I also tried to use the 'setup-py-install' type, however on my system, this breaks the build becasue /tmp is not part of the PYTHONPATH (fwiw - i did try to echo /tmp to the PYTHONPATH variable, but the same error occurs)
I also tried the simplest ways to link the pypcap modules, e.g. linking the path of the virtualenv where it is working, and moving the required files to the package-root directory. It may be useful to know, that when i reference the pcap module from the package-root, the application does envoke the pcap module, but cannot find the pkg_resources module that needs to be imported. maybe a workaround would be to somehow embed setuptools?
File "pcap", line 7, in
File "pcap", line 3, in __bootstrap__
ModuleNotFoundError: No module named 'pkg_resources'
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the pyoxidizer.toml configuration and the pip install and setup-py-install approaches described in the report. Reproduce the runtime import of pypcap and inspect the reported pkg_resources failure; done means the embedded application can import pcap without the missing module error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100