Merge pull request #642 from vkbo/minimal_zip

Minimal Zip Package
This commit is contained in:
Veronica K. Berglyd Olsen
2021-02-03 19:40:42 +00:00
committed by GitHub
3 changed files with 81 additions and 8 deletions
+9 -3
View File
@@ -191,9 +191,15 @@ novelWriter
### Setup on Windows ### Setup on Windows
For Windows, you can either install via PyPi, or use the Windows installer available from the For Windows, first ensure that you have Python installed. If not, get it from
[releases](https://github.com/vkbo/novelWriter/releases) page. This should add the necessary icons [python.org/downloads](https://www.python.org/downloads/). Remember to select "Add Python to PATH"
to your desktop and start menu. during the installation, otherwise novelWriter cannot find it.
Then, download the `novelWriter-x.y.z-minimal.zip` file, where `x.y.z` is the version number, from
the [releases](https://github.com/vkbo/novelWriter/releases) page. You can extract it to wherever
you want to keep novelWriter on your PC, and run the `setup_windows.bat` file in it
(double-clicking it should work). This will install the necessary dependencies from
[pypi,org](https://pypi.org/) and create desktop and start menu icons.
## Debugging ## Debugging
+72 -2
View File
@@ -231,7 +231,71 @@ def buildSampleZip():
# =============================================================================================== # # =============================================================================================== #
## ##
# Make Simple Package (winpack) # Make Minimal Package (minimal-zip)
##
def makeMinimalPackage():
"""Pack the core source file in a single zip file.
"""
from nw import __version__
from zipfile import ZipFile
# Make sample.zip first
try:
buildSampleZip()
except Exception as e:
print("Failed with error:")
print(str(e))
sys.exit(1)
print("")
print("Building Minimal ZIP File")
print("=========================")
print("")
if not os.path.isdir("dist"):
os.mkdir("dist")
outFile = os.path.join("dist", "novelWriter-%s-minimal.zip" % __version__)
if os.path.isfile(outFile):
os.unlink(outFile)
rootFiles = [
"LICENSE.md",
"README.md",
"CHANGELOG.md",
"novelWriter.pyw",
"requirements.txt",
"setup.py",
"setup_windows.bat",
]
with ZipFile(outFile, "w") as zipObj:
for nRoot, _, nFiles in os.walk("nw"):
if nRoot.endswith("__pycache__"):
print("Skipping: %s" % nRoot)
continue
print("Compressing: %s [%d files]" % (nRoot, len(nFiles)))
for aFile in nFiles:
if aFile.endswith(".pyc"):
print("Skipping: %s" % aFile)
continue
zipObj.write(os.path.join(nRoot, aFile))
for aFile in rootFiles:
assert os.path.isfile(aFile)
print("Compressing: %s" % aFile)
zipObj.write(aFile)
print("")
print("Built file: %s" % outFile)
print("")
return
##
# Make Simple Package (pack-pyz)
## ##
def makeSimplePackage(embedPython): def makeSimplePackage(embedPython):
@@ -722,7 +786,7 @@ def winInstall():
targetDir = os.path.abspath(os.path.dirname(__file__)) targetDir = os.path.abspath(os.path.dirname(__file__))
targetPy = os.path.join(targetDir, "novelWriter.pyw") targetPy = os.path.join(targetDir, "novelWriter.pyw")
targetIcon = os.path.join(targetDir, "setup", "icons", "novelwriter.ico") targetIcon = os.path.join(targetDir, "nw", "assets", "icons", "novelwriter.ico")
print("Collecting Info ...") print("Collecting Info ...")
print("Desktop Folder: %s" % desktopDir) print("Desktop Folder: %s" % desktopDir)
@@ -880,6 +944,8 @@ if __name__ == "__main__":
"\n" "\n"
"Python Packaging:\n" "Python Packaging:\n"
"\n" "\n"
" minimal-zip Creates a minimal zip file of the core application without all the\n"
" other source files.\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" " freeze Freeze the package and produces a folder with all dependencies using\n"
@@ -942,6 +1008,10 @@ if __name__ == "__main__":
# Python Packaging # Python Packaging
# ================ # ================
if "minimal-zip" in sys.argv:
sys.argv.remove("minimal-zip")
makeMinimalPackage()
if "pack-pyz" in sys.argv: if "pack-pyz" in sys.argv:
sys.argv.remove("pack-pyz") sys.argv.remove("pack-pyz")
simplePack = True simplePack = True
-3
View File
@@ -8,9 +8,6 @@ if errorlevel 1 goto errorNoPython
echo Python found. OK. echo Python found. OK.
echo. echo.
:: Generate the sample project
python setup.py sample
:: Install the PyQt5, lxml and pyenchant dependencies :: Install the PyQt5, lxml and pyenchant dependencies
python setup.py pip python setup.py pip