Skip to content

Commit e6e443b

Browse files
Compile l10nUtil.exe with py2exe as one of NVDA's executables, rather than using nuitka which took way too long to compile. (#17712)
l10nUtil (which allows translators to download and upload to Crowdin, and convert xliffs to markdown and html) s currently build using nuitka. However, this takes a significant amount of time. On Appveyor this takes roughly 20 minutes, which is more than a rd of the total build time.In many cases, this pushes the buildtime past 60 minutes and the build is cancelled by appveyor. Description of development approach Instead of using Nuitka, compile l10nUtil.exe as one of NVDA's executables using py2exe. Several modules and packages in lxml and markdown extensions needed to be explicitly listed in setup.py for this to work. Also, l1nutil.py, markdownTranslate.py, md2html.py and keyCommandsDoc.py were moved from user_docs to source, which made it easier to handle with py2exe. l10nUtil.exe still works just the same, and build time is cut down by at least 19 minutes.
1 parent c756899 commit e6e443b

File tree

10 files changed

+24
-18
lines changed

10 files changed

+24
-18
lines changed

appveyor/scripts/setSconsArgs.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
$ErrorActionPreference = "Stop";
2-
$sconsOutTargets = "launcher developerGuide changes userGuide keyCommands client moduleList nvdaL10nUtil"
2+
$sconsOutTargets = "launcher developerGuide changes userGuide keyCommands client moduleList"
33
if(!$env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:feature_buildAppx) {
44
$sconsOutTargets += " appx"
55
}

