pyo3 icon indicating copy to clipboard operation
pyo3 copied to clipboard

How to Dynamically embedding the Python interpreter?

Open chatwyn opened this issue 2 years ago • 1 comments

Hi

When I use cargo build to generate executable, then I use otool -l “executable-path”, It will show LC_LOAD_DYLIB command about python.

Load command 13
          cmd LC_LOAD_DYLIB
      cmdsize 104
         name /usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/Python (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 3.9.0
compatibility version 3.9.0

But I Need to distribute the executable to users whose computers do not have the python Path, Then will run error. So I have some problems.

  1. How to change or remove the python LC_LOAD_DYLIB command?
  2. If I can change the LC_LOAD_DYLIB command python path, How to adjust all mac.
  3. If I Remove the LC_LOAD_DYLIB command, how to dynamic load python dylib?

chatwyn avatar Jun 07 '22 14:06 chatwyn

I think the easiest way is probably to use PyOxidizer to embed the interpreter into your binary?

davidhewitt avatar Jun 09 '22 07:06 davidhewitt