[Python] Python project packaging and release (5) (making Windows installation package)

Python project package release summary

【Python】Python project packaging release (1) (based on Pyinstaller packaging multi-directory project)
[Python] Python project packaging release (2) (based on Pyinstaller packaging PyWebIO project) [Python] Python project packaging release (3) (based on Aardio packaging
multi-directory project) [Python] Python project packaging release (
4) (based on Nuitka packaging PySide6 project)
[Python] Python project packaging release (5) (making Windows installation package)

illustrate

There are many tools for making Windows installation packages, among which the well-known ones are:

  • NSIS
  • WiX
  • InnoSetup
  • InstallShield
  • Advanced Installer

For example, Tarui comes with WiX and NSIS
insert image description here

1、NSIS

In the Python environment, there is an open source toolkit pynsist
github address: https://github.com/takluyver/pynsist

illustrate

pynsist does not compile any Python files, but only generates a shortcut to the Python file script, and the packaging directory will include the entire Python environment. Personal experience is not good, not recommended.

2、InnoSetup

Inno Setup is a powerful free installer maker. It has an easy-to-use scripting language to create installers with custom interface, installation options and scripting actions.
Inno Setup works great with nuitka! Recommended as a toolchain in the Python environment. You can refer to the configuration of the nuitka_build.py one-click packaging script I wrote under https://github.com/KmBase/Umi-OCR

The main functions of this script are:

Nuitka generates executable files, zipfile makes portable files, and InnoSetup makes installation files. If you do not need to generate a zip archive, or create an installation package. You can comment out the corresponding statements of create_portable() and create_portable()

if __name__ == '__main__':
    build()
    create_portable()
    if SYSTEM == 'Windows':
       create_portable()

illustrate

nuitka is a tool that can convert Python code to C++ code and compile it into executable files or extension modules. It can significantly improve the loading and running speed of python projects. Inno Setup is a free Windows installation program making software, a very simple and practical packaging gadget.

Steps for usage

1. Install project dependencies

pip install -r requirements.txt

2. Install nuitka

pip install -U nuitka

3. Install Inno Setup
Official website download address: https://jrsoftware.org/download.php/is.exe
Chinese language pack: https://raw.githubusercontent.com/jrsoftware/issrc/main/Files/Languages/Unofficial/ChineseSimplified.isl
Please save the language pack to the Inno Setup installation directory
insert image description here

4. Execute the script

python nuitka_build.py

5. Installation

  • Generate build directory, including nuitka compilation process file directory (main.build), executable file directory (main.release), Inno Setup installation script (.iss)
    insert image description here

  • Open the generated .iss file with Inno Setup, or double-click the .iss to open it. Click Run to generate the installation file
    image

  • The release directory contains portable compressed files and installation files
    insert image description here

  • Double-click the installation file, you can install Umi-OCR to the specified location
    insert image description here

6. Uninstall
Find Umi-OCR in the control panel and uninstall it
insert image description here

references:

https://www.cnblogs.com/chrisfang/p/17027553.html

Guess you like

Origin blog.csdn.net/qq_25262697/article/details/131627847
Recommended