kivy app to .exe with PyInstaller - 0% to 30% increase in CPU usage

82 views
Skip to first unread message

Serhio

unread,
Mar 17, 2021, 7:52:10 PM3/17/21
to Kivy users support
I've created a basic program using Kivy. I've noticed that after creating the executable with PyInstaller the CPU usage skyrockets from the 0.0% (in case I run it from the console as .py file) to like 30% when run as an executable.

Here are the .py and .spec files that I'm using:

minimum_kivy.py

from kivy.app import App
from kivy.uix.label import Label


class TestApp(App):
   
def build(self):
       
return Label(text="Hello")        


if __name__ == '__main__':  
           
   test
= TestApp().run()




.spec file:

# -*- mode: python ; coding: utf-8 -*-


block_cipher
= None




a
= Analysis(['s:\\!kyxa\\!code\\kivy\\MinimumApp\\minimum_kivy.py'],
             pathex
=['s:\\!kyxa\\!code\\kivy\\MinimumApp'],
             binaries
=[],
             datas
=[],
             hiddenimports
=[],
             hookspath
=[],
             runtime_hooks
=[],
             excludes
=[],
             win_no_prefer_redirects
=False,
             win_private_assemblies
=False,
             cipher
=block_cipher,
             noarchive
=False)
pyz
= PYZ(a.pure, a.zipped_data,
             cipher
=block_cipher)
exe
= EXE(pyz,
          a
.scripts,
         
[],
          exclude_binaries
=True,
          name
='minimum',
          debug
=False,
          bootloader_ignore_signals
=False,
          strip
=False,
          upx
=True,
          console
=True )
coll
= COLLECT(exe,
               a
.binaries,
               a
.zipfiles,
               a
.datas,
               strip
=False,
               upx
=True,
               upx_exclude
=[],
               name
='minimum')




I use python2.7 on windows 10.

Robert

unread,
Mar 17, 2021, 9:03:26 PM3/17/21
to Kivy users support
This looks like a Pyinstaller question, not a Kivy question.

Presumably the higher cpu usage is transitory.

The answer is probably that Pyinstaller doesn't 'execute' the .exe in the sense of a binary executable,
It executes the .exe by unpacking the .exe then executing the contents.
Which would explain the (unreported) latency and (reported) CPU usage.
You can test this by creating an install that is not a single file ;)

And unrelated, Kivy on Python 2.7 is depreciated.

Serhio

unread,
Mar 18, 2021, 7:12:08 AM3/18/21
to Kivy users support
Presumably the higher cpu usage is transitory.
It keeps using 30-35% always.

You can test this by creating an install that is not a single file ;)

Actually, my install is not a single file now (I don't use --onefile flag to create a one-file bundled executable).
I've tested one-file executable now - it used the same 30% CPU.


About Python2.7 - interesting idea. Later I'll do the same check with python3 and write the results here.
Reply all
Reply to author
Forward
0 new messages