bwoodsend wrote:
> PyInstaller 4.0 (the one on PyPI) doesn’t fully support 3.8 but most of
> the 3.8 issues were fixed so you usually can get away with it.
> PyInstaller 4.1 fully supports 3.8 but it isn’t out yet. You can use the
> development version on Github.
I am in no rush. I use PyInstaller to convert a few utilities I wrote
into a single file executable. I wrote these in Python 3.7; I'd like to
use 3.8 (mostly for assignment expressions), but there is no pressing need.
> As for the increases in size and startup time - I’m not seeing this when
> I try freezing |print("hello")| with Python 3.7 and 3.8. I get 7.1MB
> both times.
This is really weird. My test program is just this:
"""
def main():
print('Hello, world!')
if __name__ == '__main__':
main()
"""
That gets me (on Python 3.7.3) 5.856.459 bytes as single file
executable. I don't understand why that would be so different to your test.
> Try building in |--onedir| mode then compare what’s
> different or being added. Presumably 3.8 is including a package you
> don’t need which 3.7 doesn’t have installed.
I compared the imports as reported in the xref report; they were mostly
identical, but only Python 3.7 imported these:
encodings.cp65001
encodings.unicode_internal
These seem unimportant. Only Python 3.8 imported these:
pyi_rth__tkinter.py
pyi_rth_multiprocessing.py
This seems suspicious. EXE-00.toc of the 3.8 version confirms that
_tkinter.pyd is included, as (hence) are tk86t.dll and tcl86t.dll. This
explains part of the size difference.
Loaded hooks for 3.7:
3925 INFO: Loading module hook 'hook-encodings.py' from [...]
4009 INFO: Loading module hook 'hook-xml.py' from [...]
(no run-time hooks)
Loaded hooks for 3.8:
5994 INFO: Loading module hook 'hook-distutils.py' [...]
6009 INFO: Loading module hook 'hook-encodings.py' [...]
6079 INFO: Loading module hook 'hook-lib2to3.py' [...]
6141 INFO: Loading module hook 'hook-sysconfig.py' [...]
6141 INFO: Loading module hook '
hook-xml.etree.cElementTree.py' [...]
6141 INFO: Loading module hook 'hook-xml.py' [...]
6192 INFO: Loading module hook 'hook-_tkinter.py' [...]
6528 INFO: Including run-time hook [...]pyi_rth__tkinter.py
6528 INFO: Including run-time hook [...]pyi_rth_multiprocessing.py
(Python 3.8.6 is freshly downloaded and has nothing installed;
PyInstaller is installed in a venv, with nothing else installed.) The
hooks shows elementtree and multiprocessing are included as well.
Using --onedir, I noticed that quite a few things are bigger in 3.8.
Libcrypto-1_1: 2.4->3.3 MB; python3x.dll: 3.6->4.1 MB; the test program
itself: 1.4->2.1 MB. I *really* don't understand how 3.8 can yield the
same size executable for you.
Lastly, I noticed that --onedir on 3.8 results in quite a few
subdirectories (encoding, http1.0, messages, ...) which don't appear in
the 3.7 --onedir build.
> Startup time is mostly your
> antivirus giving everything a scan as a onefile app unpacks itself. The
> unzipping itself should be almost instant for such a small program. But
> that 4 seconds latency suggests something else is happening.
The --ondir version executable doesn't exhibit this behavior, so it is
related to the unpacking. I temporarily disabled Windows Defender, and
sure enough: the program now starts in about half a second, instead of
four. Turning Defender back on gets me over four seconds startup time again.
Regards,
Gertjan.