Re: NVDA Add-ons Community Directive: do NOT override system environment variables by assigning new strings
Hi, A better community directive title should be: Directive: do not override system environment variables without preserving old values A really elegant alternative is not using system path environment variable – manually locate the path to the executable you want. Cheers, Joseph
From: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io> On Behalf Of Joseph Lee via groups.io
Sent: Thursday, January 21, 2021 11:15 AM To: nvda-addons@nvda-addons.groups.io Subject: [nvda-addons] NVDA Add-ons Community Directive: do NOT override system environment variables by assigning new strings
Hi all, The following NVDA Add-ons community directive applies to ALL add-ons going forward and will be applied when reviewing add-ons: You can query system environment variables by doing: import os os.environ[variableString]
A crucial environment variable is system path (os.environ[“path”]). This variable is used by operating systems (in this case, Windows) to search listed directories for executables. The variable is not really a string – it is a list of strings separated by a semicolon. If an add-on wants to add new paths to environment variables: # Don’t do this: os.environ[“path”] = newStr
# Alternative 1: Os.environ[“path”] += “;” + pathStr
# Alternative 2: environPath = os.environ[“path”].split(“;”) environPath.append(newPath) os.environ[“path”] = “;”.join(environPath)
# Improved alternative 2: newPath = somePath environPath = os.environ[“path”].split(“;”) if newPath not in environPath: environPath.append(newPath) os.environ[“path”] = “;”.join(environPath)
Any add-on that overrides environment variables without preserving old values will break add-ons that opens executables for their features.
Community directive: going forward, if an add-on is found to have modified system environment variables without preserving existing values will be flagged and authors will be asked to release a fix as soon as possible. Or, for that matter, do NOT ever (EVER) modify environment variables just for convenience (especially system path variable, as it will break NVDA, add-ons, and quite possibly Windows). This directive takes effect immediately.
The above directive applies to all add-ons, including those outside community add-ons website.
Affected add-ons:
Next steps:
Cheers, Joseph
|
|