diff --git a/source/logHandler.py b/source/logHandler.py
index 2eaa0b6cec8..b9384f1caa0 100755
--- a/source/logHandler.py
+++ b/source/logHandler.py
@@ -96,17 +96,11 @@ def getCodePath(f):
return ".".join([x for x in path,className,funcName if x])
# Function to strip the base path of our code from traceback text to improve readability.
-if getattr(sys, "frozen", None):
- # We're running a py2exe build.
- # The base path already seems to be stripped in this case, so do nothing.
- def stripBasePathFromTracebackText(text):
- return text
-else:
- BASE_PATH = os.path.split(__file__)[0] + os.sep
- TB_BASE_PATH_PREFIX = ' File "'
- TB_BASE_PATH_MATCH = TB_BASE_PATH_PREFIX + BASE_PATH
- def stripBasePathFromTracebackText(text):
- return text.replace(TB_BASE_PATH_MATCH, TB_BASE_PATH_PREFIX)
+BASE_PATH = os.path.split(__file__)[0] + os.sep
+TB_BASE_PATH_PREFIX = ' File "'
+TB_BASE_PATH_MATCH = TB_BASE_PATH_PREFIX + BASE_PATH
+def stripBasePathFromTracebackText(text):
+ return text.replace(TB_BASE_PATH_MATCH, TB_BASE_PATH_PREFIX)
class Logger(logging.Logger):
# Import standard levels for convenience.
diff --git a/source/setup.py b/source/setup.py
index e105e777cc3..ed11c4c88b4 100755
--- a/source/setup.py
+++ b/source/setup.py
@@ -8,117 +8,100 @@
import os
import copy
import gettext
-gettext.install("nvda", unicode=True)
-from distutils.core import setup
+gettext.install("nvda")
+from setuptools import setup
import py2exe as py2exeModule
from glob import glob
import fnmatch
from versionInfo import *
-from py2exe import build_exe
+from py2exe import distutils_buildexe
+from py2exe.dllfinder import DllFinder
import wx
-import imp
+import importlib.machinery
-MAIN_MANIFEST_EXTRA = r"""
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+RT_MANIFEST = 24
+manifest_template = """\
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
"""
-def getModuleExtention(thisModType):
- for ext,mode,modType in imp.get_suffixes():
- if modType==thisModType:
- return ext
- raise ValueError("unknown mod type %s"%thisModType)
-
# py2exe's idea of whether a dll is a system dll appears to be wrong sometimes, so monkey patch it.
-origIsSystemDLL = build_exe.isSystemDLL
-def isSystemDLL(pathname):
- dll = os.path.basename(pathname).lower()
- if dll in ("msvcp71.dll", "msvcp90.dll", "gdiplus.dll","mfc71.dll", "mfc90.dll"):
- # These dlls don't exist on many systems, so make sure they're included.
- return 0
- elif dll.startswith("api-ms-win-") or dll in ("powrprof.dll", "mpr.dll", "crypt32.dll"):
+orig_determine_dll_type = DllFinder.determine_dll_type
+def determine_dll_type(self, imagename):
+ dll = os.path.basename(imagename).lower()
+ if dll.startswith("api-ms-win-") or dll in ("powrprof.dll", "mpr.dll", "crypt32.dll"):
# These are definitely system dlls available on all systems and must be excluded.
# Including them can cause serious problems when a binary build is run on a different version of Windows.
- return 1
- return origIsSystemDLL(pathname)
-build_exe.isSystemDLL = isSystemDLL
+ return None
+ return orig_determine_dll_type(self, imagename)
+DllFinder.determine_dll_type = determine_dll_type
-class py2exe(build_exe.py2exe):
+class py2exe(distutils_buildexe.py2exe):
"""Overridden py2exe command to:
- * Add a command line option --enable-uiAccess to enable uiAccess for the main executable
- * Add extra info to the manifest
- * Don't copy w9xpopen, as NVDA will never run on Win9x
+ * Add a command line option --enable-uiAccess to enable uiAccess for the main executable and EOA proxy
+ * Add a manifest to the executables
"""
- user_options = build_exe.py2exe.user_options + [
+ user_options = distutils_buildexe.py2exe.user_options + [
("enable-uiAccess", "u", "enable uiAccess for the main executable"),
]
def initialize_options(self):
- build_exe.py2exe.initialize_options(self)
+ super(py2exe, self).initialize_options()
self.enable_uiAccess = False
- def copy_w9xpopen(self, modules, dlls):
- pass
-
def run(self):
dist = self.distribution
if self.enable_uiAccess:
# Add a target for nvda_uiAccess, using nvda_noUIAccess as a base.
target = copy.deepcopy(dist.windows[0])
target["dest_base"] = "nvda_uiAccess"
- target["uac_info"] = (target["uac_info"][0], True)
+ target['uiAccess'] = True
dist.windows.insert(1, target)
# nvda_eoaProxy should have uiAccess.
target = dist.windows[3]
- target["uac_info"] = (target["uac_info"][0], True)
-
- build_exe.py2exe.run(self)
-
- def build_manifest(self, target, template):
- mfest, rid = build_exe.py2exe.build_manifest(self, target, template)
- if getattr(target, "script", "").endswith(".pyw"):
- # This is one of the main application executables.
- mfest = mfest[:mfest.rindex("")]
- mfest += MAIN_MANIFEST_EXTRA + ""
- return mfest, rid
+ target['uiAccess'] = True
+ # Add a manifest resource to every target at runtime.
+ for target in dist.windows:
+ target["other_resources"] = [
+ (
+ RT_MANIFEST,
+ 1,
+ (manifest_template % dict(uiAccess=target['uiAccess'])).encode("utf-8")
+ ),
+ ]
+ super(py2exe, self).run()
def getLocaleDataFiles():
wxDir=wx.__path__[0]
@@ -146,8 +129,6 @@ def getRecursiveDataFiles(dest,source,excludes=()):
[rulesList.extend(getRecursiveDataFiles(os.path.join(dest,dirName),os.path.join(source,dirName),excludes=excludes)) for dirName in os.listdir(source) if os.path.isdir(os.path.join(source,dirName)) and not dirName.startswith('.')]
return rulesList
-compiledModExtention = getModuleExtention(imp.PY_COMPILED)
-sourceModExtention = getModuleExtention(imp.PY_SOURCE)
setup(
name = name,
version=version,
@@ -169,10 +150,12 @@ def getRecursiveDataFiles(dest,source,excludes=()):
{
"script":"nvda.pyw",
"dest_base":"nvda_noUIAccess",
- "uac_info": ("asInvoker", False),
+ "uiAccess": False,
"icon_resources":[(1,"images/nvda.ico")],
+ "other_resources": [], # Populated at run time
"version":formatBuildVersionString(),
"description":"NVDA application",
+ "product_name":name,
"product_version":version,
"copyright":copyright,
"company_name":publisher,
@@ -180,9 +163,12 @@ def getRecursiveDataFiles(dest,source,excludes=()):
# The nvda_uiAccess target will be added at runtime if required.
{
"script": "nvda_slave.pyw",
+ "uiAccess": False,
"icon_resources": [(1,"images/nvda.ico")],
+ "other_resources": [], # Populated at run time
"version":formatBuildVersionString(),
"description": name,
+ "product_name":name,
"product_version": version,
"copyright": copyright,
"company_name": publisher,
@@ -190,10 +176,12 @@ def getRecursiveDataFiles(dest,source,excludes=()):
{
"script": "nvda_eoaProxy.pyw",
# uiAccess will be enabled at runtime if appropriate.
- "uac_info": ("asInvoker", False),
+ "uiAccess": False,
"icon_resources": [(1,"images/nvda.ico")],
+ "other_resources": [], # Populated at run time
"version":formatBuildVersionString(),
"description": "NVDA Ease of Access proxy",
+ "product_name":name,
"product_version": version,
"copyright": copyright,
"company_name": publisher,
@@ -201,7 +189,7 @@ def getRecursiveDataFiles(dest,source,excludes=()):
],
options = {"py2exe": {
"bundle_files": 3,
- "excludes": ["Tkinter",
+ "excludes": ["tkinter",
"serial.loopback_connection", "serial.rfc2217", "serial.serialcli", "serial.serialjava", "serial.serialposix", "serial.socket_connection"],
"packages": ["NVDAObjects","virtualBuffers","appModules","comInterfaces","brailleDisplayDrivers","synthDrivers"],
"includes": [
@@ -224,8 +212,22 @@ def getRecursiveDataFiles(dest,source,excludes=()):
] + (
getLocaleDataFiles()
+ getRecursiveDataFiles("synthDrivers", "synthDrivers",
- excludes=("*%s" % sourceModExtention, "*%s" % compiledModExtention, "*.exp", "*.lib", "*.pdb"))
- + getRecursiveDataFiles("brailleDisplayDrivers", "brailleDisplayDrivers", excludes=("*%s"%sourceModExtention,"*%s"%compiledModExtention))
+ excludes=tuple(
+ "*%s" % ext
+ for ext in importlib.machinery.SOURCE_SUFFIXES + importlib.machinery.BYTECODE_SUFFIXES
+ ) + (
+ "*.exp",
+ "*.lib",
+ "*.pdb",
+ "__pycache__"
+ ))
+ + getRecursiveDataFiles("brailleDisplayDrivers", "brailleDisplayDrivers",
+ excludes=tuple(
+ "*%s" % ext
+ for ext in importlib.machinery.SOURCE_SUFFIXES + importlib.machinery.BYTECODE_SUFFIXES
+ ) + (
+ "__pycache__",
+ ))
+ getRecursiveDataFiles('documentation', '../user_docs', excludes=('*.t2t', '*.t2tconf', '*/developerGuide.*'))
),
)