cx_Freeze - Preventing including unneeded packages

后端 未结 3 1379
心在旅途
心在旅途 2021-02-04 04:49

I have coded a tiny python program using PyQt4. Now, I want to use cx_Freeze to create a standalone application. Everything works fine - cx_Freeze includes automatically all nec

3条回答
  •  孤城傲影
    2021-02-04 05:28

    I was having a similar problem on a very simple PyQt4 Gui for a small database where the program was 58Mb for a small amount of code, the problem being that the entire PyQt4 folder was being included in the program.

    The article here refers to using zip_include_packages in your options to exclude files or to compress them to reduce the file size.

    I excluded the entire PyQt4 folder and then included the bits I needed as shown below and it reduced the whole package to 16Mb automatically

    options = {
    'build_exe': {
        'packages':packages,
        'zip_include_packages':'PyQt4',
        'includes':['PyQt4.QtCore','PyQt4.QtGui','sqlite3','sys','os'],
    },
    

    Not sure it is the right way to do it but seems to have no negative impact on my program as of yet

提交回复
热议问题