projectDocs/dev/developerGuide/sconscript

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ mdFileSub = env.Substfile(
2424
htmlFile = env.Command(
2525
target=mdFile.abspath.replace(".md", ".html"),
2626
source=mdFileSub,
27-
action=[f'@{sys.executable} user_docs/md2html.py -t developerGuide "$SOURCE" "$TARGET"'],
27+
action=[f'@{sys.executable} source/md2html.py -t developerGuide "$SOURCE" "$TARGET"'],
2828
)
2929
devGuide = env.Command(
3030
target=devDocsOutputDir.File("developerGuide.html"), source=htmlFile, action=Move("$TARGET", "$SOURCE")

requirements.txt

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ pycaw==20240210
2222

2323
# Packaging NVDA
2424
py2exe==0.13.0.2
25-
# xliff2html is packaged with nuitka
26-
nuitka==2.5.4
27-
# l10nUtil requires Crowdin
25+
# l10nUtil requires Crowdin
2826
crowdin-api-client==1.21.0
2927

3028
# Creating XML unit test reports

sconstruct

+4-12
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ for xliffFile in env.Glob(os.path.join(userDocsDir.path, "*", "*.xliff")):
341341
env.Command(
342342
mdFile,
343343
xliffFile,
344-
[f'@{sys.executable} user_docs/markdownTranslate.py generateMarkdown -x "{xliffFile}" -o "{mdFile}"'],
344+
[f'@{sys.executable} source/markdownTranslate.py generateMarkdown -x "{xliffFile}" -o "{mdFile}"'],
345345
)
346346
# Allow all markdown files to be converted to html in user_docs
347347
for mdFile in env.Glob(os.path.join(userDocsDir.path, "*", "*.md")):
@@ -360,7 +360,7 @@ for mdFile in env.Glob(os.path.join(userDocsDir.path, "*", "*.md")):
360360
htmlFile = env.Command(
361361
target=mdFile.abspath.replace(".md", ".html"),
362362
source=mdFileSub,
363-
action=[f'@{sys.executable} user_docs/md2html.py -l {lang} -t {docType} "$SOURCE" "$TARGET"'],
363+
action=[f'@{sys.executable} source/md2html.py -l {lang} -t {docType} "$SOURCE" "$TARGET"'],
364364
)
365365
styleInstallPath = os.path.dirname(mdFile.abspath)
366366
installedStyle = env.Install(styleInstallPath, styles)
@@ -382,7 +382,7 @@ for userGuideFileSub in env.Glob(os.path.join(userDocsDir.path, "*", "userGuide.
382382
keyCommandsHtmlFile = env.Command(
383383
target=userGuideFileSub.abspath.replace("userGuide.md.sub", "keyCommands.html"),
384384
source=userGuideFileSub,
385-
action=[f'@{sys.executable} user_docs/md2html.py -l {lang} -t keyCommands "$SOURCE" "$TARGET"'],
385+
action=[f'@{sys.executable} source/md2html.py -l {lang} -t keyCommands "$SOURCE" "$TARGET"'],
386386
)
387387
env.Depends(keyCommandsHtmlFile, userGuideFileSub)
388388

@@ -454,7 +454,7 @@ def NVDADistGenerator(target, source, env, for_signature):
454454
action.append(Copy(target[0], file.path))
455455

456456
if certFile or apiSigningToken:
457-
for prog in "nvda_noUIAccess.exe", "nvda_uiAccess.exe", "nvda_slave.exe":
457+
for prog in "nvda_noUIAccess.exe", "nvda_uiAccess.exe", "nvda_slave.exe", "l10nUtil.exe":
458458
action.append(
459459
lambda target, source, env, progByVal=prog: env["signExec"](
460460
[target[0].File(progByVal)], source, env
@@ -731,11 +731,3 @@ source = env.Dir(os.path.join(os.getcwd(), "dist"))
731731
# Putting the target in the output dir automatically causes AppVeyor to package it as an artefact
732732
target = env.File(os.path.join(outputDir.abspath, "library_modules.txt"))
733733
env.Alias("moduleList", env.GenerateModuleList(target, source))
734-
735-
nvdaL10nUtil = env.Command(
736-
target=outputDir.File("l10nUtil.exe"),
737-
source="user_docs\l10nUtil.py",
738-
ENV=os.environ,
739-
action=f"nuitka --assume-yes-for-downloads --remove-output --standalone --onefile --output-dir={outputDir.abspath} --include-module=mdx_truly_sane_lists --include-module=markdown_link_attr_modifier --include-module=mdx_gh_links $SOURCE",
740-
)
741-
env.Alias("nvdaL10nUtil", nvdaL10nUtil)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

source/setup.py

+16
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,17 @@ def _genManifestTemplate(shouldHaveUIAccess: bool) -> tuple[int, int, bytes]:
192192
"company_name": f"Bill Dengler, {publisher}",
193193
},
194194
},
195+
{
196+
"script": "l10nUtil.py",
197+
"version_info": {
198+
"version": formatBuildVersionString(),
199+
"description": "NVDA Localization Utility",
200+
"product_name": name,
201+
"product_version": version,
202+
"copyright": NVDAcopyright,
203+
"company_name": publisher,
204+
},
205+
},
195206
],
196207
options={
197208
"verbose": 2,
@@ -241,6 +252,11 @@ def _genManifestTemplate(shouldHaveUIAccess: bool) -> tuple[int, int, bytes]:
241252
"visionEnhancementProviders",
242253
# Required for markdown, markdown implicitly imports this so it isn't picked up
243254
"html.parser",
255+
"lxml._elementpath",
256+
"markdown.extensions",
257+
"markdown_link_attr_modifier",
258+
"mdx_truly_sane_lists",
259+
"mdx_gh_links",
244260
],
245261
"includes": [
246262
"nvdaBuiltin",

tests/unit/test_markdownTranslate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class TestMarkdownTranslate(unittest.TestCase):
1717
os.path.dirname(__file__),
1818
"..",
1919
"..",
20-
"user_docs",
20+
"source",
2121
"markdownTranslate.py",
2222
)
2323
testDir = os.path.join(os.path.dirname(__file__), "..", "markdownTranslate")

0 commit comments

Comments
 (0)