intoli / exodus

Painless relocation of Linux binaries–and all of their dependencies–without containers.
Other
2.94k stars 71 forks source link

Python's venv library bypasses the exodus wrapper #63

Open bhilton opened 3 years ago

bhilton commented 3 years ago

Python's venv creation code bypasses the exodus wrapper, which results in the real Python binary being called directly.

Here's the relevant code: https://github.com/python/cpython/blob/master/Lib/venv/__init__.py#L117

Has anyone found a solution for using exodus with applications that follow this pattern? I haven't been able to come up with a workable solution. Even hacking this particular file still doesn't solve the issue, as pip itself seems to do something similar when launching subprocesses.

sangaline commented 3 years ago

Could you share a few more details about what you're trying to do? Are you trying to create a virtualenv using a version of Python that was bundled using Exodus, or to bundle a script that runs locally in a virtualenv with the necessary dependencies? Bundling something as complex as Python is definitely pushing the boundaries of what Exodus can do, but it might be possible depending on the exact use-case.

bhilton commented 3 years ago

The former - trying to create a virtualenv using a version of Python that was bundled using Exodus. It works surprisingly well, aside from some behavior in Python's venv and pip libraries. They launch sub-processes and seem to resolve the executable to Python itself instead of the exodus wrapper.

Apart from that, everything works as expected. I'm able to import C-libs from Python's ssl, kerberos, and other extensions with C library dependencies. I can build on Ubuntu 20.04 and run it inside a vanilla CentOS 6 docker container, which was my initial goal.

If you have any ideas for how to overcome Python's behavior it would be welcome. Thanks for your reply!