[PYTHON] Create an upgradeable msi file with cx_Freeze

The MSI Upgrade Code is a unique code for managing your application. If this is not specified, you will have to manually reinstall the package with each upgrade.

Generate a UUID (GUID) for the Upgrade Code

Run the following command in the Python interpreter. import uuid str(uuid.uuid3(uuid.NAMESPACE_DNS, 'appname.orgname.org')).upper()

This will generate a unique ID such as '3F2504E0-4F89-11D3-9A0C-0305E82C3301', so make a note of it.

Prepare setup.py

setup.py


#Application information
name = 'memopad'
version = '1.0.0'
author = 'example'
author_email = '[email protected]'
url = 'http://example.xxx'
description = 'Text Editor'

#Specify the GUID here (basically it should not be changed)
upgrade_code = '{3F2504E0-4F89-11D3-9A0C-0305E82C3301}'
#For 64-bit Windows, switch the installation folder
# ProgramFiles(64)Folder seems to be replaced with the actual directory on the msi side
programfiles_dir = 'ProgramFiles64Folder' if distutils.util.get_platform() == 'win-amd64' else 'ProgramFilesFolder'

#Options to use with the build command on Windows
build_exe_options = {
    'packages': ['os'],
    'excludes': ['tkinter'], #Exclude tkinter as it is not used
    'includes': ['PySide.QtCore', 'PySide.QtGui', 'gui', 'commands'],
    'include_files': ['img/', 'lang/', 'license/'],
    'include_msvcr': True, #Since it uses PySide, it cannot be started unless Microsoft's C runtime is included.
    'compressed'   : True
}

# bdist_Options to use with the msi command
bdist_msi_options = {
    'upgrade_code': upgrade_code,
    'add_to_path': False,
    'initial_target_dir': '[%s]\%s\%s' % (programfiles_dir, author, name)
}

options = {
    'build_exe': build_exe_options,
    'bdist_msi': bdist_msi_options
}

#exe information
base = 'Win32GUI' if sys.platform == 'win32' else None
icon = 'img/app_icon.ico'

mainexe = Executable(
    'main.py',
    targetName = 'Memopad.exe',
    base = base,
    icon = icon,
    copyDependentFiles = True
)

setup(
    name=name,
    version=version,
    author=author,
    author_email=author_email,
    url=url,
    description=description,
    options=options,
    executables=[mainexe]
)

Fixed windist.py in cx_Freeze

If you build it as it is, it will not pass the validation check of Orca (Microsoft's MSI editor), so modify'cx_Freeze / windist.py'in site-packages. Add the following tuple to the props list on line 230:

windist.py


('SecureCustomProperties', 'REMOVEOLDVERSION;REMOVENEWVERSION')

Build

python setup.py bdist_msi Just run. The exe and msi are created. Please note that if you change the UpgradeCode, it will not be considered as the same package and you will not be able to manage the package properly. Also, be aware that you may get a warning during installation without a digital signature.

Confirmation of MSI

Open the Orca-generated MSI and look at the Property table. If the GUID specified earlier is displayed in the UpgradeCode property, there should be no problem.

reference

distutils setup script — cx_Freeze 5.0 documentation Developer Course-Windows Installer

Recommended Posts

Create an upgradeable msi file with cx_Freeze
Create an Excel file with Python3
Quickly create an excel file with Python #python
Create an environment with virtualenv
Create an API with Django
[Python] Create a Tkinter program distribution file with cx_Freeze
Make an application using tkinter an executable file with cx_freeze
[Python Kivy] How to create an exe file with pyinstaller
Create an age group with pandas
Create a file uploader with Django
Create an application by classifying with Pygame
Create an image processing viewer with PySimpleGUI
Create a VM with a YAML file (KVM)
Create Excel file with Python + similarity matrix
[Python] Quickly create an API with Flask
Create an add-in-enabled Excel instance with xlwings
Create an English word app with python
Create an app that guesses students with python
Create an academic society program with combinatorial optimization
Create a GUI executable file created with tkinter
Create an executable file in a scripting language
Create an image with characters in python (Japanese)
Create a Photoshop format file (.psd) with python
Create a cylinder with open3d + STL file output
Create an API server quickly with Python + Falcon
Create an exe file that works in a Windows environment without Python with PyInstaller
Create an animated GIF local server with Python + Flask
Create an image file using PIL (Python Imaging Library).
Create an idol-like tweet with Keras LSTM (sentence generation)
An easy way to create an import module with jupyter
Create an app that guesses students with python-GUI version
Create a random number with an arbitrary probability density
Create an OpenAI Gym environment with bash on Windows 10
Type after reading an excel file with pandas read_excel
Create a 2d CAD file ".dxf" with python [ezdxf]
[WIP] Create 1-file Chainer
File operations with open — "../"
Create games with Pygame
Create filter with scipy
[Python] Create a file & folder path specification screen with tkinter
Until you edit an SVG file with AutoCAD to PNG.
Create an LCD (16x2) game with Raspberry Pi and Python
Minimum Makefile and buildout.cfg to create an environment with buildout
Create an example game-like stage with just the Blender 2.80 script
Let's create an app that authenticates with OIDC with Azure AD
I'm trying to create an authentication / authorization process with Django
Create an authentication feature with django-allauth and CustomUser in Django
How to read an Excel file (.xlsx) with Pandas [Python]
How to create an ISO file (CD image) on Linux
I tried to create an article in Wiki.js with SQLAlchemy