Reduce size of freeze build and added more documentation

This commit is contained in:
Veronica K. B. Olsen
2020-10-17 15:52:40 +02:00
parent 614572ca80
commit 3378b387cf
3 changed files with 75 additions and 21 deletions
+2
View File
@@ -78,6 +78,8 @@ for debugging.
You can also provide a path to a folder containing a novelWriter project as the last parameter. You can also provide a path to a folder containing a novelWriter project as the last parameter.
For more install options, see [Build and Install novelWriter](setup/BUILD.md).
### Launcher and Icons ### Launcher and Icons
+29 -21
View File
@@ -28,28 +28,29 @@ OS_DARWIN = 3
# Package Installer # Package Installer
# =============================================================================================== # # =============================================================================================== #
def installPackages(): def installPackages(hostOS):
"""Install package dependencies both for this script and for running
novelWriter itself.
"""
print("") print("")
print("Installing Dependencies") print("Installing Dependencies")
print("#######################") print("#######################")
print("") print("")
try:
subprocess.call([ installQueue = ["pip", "pyinstaller", "-r requirements.txt"]
sys.executable, "-m", if hostOS == OS_DARWIN:
"pip", "install", "--user", "--upgrade", "pip" installQueue.append("pyobjc")
])
subprocess.call([ pyCmd = [sys.executable, "-m"]
sys.executable, "-m", pipCmd = ["pip", "install", "--user", "--upgrade"]
"pip", "install", "--user", "--upgrade", "pyinstaller" for stepCmd in installQueue:
]) pkgCmd = stepCmd.split(" ")
subprocess.call([ try:
sys.executable, "-m", subprocess.call(pyCmd + pipCmd + pkgCmd)
"pip", "install", "--user", "--upgrade", "-r", "requirements.txt" except Exception as e:
]) print("Failed with error:")
except Exception as e: print(str(e))
print("Failed with error:") sys.exit(1)
print(str(e))
sys.exit(1)
return return
@@ -73,6 +74,7 @@ def freezePackage(buildWindowed, oneFile, makeSetup, hostOS):
else: else:
dotDot = ":" dotDot = ":"
sys.modules["FixTk"] = None
instOpt = [ instOpt = [
"--name=novelWriter", "--name=novelWriter",
"--clean", "--clean",
@@ -92,6 +94,12 @@ def freezePackage(buildWindowed, oneFile, makeSetup, hostOS):
"--exclude-module=PyQt5.QtSensors", "--exclude-module=PyQt5.QtSensors",
"--exclude-module=PyQt5.QtSerialPort", "--exclude-module=PyQt5.QtSerialPort",
"--exclude-module=PyQt5.QtSql", "--exclude-module=PyQt5.QtSql",
"--exclude-module=FixTk",
"--exclude-module=tcl",
"--exclude-module=tk",
"--exclude-module=_tkinter",
"--exclude-module=tkinter",
"--exclude-module=Tkinter",
] ]
if buildWindowed: if buildWindowed:
@@ -263,8 +271,9 @@ if __name__ == "__main__":
"This tool provides build commands for distibuting novelWriter as a\n" "This tool provides build commands for distibuting novelWriter as a\n"
"package. The available options are as follows:\n" "package. The available options are as follows:\n"
"\n" "\n"
"help Print the help message.\n"
"freeze Freeze the package and produces a folder of all\n" "freeze Freeze the package and produces a folder of all\n"
" dependecies using pyinstaller.\n" " dependencies using pyinstaller.\n"
"onefile Build a standalone executable with all dependencies\n" "onefile Build a standalone executable with all dependencies\n"
" bundled. Implies 'freeze', cannot be used with 'setup'.\n" " bundled. Implies 'freeze', cannot be used with 'setup'.\n"
"pip Run pip to install all package dependencies for\n" "pip Run pip to install all package dependencies for\n"
@@ -290,11 +299,10 @@ if __name__ == "__main__":
if "clean" in sys.argv: if "clean" in sys.argv:
sys.argv.remove("clean") sys.argv.remove("clean")
cleanInstall() cleanInstall()
sys.exit(0)
if "pip" in sys.argv: if "pip" in sys.argv:
sys.argv.remove("pip") sys.argv.remove("pip")
installPackages() installPackages(hostOS)
if "freeze" in sys.argv: if "freeze" in sys.argv:
sys.argv.remove("freeze") sys.argv.remove("freeze")
+44
View File
@@ -0,0 +1,44 @@
# Build and Install novelWriter
The root folder of the repository contains two scripts for setup and install:
## Script `setup.py`
The `setup.py` is a standard Python setup script with a couple of additional options:
* `qthelp`: Will attempt to build a single file QtAssistand documentation file.
This requires the Qt tools to be installed on the local system, as well as the sphinx build tools
for the documentation.
* `sample`: Will create a `sample.zip` file in the `nw/assets` folder.
This is the file the New Project Wizard uses to generate an example project.
If novelWriter is run from source, this file is not needed.
To install novelWriter as a local Python package, run:
```bash
sudo python setup.py install
```
## Script `make.py`
The `make.py` script provides a number of convenient options for building packages if novelWriter.
Usage:
```bash
python make.py [command]
```
It currently accept the following commands:
* `help`: Print the help message.
* `freeze`: Freeze the package and produces a folder of all dependencies using pyinstaller.
* `onefile`: Build a standalone executable with all dependencies bundled.
Implies `freeze`, cannot be used with `setup`.
* `pip`: Run pip to install all package dependencies for novelWriter and this build tool.
* `setup`: Build a setup.exe installer for Windows.
This option automaticall disables the `onefile` option.
* `clean`: This will attempt to delete the `build` and `dist` folders in the current folder.
For instance, to create a Windows installer, run:
```bash
python make.py freeze setup
```