Improve setup for Windows
This commit is contained in:
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""
|
"""
|
||||||
novelWriter – Linux Start Script
|
novelWriter – Terminal Start Script
|
||||||
================================
|
===================================
|
||||||
The main start script for Linux
|
The main start script for the terminal
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"""
|
"""
|
||||||
novelWriter – Windows Start Script
|
novelWriter – Windows Start Script
|
||||||
==================================
|
==================================
|
||||||
The main start script for Windows
|
The main start script for Windows GUI
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ def installPackages(hostOS):
|
|||||||
"""
|
"""
|
||||||
print("")
|
print("")
|
||||||
print("Installing Dependencies")
|
print("Installing Dependencies")
|
||||||
print("#######################")
|
print("=======================")
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
installQueue = ["pip", "-r requirements.txt"]
|
installQueue = ["pip", "-r requirements.txt"]
|
||||||
@@ -427,7 +427,7 @@ def freezePackage(buildWindowed, oneFile, makeSetup, hostOS):
|
|||||||
|
|
||||||
print("")
|
print("")
|
||||||
print("Running PyInstaller")
|
print("Running PyInstaller")
|
||||||
print("###################")
|
print("===================")
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
if hostOS == OS_WIN:
|
if hostOS == OS_WIN:
|
||||||
@@ -685,6 +685,7 @@ def xdgInstall():
|
|||||||
def winInstall():
|
def winInstall():
|
||||||
"""Will attempt to install icons and make a launcher for Windows.
|
"""Will attempt to install icons and make a launcher for Windows.
|
||||||
"""
|
"""
|
||||||
|
import winreg
|
||||||
from nw import __version__, __hexversion__
|
from nw import __version__, __hexversion__
|
||||||
try:
|
try:
|
||||||
import win32com.client
|
import win32com.client
|
||||||
@@ -723,18 +724,6 @@ def winInstall():
|
|||||||
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, "setup", "icons", "novelwriter.ico")
|
||||||
|
|
||||||
os.curdir = os.path.dirname(__file__)
|
|
||||||
with open(targetPy, mode="w") as outFile:
|
|
||||||
outFile.write(
|
|
||||||
"#!/usr/bin/env python3\n"
|
|
||||||
"# -*- coding: utf-8 -*-\n\n"
|
|
||||||
"import os\n\n"
|
|
||||||
"os.curdir = os.path.abspath(os.path.dirname(__file__))\n\n"
|
|
||||||
"if __name__ == \"__main__\":\n"
|
|
||||||
" import nw\n"
|
|
||||||
" nw.main()\n"
|
|
||||||
)
|
|
||||||
|
|
||||||
print("Collecting Info ...")
|
print("Collecting Info ...")
|
||||||
print("Desktop Folder: %s" % desktopDir)
|
print("Desktop Folder: %s" % desktopDir)
|
||||||
print("Start Menu Folder: %s" % startMenuDir)
|
print("Start Menu Folder: %s" % startMenuDir)
|
||||||
@@ -782,6 +771,28 @@ def winInstall():
|
|||||||
wShortcut.save()
|
wShortcut.save()
|
||||||
print("Created: %s" % startMenuIcon)
|
print("Created: %s" % startMenuIcon)
|
||||||
|
|
||||||
|
print("")
|
||||||
|
print("Creating registry keys ...")
|
||||||
|
|
||||||
|
def setKey(kPath, kName, kVal):
|
||||||
|
winreg.CreateKey(winreg.HKEY_CURRENT_USER, kPath)
|
||||||
|
regKey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, kPath, 0, winreg.KEY_WRITE)
|
||||||
|
winreg.SetValueEx(regKey, kName, 0, winreg.REG_SZ, kVal)
|
||||||
|
winreg.CloseKey(regKey)
|
||||||
|
|
||||||
|
mimeIcon = os.path.join(targetDir, "assets", "icons", "x-novelwriter-project.ico")
|
||||||
|
mimeExec = '"%s" "%s" "%%1"' % (pythonExe, targetPy)
|
||||||
|
|
||||||
|
try:
|
||||||
|
setKey(r"Software\Classes\.nwx\OpenWithProgids", "novelWriterProject.nwx", "")
|
||||||
|
setKey(r"Software\Classes\novelWriterProject.nwx", "", "novelWriter Project File")
|
||||||
|
setKey(r"Software\Classes\novelWriterProject.nwx\DefaultIcon", "", mimeIcon)
|
||||||
|
setKey(r"Software\Classes\novelWriterProject.nwx\shell\open\command", "", mimeExec)
|
||||||
|
setKey(r"Software\Classes\Applications\novelWriter.pyw\SupportedTypes", ".nwx", "")
|
||||||
|
except WindowsError:
|
||||||
|
print("ERROR: Failed to set registry keys.")
|
||||||
|
print("")
|
||||||
|
|
||||||
print("")
|
print("")
|
||||||
print("Done!")
|
print("Done!")
|
||||||
print("")
|
print("")
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
:: Check for Python Installation
|
||||||
|
echo.
|
||||||
|
echo Looking for Python
|
||||||
|
python --version 2>NUL
|
||||||
|
if errorlevel 1 goto errorNoPython
|
||||||
|
echo Python found. OK.
|
||||||
|
echo.
|
||||||
|
|
||||||
|
:: Generate the sample project
|
||||||
|
python setup.py sample
|
||||||
|
|
||||||
|
:: Install the PyQt5, lxml and pyenchant dependencies
|
||||||
|
python setup.py pip
|
||||||
|
|
||||||
|
:: Create the desktop and start menu icons
|
||||||
|
python setup.py win-install
|
||||||
|
|
||||||
|
pause
|
||||||
|
goto:eof
|
||||||
|
|
||||||
|
:errorNoPython
|
||||||
|
echo.
|
||||||
|
echo ERROR^: Python is not installed on your system, or cannot be found.
|
||||||
|
echo.
|
||||||
|
echo Please download and install it from https://www.python.org/downloads/
|
||||||
|
echo Also make sure the "Add Python to PATH" option is selected during installation.
|
||||||
|
echo.
|
||||||
|
|
||||||
|
pause
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
@echo off
|
|
||||||
python setup.py pip
|
|
||||||
python setup.py win-install
|
|
||||||
pause
|
|
||||||
Reference in New Issue
Block a user