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

Update setup script for Python 3.7 #9605

Merged
merged 3 commits into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions source/logHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
178 changes: 90 additions & 88 deletions source/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
<file name="brailleDisplayDrivers\handyTech\HtBrailleDriverServer.dll">
<comClass
description="HtBrailleDriver Class"
clsid="{209445BA-92ED-4AB2-83EC-F24ACEE77EE0}"
threadingModel="Apartment"
progid="HtBrailleDriverServer.HtBrailleDriver"
tlbid="{33257EFB-336F-4680-B94E-F5013BA6B9B3}" />
</file>
<file name="brailleDisplayDrivers\handyTech\HtBrailleDriverServer.tlb">
<typelib tlbid="{33257EFB-336F-4680-B94E-F5013BA6B9B3}"
version="1.0"
helpdir="" />
</file>
<comInterfaceExternalProxyStub
name="IHtBrailleDriverSink"
iid="{EF551F82-1C7E-421F-963D-D9D03548785A}"
proxyStubClsid32="{00020420-0000-0000-C000-000000000046}"
baseInterface="{00000000-0000-0000-C000-000000000046}"
tlbid="{33257EFB-336F-4680-B94E-F5013BA6B9B3}" />
<comInterfaceExternalProxyStub
name="IHtBrailleDriver"
iid="{43A71F9B-58EE-42D4-B58E-0F9FBA28D995}"
proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"
baseInterface="{00000000-0000-0000-C000-000000000046}"
tlbid="{33257EFB-336F-4680-B94E-F5013BA6B9B3}" />
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
RT_MANIFEST = 24
manifest_template = """\
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="asInvoker"
uiAccess="%(uiAccess)s"
/>
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 7 -->
<supportedOS
Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"
/>
<!-- Windows 8 -->
<supportedOS
Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"
/>
<!-- Windows 8.1 -->
<supportedOS
Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"
/>
<!-- Windows 10 -->
<supportedOS
Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"
/>
</application>
</compatibility>
</assembly>
"""

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("</assembly>")]
mfest += MAIN_MANIFEST_EXTRA + "</assembly>"
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]
Expand Down Expand Up @@ -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,
Expand All @@ -169,39 +150,46 @@ 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,
},
# 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,
},
{
"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,
},
],
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": [
Expand All @@ -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.*'))
),
)