Remove the pyinstaller setup functions
This commit is contained in:
@@ -489,127 +489,6 @@ def makeSimplePackage(embedPython):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
|
||||||
# Run PyInstaller on Package (freeze, onefile)
|
|
||||||
##
|
|
||||||
|
|
||||||
def freezePackage(buildWindowed, oneFile, makeSetup, hostOS):
|
|
||||||
"""Run PyInstaller to freeze the packages. This assumes all
|
|
||||||
dependencies are already in place.
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
import PyInstaller.__main__ # noqa: E402
|
|
||||||
except ImportError:
|
|
||||||
print(
|
|
||||||
"ERROR: Package 'pyinstaller' is missing on this system.\n"
|
|
||||||
" Please run 'pip install --user pyinstaller'."
|
|
||||||
)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
print("")
|
|
||||||
print("Running PyInstaller")
|
|
||||||
print("===================")
|
|
||||||
print("")
|
|
||||||
|
|
||||||
if hostOS == OS_WIN:
|
|
||||||
dotDot = ";"
|
|
||||||
else:
|
|
||||||
dotDot = ":"
|
|
||||||
|
|
||||||
sys.modules["FixTk"] = None
|
|
||||||
instOpt = [
|
|
||||||
"--name=novelWriter",
|
|
||||||
"--clean",
|
|
||||||
"--add-data=%s%s%s" % (os.path.join("nw", "assets"), dotDot, "assets"),
|
|
||||||
"--icon=%s" % os.path.join("nw", "assets", "icons", "novelwriter.ico"),
|
|
||||||
"--exclude-module=PyQt5.QtQml",
|
|
||||||
"--exclude-module=PyQt5.QtBluetooth",
|
|
||||||
"--exclude-module=PyQt5.QtDBus",
|
|
||||||
"--exclude-module=PyQt5.QtMultimedia",
|
|
||||||
"--exclude-module=PyQt5.QtMultimediaWidgets",
|
|
||||||
"--exclude-module=PyQt5.QtNetwork",
|
|
||||||
"--exclude-module=PyQt5.QtNetworkAuth",
|
|
||||||
"--exclude-module=PyQt5.QtNfc",
|
|
||||||
"--exclude-module=PyQt5.QtQuick",
|
|
||||||
"--exclude-module=PyQt5.QtQuickWidgets",
|
|
||||||
"--exclude-module=PyQt5.QtRemoteObjects",
|
|
||||||
"--exclude-module=PyQt5.QtSensors",
|
|
||||||
"--exclude-module=PyQt5.QtSerialPort",
|
|
||||||
"--exclude-module=PyQt5.QtSql",
|
|
||||||
"--exclude-module=FixTk",
|
|
||||||
"--exclude-module=tcl",
|
|
||||||
"--exclude-module=tk",
|
|
||||||
"--exclude-module=_tkinter",
|
|
||||||
"--exclude-module=tkinter",
|
|
||||||
"--exclude-module=Tkinter",
|
|
||||||
]
|
|
||||||
|
|
||||||
if buildWindowed:
|
|
||||||
instOpt.append("--windowed")
|
|
||||||
|
|
||||||
if oneFile and not makeSetup:
|
|
||||||
instOpt.append("--onefile")
|
|
||||||
else:
|
|
||||||
instOpt.append("--onedir")
|
|
||||||
|
|
||||||
instOpt.append("novelWriter.py")
|
|
||||||
|
|
||||||
# Make sample.zip first
|
|
||||||
try:
|
|
||||||
buildSampleZip()
|
|
||||||
except Exception as e:
|
|
||||||
print("Failed with error:")
|
|
||||||
print(str(e))
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
PyInstaller.__main__.run(instOpt)
|
|
||||||
|
|
||||||
if not oneFile:
|
|
||||||
# These files are not needed, and take up a fair bit of space.
|
|
||||||
delFiles = []
|
|
||||||
if hostOS == OS_WIN:
|
|
||||||
delFiles = [
|
|
||||||
"Qt5DBus.dll",
|
|
||||||
"Qt5Network.dll",
|
|
||||||
"Qt5Qml.dll",
|
|
||||||
"Qt5QmlModels.dll",
|
|
||||||
"Qt5Quick.dll",
|
|
||||||
"Qt5Quick3D.dll",
|
|
||||||
"Qt5Quick3DAssetImport.dll",
|
|
||||||
"Qt5Quick3DRender.dll",
|
|
||||||
"Qt5Quick3DRuntimeRender.dll",
|
|
||||||
"Qt5Quick3DUtils.dll",
|
|
||||||
"Qt5Sql.dll"
|
|
||||||
]
|
|
||||||
elif hostOS == OS_LINUX:
|
|
||||||
delFiles = [
|
|
||||||
"libQt5DBus.so.5",
|
|
||||||
"libQt5Network.so.5",
|
|
||||||
"libQt5Qml.so.5",
|
|
||||||
"libQt5QmlModels.so.5",
|
|
||||||
"libQt5Quick.so.5",
|
|
||||||
"libQt5Quick3D.so.5",
|
|
||||||
"libQt5Quick3DAssetImport.so.5",
|
|
||||||
"libQt5Quick3DRender.so.5",
|
|
||||||
"libQt5Quick3DRuntimeRender.so.5",
|
|
||||||
"libQt5Quick3DUtils.so.5",
|
|
||||||
"libQt5Sql.so.5"
|
|
||||||
]
|
|
||||||
distDir = os.path.join(os.getcwd(), "dist", "novelWriter")
|
|
||||||
for delFile in delFiles:
|
|
||||||
delPath = os.path.join(distDir, delFile)
|
|
||||||
if os.path.isfile(delPath):
|
|
||||||
print("Deleting file: %s" % delPath)
|
|
||||||
os.unlink(delPath)
|
|
||||||
|
|
||||||
print("")
|
|
||||||
print("Build Finished")
|
|
||||||
print("")
|
|
||||||
print("The novelWriter executable should be in the folder named 'dist'")
|
|
||||||
print("")
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
# =============================================================================================== #
|
# =============================================================================================== #
|
||||||
# General Installers
|
# General Installers
|
||||||
# =============================================================================================== #
|
# =============================================================================================== #
|
||||||
@@ -888,9 +767,8 @@ def winInstall():
|
|||||||
# Inno Setup Builder (setup-exe, setup-pyz)
|
# Inno Setup Builder (setup-exe, setup-pyz)
|
||||||
##
|
##
|
||||||
|
|
||||||
def innoSetup(setupType):
|
def innoSetup():
|
||||||
"""Run the Inno Setup tool to build a setup.exe file for Windows based on either a pyinstaller
|
"""Run the Inno Setup tool to build a setup.exe file for Windows based on the pyz package.
|
||||||
freeze package (exe) or a zipapp package (pyz).
|
|
||||||
"""
|
"""
|
||||||
print("")
|
print("")
|
||||||
print("Running Inno Setup")
|
print("Running Inno Setup")
|
||||||
@@ -899,7 +777,7 @@ def innoSetup(setupType):
|
|||||||
|
|
||||||
# Read the iss template
|
# Read the iss template
|
||||||
issData = ""
|
issData = ""
|
||||||
with open(os.path.join("setup", "win_setup_%s.iss" % setupType), mode="r") as inFile:
|
with open(os.path.join("setup", "win_setup_pyz.iss"), mode="r") as inFile:
|
||||||
issData = inFile.read()
|
issData = inFile.read()
|
||||||
|
|
||||||
import nw # noqa: E402
|
import nw # noqa: E402
|
||||||
@@ -938,14 +816,14 @@ if __name__ == "__main__":
|
|||||||
hostOS = OS_NONE
|
hostOS = OS_NONE
|
||||||
|
|
||||||
# Set Target OS
|
# Set Target OS
|
||||||
if "--linux" in sys.argv:
|
if "--target-linux" in sys.argv:
|
||||||
sys.argv.remove("--linux")
|
sys.argv.remove("--target-linux")
|
||||||
targetOS = OS_LINUX
|
targetOS = OS_LINUX
|
||||||
elif "--darwin" in sys.argv:
|
elif "--target-darwin" in sys.argv:
|
||||||
sys.argv.remove("--darwin")
|
sys.argv.remove("--target-darwin")
|
||||||
targetOS = OS_DARWIN
|
targetOS = OS_DARWIN
|
||||||
elif "--win" in sys.argv:
|
elif "--target-win" in sys.argv:
|
||||||
sys.argv.remove("--win")
|
sys.argv.remove("--target-win")
|
||||||
targetOS = OS_WIN
|
targetOS = OS_WIN
|
||||||
else:
|
else:
|
||||||
targetOS = hostOS
|
targetOS = hostOS
|
||||||
@@ -959,7 +837,7 @@ if __name__ == "__main__":
|
|||||||
"as a package on Linux, Mac and Windows. The available options are as follows:\n"
|
"as a package on Linux, Mac and Windows. The available options are as follows:\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Some of the commands can be targeted towards a different OS than the host OS. To target\n"
|
"Some of the commands can be targeted towards a different OS than the host OS. To target\n"
|
||||||
"the command, add one of '--linux', '--darwin' or '--win'.\n"
|
"the command, add one of '--target-linux', '--target-darwin' or '--target-win'.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"General:\n"
|
"General:\n"
|
||||||
"\n"
|
"\n"
|
||||||
@@ -980,12 +858,9 @@ if __name__ == "__main__":
|
|||||||
" other source files. Accepts a target OS flag.\n"
|
" other source files. Accepts a target OS flag.\n"
|
||||||
" pack-pyz Creates a pyz package in a folder with all dependencies using the\n"
|
" pack-pyz Creates a pyz package in a folder with all dependencies using the\n"
|
||||||
" zipapp tool. On Windows, python embeddable is added to the folder.\n"
|
" zipapp tool. On Windows, python embeddable is added to the folder.\n"
|
||||||
" freeze Freeze the package and produces a folder with all dependencies using\n"
|
" setup-pyz Build a Windows installer from a zipapp package using Inno Setup.\n"
|
||||||
" the pyinstaller tool. This option is not designed for a specific OS.\n"
|
|
||||||
" onefile Build a standalone executable with all dependencies bundled using the\n"
|
|
||||||
" pyinstaller tool. Implies 'freeze', cannot be used with 'setup-exe'.\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
"General Installers:\n"
|
"System Install:\n"
|
||||||
"\n"
|
"\n"
|
||||||
" install Installs novelWriter to the system's Python install location. Run as \n"
|
" install Installs novelWriter to the system's Python install location. Run as \n"
|
||||||
" root or with sudo for system-wide install, or as user for single user \n"
|
" root or with sudo for system-wide install, or as user for single user \n"
|
||||||
@@ -993,20 +868,10 @@ if __name__ == "__main__":
|
|||||||
" xdg-install Install launcher and icons for freedesktop systems. Run as root or \n"
|
" xdg-install Install launcher and icons for freedesktop systems. Run as root or \n"
|
||||||
" with sudo for system-wide install, or as user for single user install.\n"
|
" with sudo for system-wide install, or as user for single user install.\n"
|
||||||
" win-install Install desktop and start menu icons for Windows systems.\n"
|
" win-install Install desktop and start menu icons for Windows systems.\n"
|
||||||
"\n"
|
|
||||||
"Windows Installers:\n"
|
|
||||||
"\n"
|
|
||||||
" setup-exe Build a Windows installer from a pyinstaller freeze package using Inno\n"
|
|
||||||
" Setup. This option automatically disables 'onefile'.\n"
|
|
||||||
" setup-pyz Build a Windows installer from a zipapp package using Inno Setup.\n"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Flags and Variables
|
# Flags and Variables
|
||||||
buildWindowed = True
|
|
||||||
oneFile = False
|
|
||||||
makeSetupExe = False
|
|
||||||
makeSetupPyz = False
|
makeSetupPyz = False
|
||||||
doFreeze = False
|
|
||||||
simplePack = False
|
simplePack = False
|
||||||
embedPython = False
|
embedPython = False
|
||||||
|
|
||||||
@@ -1050,15 +915,6 @@ if __name__ == "__main__":
|
|||||||
if hostOS == OS_WIN:
|
if hostOS == OS_WIN:
|
||||||
embedPython = True
|
embedPython = True
|
||||||
|
|
||||||
if "freeze" in sys.argv:
|
|
||||||
sys.argv.remove("freeze")
|
|
||||||
doFreeze = True
|
|
||||||
|
|
||||||
if "onefile" in sys.argv:
|
|
||||||
sys.argv.remove("onefile")
|
|
||||||
doFreeze = True
|
|
||||||
oneFile = True
|
|
||||||
|
|
||||||
# General Installers
|
# General Installers
|
||||||
# ==================
|
# ==================
|
||||||
|
|
||||||
@@ -1083,23 +939,12 @@ if __name__ == "__main__":
|
|||||||
print("ERROR: Command 'win-install' can only be used on Windows")
|
print("ERROR: Command 'win-install' can only be used on Windows")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Windows Setup Installers
|
# Windows Setup Installer
|
||||||
# ========================
|
# =======================
|
||||||
|
|
||||||
if "setup-exe" in sys.argv:
|
|
||||||
sys.argv.remove("setup-exe")
|
|
||||||
if hostOS == OS_WIN:
|
|
||||||
oneFile = False
|
|
||||||
makeSetupExe = True
|
|
||||||
makeSetupPyz = False
|
|
||||||
else:
|
|
||||||
print("Error: Command 'setup-exe' for Inno Setup is Windows only.")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if "setup-pyz" in sys.argv:
|
if "setup-pyz" in sys.argv:
|
||||||
sys.argv.remove("setup-pyz")
|
sys.argv.remove("setup-pyz")
|
||||||
if hostOS == OS_WIN:
|
if hostOS == OS_WIN:
|
||||||
makeSetupExe = False
|
|
||||||
makeSetupPyz = True
|
makeSetupPyz = True
|
||||||
else:
|
else:
|
||||||
print("Error: Command 'setup-pyz' for Inno Setup is Windows only.")
|
print("Error: Command 'setup-pyz' for Inno Setup is Windows only.")
|
||||||
@@ -1113,14 +958,8 @@ if __name__ == "__main__":
|
|||||||
if simplePack:
|
if simplePack:
|
||||||
makeSimplePackage(embedPython)
|
makeSimplePackage(embedPython)
|
||||||
|
|
||||||
if doFreeze:
|
|
||||||
freezePackage(buildWindowed, oneFile, makeSetupExe, hostOS)
|
|
||||||
|
|
||||||
if makeSetupExe:
|
|
||||||
innoSetup("exe")
|
|
||||||
|
|
||||||
if makeSetupPyz:
|
if makeSetupPyz:
|
||||||
innoSetup("pyz")
|
innoSetup()
|
||||||
|
|
||||||
if len(sys.argv) <= 1:
|
if len(sys.argv) <= 1:
|
||||||
# Nothing more to do
|
# Nothing more to do
|
||||||
|
|||||||
+6
-13
@@ -8,6 +8,10 @@ The root folder of the repository contains two scripts for setup and install:
|
|||||||
The `setup.py` is a standard Python setup script with a couple of additional
|
The `setup.py` is a standard Python setup script with a couple of additional
|
||||||
options:
|
options:
|
||||||
|
|
||||||
|
Some of the commands can be targeted towards a different OS than the host OS.
|
||||||
|
To target the command, add one of `--target-linux`, `--target-darwin` or
|
||||||
|
`--target-win`.
|
||||||
|
|
||||||
### General
|
### General
|
||||||
|
|
||||||
`help` – Print the help message.
|
`help` – Print the help message.
|
||||||
@@ -32,13 +36,9 @@ the other source files.
|
|||||||
`pack-pyz` – Creates a pyz package in a folder with all dependencies using the
|
`pack-pyz` – Creates a pyz package in a folder with all dependencies using the
|
||||||
zipapp tool. On Windows, python embeddable is added to the folder.
|
zipapp tool. On Windows, python embeddable is added to the folder.
|
||||||
|
|
||||||
`freeze` – Freeze the package and produces a folder with all dependencies using
|
`setup-pyz` – Build a Windows installer from a zipapp package using Inno Setup.
|
||||||
the pyinstaller tool. This option is not designed for a specific OS.
|
|
||||||
|
|
||||||
`onefile` – Build a standalone executable with all dependencies bundled using
|
### System Install
|
||||||
the pyinstaller tool. Implies `freeze`, cannot be used with `setup-exe`.
|
|
||||||
|
|
||||||
### General Installers
|
|
||||||
|
|
||||||
`install` – Installs novelWriter to the system's Python install location. Run
|
`install` – Installs novelWriter to the system's Python install location. Run
|
||||||
as root or with sudo for system-wide install, or as user for single user
|
as root or with sudo for system-wide install, or as user for single user
|
||||||
@@ -48,10 +48,3 @@ install.
|
|||||||
or with sudo for system-wide install, or as user for single user install.
|
or with sudo for system-wide install, or as user for single user install.
|
||||||
|
|
||||||
`win-install` – Install desktop and start menu icons for Windows systems.
|
`win-install` – Install desktop and start menu icons for Windows systems.
|
||||||
|
|
||||||
### "Windows Installers
|
|
||||||
|
|
||||||
`setup-exe` – Build a Windows installer from a pyinstaller freeze package using
|
|
||||||
Inno Setup. This option automatically disables `onefile`.
|
|
||||||
|
|
||||||
`setup-pyz` – Build a Windows installer from a zipapp package using Inno Setup.
|
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
; Script generated by the Inno Setup Script Wizard.
|
|
||||||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
|
||||||
|
|
||||||
#define nwAppDir "%%dir%%\dist"
|
|
||||||
#define nwAppName "novelWriter"
|
|
||||||
#define nwAppVersion "%%version%%"
|
|
||||||
#define nwAppPublisher "novelWriter"
|
|
||||||
#define nwAppURL "http://novelWriter.io"
|
|
||||||
#define nwAppExeName "novelWriter.exe"
|
|
||||||
|
|
||||||
[Setup]
|
|
||||||
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
|
|
||||||
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
|
|
||||||
AppId={{459A75D0-951F-4932-9809-6002EC8E733E}
|
|
||||||
AppName={#nwAppName}
|
|
||||||
AppVersion={#nwAppVersion}
|
|
||||||
AppVerName={#nwAppName} {#nwAppVersion}
|
|
||||||
AppPublisher={#nwAppPublisher}
|
|
||||||
AppPublisherURL={#nwAppURL}
|
|
||||||
AppSupportURL={#nwAppURL}
|
|
||||||
AppUpdatesURL={#nwAppURL}
|
|
||||||
DefaultDirName={autopf}\{#nwAppName}
|
|
||||||
DisableProgramGroupPage=yes
|
|
||||||
; The [Icons] "quicklaunchicon" entry uses {userappdata} but its [Tasks] entry has a proper IsAdminInstallMode Check.
|
|
||||||
UsedUserAreasWarning=no
|
|
||||||
; Uncomment the following line to run in non administrative install mode (install for current user only.)
|
|
||||||
;PrivilegesRequired=lowest
|
|
||||||
PrivilegesRequiredOverridesAllowed=dialog
|
|
||||||
OutputDir={#nwAppDir}
|
|
||||||
OutputBaseFilename=novelwriter-{#nwAppVersion}-win10-amd64-setup
|
|
||||||
Compression=lzma
|
|
||||||
SolidCompression=yes
|
|
||||||
WizardStyle=modern
|
|
||||||
ArchitecturesInstallIn64BitMode=x64
|
|
||||||
ChangesAssociations=yes
|
|
||||||
|
|
||||||
[Languages]
|
|
||||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
|
||||||
|
|
||||||
[Tasks]
|
|
||||||
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
|
||||||
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 6.1; Check: not IsAdminInstallMode
|
|
||||||
|
|
||||||
[Files]
|
|
||||||
Source: "{#nwAppDir}\novelWriter\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
|
|
||||||
|
|
||||||
[Icons]
|
|
||||||
Name: "{autoprograms}\{#nwAppName}"; Filename: "{app}\{#nwAppExeName}"
|
|
||||||
Name: "{autodesktop}\{#nwAppName}"; Filename: "{app}\{#nwAppExeName}"; Tasks: desktopicon
|
|
||||||
|
|
||||||
[Run]
|
|
||||||
Filename: "{app}\{#nwAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(nwAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
|
|
||||||
|
|
||||||
[Registry]
|
|
||||||
Root: HKA; Subkey: "Software\Classes\.nwx\OpenWithProgids"; ValueType: string; ValueName: "novelWriterProject.nwx"; ValueData: ""; Flags: uninsdeletevalue
|
|
||||||
Root: HKA; Subkey: "Software\Classes\novelWriterProject.nwx"; ValueType: string; ValueName: ""; ValueData: "novelWriter Project File"; Flags: uninsdeletekey
|
|
||||||
Root: HKA; Subkey: "Software\Classes\novelWriterProject.nwx\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\assets\icons\x-novelwriter-project.ico"
|
|
||||||
Root: HKA; Subkey: "Software\Classes\novelWriterProject.nwx\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#nwAppExeName}"" ""%1"""
|
|
||||||
Root: HKA; Subkey: "Software\Classes\Applications\{#nwAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".nwx"; ValueData: ""
|
|
||||||
Reference in New Issue
Block a user