-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
removing PYTHONHOME dependency from a static libpython? #57
Comments
I would also like to ask if you would be interested in how I was able to make a static compile from the python-build-standalone output? In addition, I'm working to try and reduce the size of the PYTHONHOME dependency for my embedded case. I may be able to provide a post build script to generate a minimal size "install" dir for static embedded versions as well. Thank you, -mp |
For importing modules from memory, have you seen As for compiling the output of python-build-standalone, the process varies depending on the platform, programming language, and python-build-standalone distribution used. On Linux, if you want a fully static executable, you'll need to use the musl libc distribution. You should be able to link the It's a legitimate feature request for the documentation to be improved here. I also think it would be a legitimate request to ask for scripts in the distribution to help with this. e.g. you could run a |
Thank you for the quick reply. I wasnt so clear perhaps on my question. I already have a fully static executable in linux by In the docs/status.rst I see you've also run into this issue:
This is exactly my problem. It goes away if I specify a PYTHONHOME env var to python-build-standalone's build path. Thank you for oxidizer_importer. I believe I can use that to find the minimum set of files required by libpython and I will see what I can do about a script to produce a static archive. In the meantime if someone stumbles across this, Thank you again, -mp To compile use the following. The ordering is explicit as there are dependencies. PYTHON_DIST_PATH is where you x86_64-linux-musl-g++ -static test.cxx -IPYTHON_DIST_PATH/python/install/include/python3.7m And a sample test.cxx to validate if the above works: #define PY_SSIZE_T_CLEAN int main(int argc, char* argv[]) |
The overarching issue here is that the Python runtime can't find the ( You have a few options for this. One is to call a Python C API to set the path of the Python standard library based on the executable path. You could use Modules like The solution is described in writing at https://github.com/indygreg/PyOxidizer/blob/dc74b305a6f0fe763d04881d3771e484bc4d9659/pyembed/src/technotes.rs and in code in the If you are using Python 3.7, the hacks to make this all work are a lot uglier, but achievable. I highly recommend targeting Python 3.8. If you want to use Python 3.7, I can send you links to the relevant code. I think PyOxidizer Git commit |
Hello, First thank you for a great package. I spent quite a bit of time trial and erroring what python-build-standalone does well.
My question is that I have a simple c program which is essentially the example from the python doc on how to embed libpython.
I've managed to compile a fully static exec. As you've already solved the issue of module importing with PyOxidizer for a python executable, would you have any thoughts or suggestions on the libpython embedded side? I mean beyond the trivial mechanism of storing the files in the exec and using local disk or shm to extract out the files when needed? I do not want to modify
python source if I can help it as that would make any method highly dependent on the specific python version. But perhaps modifying the Python module initialization to load from memory instead of a file is the easiest way forward.
Any feedback would be highly appreciated.
Thank you,
-mp
The text was updated successfully, but these errors were encountered: