Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyPy and PyInstaller

Tags:

Is it possible to build a single-binary or single-directory package with PyInstaller that uses pypy as interpreter?

Any special tricks to do that?

Some alternative to PyInstaller?

If not, what are the fundamental technical reasons?

Notes why/how pyinstaller doesn't doesn't with pypy out of the box:

  • distutils.sysconfig.get_config_h_filename missing, fixed in pytinstaller trunk
  • (distutils.|)sysconfig.(_|)get_makefile_filename missing, actually optional
  • tries to link against libpython2.7.so.1, pypy in single executable, not a shared object
like image 494
Dima Tisnek Avatar asked Feb 25 '14 20:02

Dima Tisnek


People also ask

Which is better py2exe or PyInstaller?

In PyInstaller it is easy to create one exe, By default both create a bunch of exes & dlls. In py2exe its easier to embed manifest file in exe, useful for run as administrator mode in windows vista and beyond. Pyinstaller is modular and has a feature of hooks to include files in the build that you like.

What is PyInstaller used for?

PyInstaller reads a Python script written by you. It analyzes your code to discover every other module and library your script needs in order to execute. Then it collects copies of all those files – including the active Python interpreter!

Is PyInstaller standalone?

PyInstaller will bundle the Python script and all its dependencies into a single self-contained standalone executable which can be distributed to other systems or users without having Python or any modules, including teradatasql installed.


1 Answers

I have tried this out and it failed, on many occasions, because PyPy is only able to work with a few subset of what CPython uses. PyInstaller is a full blown CPython application, so there are not able to communicate.

PyInstaller's mechanism is sensitive to how CPython works, so PyPy can introduce some issues. This is what you'll get when trying to run PyInstaller in a PyPy virtual environment:

OSError: Python library not found: Python, .Python, libpython3.5.dylib, libpython3.5m.dylib  This would mean your Python installation doesn't come with proper library files.  This usually happens by missing development package, or unsuitable build parameters of Python installation.  * On Debian/Ubuntu, you would need to install Python development packages   * apt-get install python3-dev   * apt-get install python-dev * If you're building Python by yourself, please rebuild your Python with   `--enable-shared` (or, `--enable-framework` on Darwin) 

If you need improved speed and hiding your code away from people, you can try out Cython. I use both Cython and PyInstaller a lot, and I love their cross platform nature.

When you are through with both, you can then use PyInstaller & CPython to package your app.

like image 52
iChux Avatar answered Oct 26 '22 11:10

iChux