본문 바로가기
PyQt5_

Creating a Windows installer with InstallForge

by 자동매매 2023. 3. 13.

38. Creating a Windows installer

with InstallForge

So far we’ve used PyInstaller to bundle applications for distribution. The output of this bundling process is a folder, named dist which contains all the files our application needs to run. While you could share this folder with your users as a ZIP file it’s not the best user experience.

Windows desktop applications are normally distributed with installers which handle the process of putting the executable (and any other files) in the correct place and adding Start Menu shortcuts. Next we’ll look at how we can take our dist folder and use it to create a functioning Windows installer.

To create our installer we’ll be using a tool called InstallForge. InstallForge is free and can be downloaded from this page. The working InstallForge configuration is available in the downloads for this book, as Hello World.ifp however bear in mind that the source paths will need to be updated for your system.

ë

If you’re impatient, you can download the Example Windows

Installer first.

We’ll now walk through the basic steps of creating an installer with InstallForge.

General

When you first run InstallForge you’ll be presented with this General tab. Here you can enter the basic information about your application, including the name, program version, company and website.

Figure 255. InstallForge initial view, showing General settings.

You can also select the target platforms for the installer, from various versions of Windows that are currently available. This ensures people can only install your application on versions of Windows which are compatible with it.

Z

There is no magic here, selecting additional platforms in the

installer won’t make your application work on them! You need

to check your application runs on the target versions of

Windows before enabling them in the installer.

Setup

Click on the left sidebar to open the "Files" page under "Setup". Here you can specify the files to be bundled in the installer.

Use "Add Files..." on the toolbar and select all the files in the dist/hello-world folder produced by PyInstaller. The file browser that pops up allows multiple file selections, so you can add them all in a single go, however you need to add folders separately. Click "Add Folder..." and add any folders under dist/hello- world such as your icons folder and other libraries.

Figure 256. InstallForge Files view, add all files & folders to be packaged.

ë

Contents of selected folders will be included recursively, you do

not need to select subfolders.

Once you’re finished scroll through the list to the bottom and ensure that the folders are listed to be included. You want all files and folders under dist/hello- world to be present. But the folder dist/hello-world itself should not be listed.

The default install path can be left as-is. The values between angled brackets, e.g.

, are variables and will be filled automatically from the configuration.

Next, it’s nice to allow your users to uninstall your application. Even though it’s undoubtedly awesome, they may want to remove it at some time in the future. You can do this under the "Uninstall" tab, simply by ticking the box. This will also make the application appear in Windows "Add or Remove Programs".

Figure 257. InstallForge add Uninstaller for your app.

Dialogs

The "Dialogs" section can be used to show custom messages, splash screens or license information to the user. The "Finish" tab lets you control what happens once the installer is complete, and it’s helpful here to give the user the option to run your program once it’s installed.

To do this you need to tick the box next to "Run program" and add your own application EXE into the box. Since \ is already specified, we can just add hello-world.exe. Arguments can be used to pass any arguments to the program on the first launch.

Figure 258. InstallForge configure optional run program on finish install.

System

Under "System" select "Shortcuts" to open the shortcut editor. Here you can specify shortcuts for both the Start Menu and Desktop if you like.

Figure 259. InstallForge configure Shortcuts, for Start Menu and Desktop.

Click "Add..." to add new shortcuts for your application. Choose between Start menu and Desktop shortcuts, and fill in the name and target file. This is the path your application EXE will end up at once installed. Since \ is already specified, you simply need to add your application’s EXE name onto the end, here hello-world.exe

Figure 260. InstallForge, adding a Shortcut.

Build

With the basic settings in place, you can now build your installer.

ë

At this point you can save your InstallForge project so you can

re-build the installer from the same settings in future.

Click on the "Build" section at the bottom to open the build panel.

Figure 261. InstallForge, ready to build.

Click on the Build icon on the toolbar to start the build process. If you haven’t already specified a setup file location you will be prompted for one. This is the location where you want the completed installer to be saved. The build process will began, collecting and compressing the files into the installer.

Figure 262. InstallForge, build complete.

Once complete you will be prompted to run the installer. This is entirely optional, but a handy way to find out if it works.

Running the installer

The installer itself shouldn’t have any surprises, working as expected. Depending on the options selected in InstallForge you may have extra panels or options.

Figure 263. InstallForge, running the resulting installer.

Step through the installer until it is complete. You can optionally run the application from the last page of the installer, or you can find it in your start menu.

Figure 264. Hello World in the Start Menu on Windows 11.

Wrapping up

In a previous chapter we covered how to build your PyQt6 applications into a distributable executable using PyInstaller. In this chapter we’ve taken this built PyInstaller application and walked through the steps of using InstallForge to build an installer for the app. Following these steps you should be able to package up your own applications and make them available to other people on Windows.

ë

Another popular tool for building Windows installers is NSIS

which is a scriptable installer, meaning you configure it’s

behavior by writing custom scripts. If you’re going to be

building your application frequently and want to automate the

process, it’s definitely worth a look.

'PyQt5_' 카테고리의 다른 글

Creating a Linux Package with  (0) 2023.03.13
Creating a macOS Disk Image Installer  (0) 2023.03.13
Packaging with PyInstaller  (0) 2023.03.13
Working with command-line arguments  (0) 2023.03.13
Enums & the Qt Namespace  (0) 2023.03.13

댓글