Is it possible to do a two steps decompression with PyInstaller?
e.g. it can decompress archived files from itself as needed, like InnoSetup, Nullsoft Installer (NSIS).
For --onefile exe generated with PyInstaller, everything is decompressed at invocation runtime, and it takes a lot of time, if there's a lot of bundled datafile.
What I trying to do is to replicate InnoSetup with PyInstaller+PyQt. Any ideas?
Yes you can. You can bundle installer files by appending to a.data in your spec file. Then at runtime your data files will be in the MEIPASS folder and you can copy them wherever you want. https://stackoverflow.com/a/20088482/259538
Related
I'm using PyInstaller to build a Windows EXE. It's building correctly, but the EXE is almost double the size of an EXE generated from the same .py code in the past. I'm assuming that either the version of Python, an imported package, or Pyinstaller itself has changed. I have the /build directory artifacts and the .spec files from the current and prior builds. Is there a way to extract the version information from those artifacts to figure out what has changed? When PyInstaller runs it prints out its version but I'm not seeing anything like that in the /build directory.
This question is related to differential update of pyinstaller executable (modify embedded PYZ-00.pyz)
I would like to create a pyinstaller distributable, that can easily be hot fixed without wasting too much bandwidth.
The standard pyinstaller approach for embedding python code .pyc files seems to be to put them into a PYZ file (ZLIB archive), adding the PYZ file into a CARchive and append the CArchive to the end of the executable.
I thought, that following solution might help me, tough it will penalize startup time of the program, but this is acceptable.
If possible I would like, that all collected .pyc files will not be added tot he .PYZ file but into a normal .zip file and that this normal zip file will then be added ('collected') into the dist folder.
How could I achieve this?
The answer https://stackoverflow.com/a/68754754/858675 to the other question is almost there and one could just pack up all .pyc files into a .zip file.
However the value of __file__ would be different for the modules and I guess, this might break some existing code if the depend on __file__
I have a big project, and I update it very often.
Later I used py2exe one time to create the main .exe file, and just copied only 1-2 fresh .py files after every update to the directory with .exe file (no need to recreate .exe file, really quick update).
But I can't force pyinstaller to use my raw .py files this way. It packs all .py files to .exe and on running it extract and use that files. So I should recreate .exe even after the smallest changes of code (and it takes too long time...).
How to force pyinstaller to use my .py files like I did with py2exe?
When you build an exe file using --onefile option with Pyinstaller, you can specify datas (like picture or whatever...)
During the runtime, a tmp directory is created (MEI*) which contains python interpreter, your data in original format ...
How does Pyinstaller embed all theses datas?
.exe files are only machine code instructions right? They are not supposed to be "container file"...
Thanks !
Have you read the pyinstaller manual?
https://pythonhosted.org/PyInstaller/#id22
How the One-File Program Works The bootloader is the heart of the
one-file bundle also. When started it creates a temporary folder in
the appropriate temp-folder location for this OS. The folder is named
_MEIxxxxxx, where xxxxxx is a random number.
The one executable file contains an embedded archive of all the Python
modules used by your script, as well as compressed copies of any
non-Python support files (e.g. .so files). The bootloader uncompresses
the support files and writes copies into the the temporary folder.
This can take a little time. That is why a one-file app is a little
slower to start than a one-folder app.
After creating the temporary folder, the bootloader proceeds exactly
as for the one-folder bundle, in the context of the temporary folder.
When the bundled code terminates, the bootloader deletes the temporary
folder.
(In Linux and related systems, it is possible to mount the /tmp folder
with a "no-execution" option. That option is not compatible with a
PyInstaller one-file bundle. It needs to execute code out of /tmp.)
Because the program makes a temporary folder with a unique name, you
can run multiple copies of the app; they won't interfere with each
other. However, running multiple copies is expensive in disk space
because nothing is shared.
The _MEIxxxxxx folder is not removed if the program crashes or is
killed (kill -9 on Unix, killed by the Task Manager on Windows, "Force
Quit" on Mac OS). Thus if your app crashes frequently, your users will
lose disk space to multiple _MEIxxxxxx temporary folders.
Alright, I found this : https://en.wikipedia.org/wiki/Executable_compression
Compressed data can be along with a decompression code into a single excutable.
So, Pyinstaller may include a runtime packer to do that.
I had a python program written which I converted to an exe binary using py2exe. I have all of the files generated in the dist folder but due to a system crash, I lost the source code.
Is there a way to get the .py source code file back from .exe or other supporting files generated by py2exe?
According to the following links, you can extract your .pyc files from library.zip and then use decompyle to obtain .py files similar to what you started with.
http://bytes.com/topic/python/answers/101743-py2exe-there-way-go-backwards-exe2py
http://sourceforge.net/projects/decompyle/
Hope it works, and I hope you use github or bitbucket next time.