Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change format of add/remove programs registration to improve winget support #13911

Merged
merged 11 commits into from
Aug 1, 2022
1 change: 1 addition & 0 deletions source/buildVersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,6 @@ def formatVersionForGUI(year, major, minor):
except ImportError:
_updateVersionFromVCS()

version_detailed = formatBuildVersionString()
# A test version is anything other than a final or rc release.
isTestVersion = not version[0].isdigit() or "alpha" in version or "beta" in version or "dev" in version
63 changes: 34 additions & 29 deletions source/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
import easeOfAccess
import COMRegistrationFixes
import winKernel
from typing import (
Dict,
Union,
)

_wsh=None
def _getWSH():
Expand Down Expand Up @@ -227,16 +231,23 @@ def removeOldProgramFiles(destPath):
log.warning(f"Couldn't remove file: {path!r}")


uninstallerRegInfo={
"DisplayName":versionInfo.name,
"DisplayVersion":versionInfo.version,
"DisplayIcon":u"{installDir}\\images\\nvda.ico",
"InstallDir":u"{installDir}",
"Publisher":versionInfo.publisher,
"UninstallDirectory":u"{installDir}",
"UninstallString":u"{installDir}\\uninstall.exe",
"URLInfoAbout":versionInfo.url,
}
def getUninstallerRegInfo(installDir: str) -> Dict[str, Union[str, int]]:
"""
Constructs a dictionary that is written to the registry for NVDA to show up
in the Windows "Apps and Features" overview.
"""
return dict(
DisplayName=f"{versionInfo.name} {versionInfo.version}",
DisplayVersion=versionInfo.version_detailed,
DisplayIcon=os.path.join(installDir, "images", "nvda.ico"),
# EstimatedSize is in KiB
EstimatedSize=getDirectorySize(installDir) // 1024,
InstallDir=installDir,
Publisher=versionInfo.publisher,
UninstallDirectory=installDir,
UninstallString=os.path.join(installDir, "uninstall.exe"),
URLInfoAbout=versionInfo.url,
)


def getDirectorySize(path: str) -> int:
Expand All @@ -259,11 +270,8 @@ def registerInstallation(
startOnLogonScreen: bool,
configInLocalAppData: bool = False
) -> None:
calculatedUninstallerRegInfo = uninstallerRegInfo.copy()
# EstimatedSize is in KiB
estimatedSize = getDirectorySize(installDir)
log.debug(f"Estimated install size {estimatedSize}")
calculatedUninstallerRegInfo.update(EstimatedSize=estimatedSize // 1024)
calculatedUninstallerRegInfo = getUninstallerRegInfo(installDir)
log.debug(f"Estimated install size: {calculatedUninstallerRegInfo.get('EstimatedSize')} KiB")
with winreg.CreateKeyEx(
winreg.HKEY_LOCAL_MACHINE,
r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NVDA",
Expand All @@ -272,21 +280,18 @@ def registerInstallation(
) as k:
for name, value in calculatedUninstallerRegInfo.items():
if isinstance(value, int):
winreg.SetValueEx(
k,
name,
None,
winreg.REG_DWORD,
value
)
regType = winreg.REG_DWORD
elif isinstance(value, str):
regType = winreg.REG_SZ
else:
winreg.SetValueEx(
k,
name,
None,
winreg.REG_SZ,
value.format(installDir=installDir)
)
raise NotImplementedError("Unexpected value from dictionary in getUninstallerRegInfo")
winreg.SetValueEx(
k,
name,
None,
regType,
value
)
with winreg.CreateKeyEx(winreg.HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\nvda.exe",0,winreg.KEY_WRITE) as k:
winreg.SetValueEx(k,"",None,winreg.REG_SZ,os.path.join(installDir,"nvda.exe"))
with winreg.CreateKeyEx(winreg.HKEY_LOCAL_MACHINE, config.RegistryKey.NVDA.value, 0, winreg.KEY_WRITE) as k:
Expand Down
2 changes: 1 addition & 1 deletion source/versionInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
aboutMessage = _(
# Translators: "About NVDA" dialog box message
u"""{longName} ({name})
Version: {version}
Version: {version} ({version_detailed})
URL: {url}
{copyright}

Expand Down
1 change: 1 addition & 0 deletions user_docs/en/changes.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ What's New in NVDA


== Bug Fixes ==
- When updating NVDA using the Windows Package Manager CLI (aka winget), a released version of NVDA is no longer always treated as newer than whatever alpha version is installed. (#12469)
- NVDA will now correctly announce Group boxes in Java applications. (#13962)
-

Expand Down