Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. The most size-efficient way to build Windows app from a PySide app

The most size-efficient way to build Windows app from a PySide app

Scheduled Pinned Locked Moved Unsolved Qt for Python
5 Posts 3 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    midnightdim
    wrote on last edited by midnightdim
    #1

    I have an open source PySide app that I'd like to build and distribute as a Windows desktop app (and also Mac and Linux in the future).
    I'm currently using cxfreeze with a build script to build the app and Inno Setup to create the installer.

    I noticed that when I build the app with cxfreeze the biggest folder inside lib folder is PySide2. It's around 322Mb when I build it.
    The app is rather minimalistic, so it's a bit confusing that even the packaged installer is almost 100Mb. I'd like to reduce this size as much as possible.

    I noticed that I can delete some big files inside PySide2 subfolder and it doesn't affect the functioning of the app, because I'm not using the corresponding components: Qt5WebEngineCore.dll, Qt5Designer.dll, etc.

    I also found that it's safe to delete some subfolders like examples, resources, qml and even translations.

    So my questions are:

    1. What's the best way to build an executable app from a PySide app for Windows (7,10)?
    2. How can I get rid of unused files and folders? How can this be automated?
    3. What's the best practice for building the app for Mac and Linux?

    Thanks.

    1 Reply Last reply
    0
    • ewerybodyE Offline
      ewerybodyE Offline
      ewerybody
      wrote on last edited by
      #2

      Hello @midnightdim 👋 I cannot say much about cxfreeze. According to the docs its one of the 2 that supports PySide6? nice.
      Well. I dunno whats the best 🤷‍♀️ But I can tell about my process of building releases for Windows.

      I'm using PyInstaller and some post assembly python scripts for cleanup and installer creation. My stats are:

      • ~58.5mb for the unpacked PySide2 python app dir
      • ~27mb for the zipped portable pack
      • ~18mb for the installer executable using 7zip self extractor.

      I saw other people talking about using UPX to compress some of the Qt-dlls but so far I'm happy with the sizes. So I didn't fiddle with it.

      M 1 Reply Last reply
      3
      • ewerybodyE ewerybody

        Hello @midnightdim 👋 I cannot say much about cxfreeze. According to the docs its one of the 2 that supports PySide6? nice.
        Well. I dunno whats the best 🤷‍♀️ But I can tell about my process of building releases for Windows.

        I'm using PyInstaller and some post assembly python scripts for cleanup and installer creation. My stats are:

        • ~58.5mb for the unpacked PySide2 python app dir
        • ~27mb for the zipped portable pack
        • ~18mb for the installer executable using 7zip self extractor.

        I saw other people talking about using UPX to compress some of the Qt-dlls but so far I'm happy with the sizes. So I didn't fiddle with it.

        M Offline
        M Offline
        midnightdim
        wrote on last edited by midnightdim
        #3

        @ewerybody Hi and thanks!

        Is it correct that you're shipping your app as a "portable version", i.e. without the installation?
        I'm going to try reusing your finish_package.py, looks like it does some cleanup that I'm looking for.
        Could you please shed some light on what's the best way to apply these scripts? What kind of tweaking do I need to use it with my app?
        Is there a simpler solution? For example, just a script that would delete unused dlls?

        Although I'm not using Qt6 yet, I'd really like to switch to PySide6/Qt6 in the future, so would be glad to hear the suggestions for building the app with cxfreeze. Or maybe pyinstaller is going to support it in the near future.

        Gojir4G 1 Reply Last reply
        0
        • M midnightdim

          @ewerybody Hi and thanks!

          Is it correct that you're shipping your app as a "portable version", i.e. without the installation?
          I'm going to try reusing your finish_package.py, looks like it does some cleanup that I'm looking for.
          Could you please shed some light on what's the best way to apply these scripts? What kind of tweaking do I need to use it with my app?
          Is there a simpler solution? For example, just a script that would delete unused dlls?

          Although I'm not using Qt6 yet, I'd really like to switch to PySide6/Qt6 in the future, so would be glad to hear the suggestions for building the app with cxfreeze. Or maybe pyinstaller is going to support it in the near future.

          Gojir4G Offline
          Gojir4G Offline
          Gojir4
          wrote on last edited by
          #4

          Hello @midnightdim,

          First, did you try to use "exclude" argument in cxfreeze setup script ? It may help to reduce size according to this post on stackoverflow

          Since you're planning to switch to PySide6, you may be interested by nuitka. It compiles Python code to c code and make a "true" executable. It's partially supported on PySide2 but seems PySide6 is fully supported. I didn't test it yet but it looks promising.

          M 1 Reply Last reply
          1
          • Gojir4G Gojir4

            Hello @midnightdim,

            First, did you try to use "exclude" argument in cxfreeze setup script ? It may help to reduce size according to this post on stackoverflow

            Since you're planning to switch to PySide6, you may be interested by nuitka. It compiles Python code to c code and make a "true" executable. It's partially supported on PySide2 but seems PySide6 is fully supported. I didn't test it yet but it looks promising.

            M Offline
            M Offline
            midnightdim
            wrote on last edited by
            #5

            @Gojir4 Thanks. Yes, I'm using "excludes", but the question is: what exactly should I exclude (at least in PySide). I know what I'm using, does it mean that I have to review all PySide2 packages and add everything that I don't use to "excludes"?

            And yes, thanks for the tip, I looked at nuitka and it looks promising indeed. Going to try it, but @ewerybody 's approach seems very solid, so I'm reaching out to him to get some further advice.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved