Python: Excluding Modules Pyinstaller

前端 未结 4 1029
有刺的猬
有刺的猬 2020-11-29 04:16

I\'ve begun using Pyinstaller over Py2Exe. However I\'ve rather quickly run into a problem. How do I exclude modules that I don\'t want, and how do I view the ones that are

4条回答
  •  死守一世寂寞
    2020-11-29 04:57

    FIND THE ANSWER BY YOURSELF

    I've seen a lot of questions like this, but no one teaches you how to debug by yourself.

    document of pyinstaller may have useful for beginner, but once you need more ...

    personally, think the pyinstaller documentation is not friendly (Too few examples) and lacks updates.

    for example, The document shows the version of the pyinstaller is 3.2. (3.5 is available now (2019/10/5))

    I want to say that you should find the answer from source code

    START WAY

    • create a script file (for example, run_pyinstaller.py) as below:
    # run_pyinstaller.py
    
    from PyInstaller.__main__ import run
    run()
    
    • before you run this script you can assign parameters, like "--clean your.spec"

    • set breakpoint at {env_path}/Lib/site-packages/PyInstaller/building/build_main.py -> def build(...) ... -> exec(code, spec_namespace) like below:

      note: If you are not using the virtual environment, the actual path should be {Python}/Lib/site-packages/PyInstaller/building/build_main.py

    • finally, you run here and press button of step into. you will into .spec file

    then you can watch any variables that you interested in.

    also, you will learn more about pyinstaller.exe actually do what.

    for example, you learn the class of TOC is inherits to list, and see more the detail than the document from PyInstaller.building.datastruct

    eventually, you can use any python way to set a.binaries and a.datas that is you really wanted

    ASSOCIATED FILE LOCATION

    from PyInstaller.building.datastruct import TOC, Tree
    from PyInstaller.building.build_main import Analysis
    from PyInstaller.building.api import EXE, PYZ, COLLECT, PKG, MERGE
    

提交回复
热议问题