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

Py3.8: Transparently use a Python virtual environment under the hood #12075

Merged
merged 72 commits into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
adf131a
Build NVDA with Python 3.8 32-bit (#12042)
josephsl Feb 15, 2021
5e87120
Remove any git submodules to distributions we can instead fetch with …
michaelDCurran Feb 15, 2021
c8fc42b
List all required Python packages in a requirements.txt in the root o…
michaelDCurran Feb 15, 2021
9c9d1e1
Ssconscripts: import SCons correctly.
michaelDCurran Feb 15, 2021
3878133
Appveyor: Create and activate a Python virtual environment. Also use …
michaelDCurran Feb 15, 2021
90a7183
Update readme.md
michaelDCurran Feb 15, 2021
cd4a3cf
appveyor.yml: no need to specifify python version in specific command…
michaelDCurran Feb 16, 2021
9503492
.gitignore: ignore the .venv directory
michaelDCurran Feb 16, 2021
fd890d3
setup.py: don't package numpy with NVDA.
michaelDCurran Feb 16, 2021
4a852d9
Use py2exe 0.10.1.0 rather than py2exe 0.10.2.0 which seems to actual…
michaelDCurran Feb 16, 2021
5795e76
Python 3.8/liblouis helper: add NVDA executable path by calling os.ad…
josephsl Feb 16, 2021
6d58baa
Merge branch 'py3.8' into py3.8_manualVenv
michaelDCurran Feb 16, 2021
3025d74
Use comtypes 1.1.7.
michaelDCurran Feb 16, 2021
8074fa1
System tests: don't specify Python 3.7 when running system tests with…
michaelDCurran Feb 16, 2021
c22b7b3
appveyor: run nose with the --traverse-namespace option as it is now …
michaelDCurran Feb 17, 2021
0179e48
Update to miscDeps containing brlAPI for Python 3.8
michaelDCurran Feb 17, 2021
f70b0e8
Work around for issue #12058: In wxPython >= 4.1, wx.CallAfter no lon…
michaelDCurran Feb 17, 2021
cbd21be
Merge remote-tracking branch 'origin/py3.8' into py3.8_manualVenv
michaelDCurran Feb 17, 2021
6f427af
Explicitly include xmlrpc.server with py2exe, as it is required for s…
michaelDCurran Feb 17, 2021
e59018e
sourceEnv: stop the user from running with no virtual environment.
michaelDCurran Feb 22, 2021
daf53a1
Integrate the Python virtual environment transparently into the build…
michaelDCurran Feb 24, 2021
ef52123
Fix typo
michaelDCurran Feb 24, 2021
e7a54fd
ensureVenv.py: flush standard out before running any sub processes ot…
michaelDCurran Feb 24, 2021
713397c
remove some unneeded imports.
michaelDCurran Feb 25, 2021
c60975e
Update pip within the virtual environment, not before, as a stock-sta…
michaelDCurran Feb 25, 2021
da159ae
ensureVenv: address review commnts.
michaelDCurran Feb 25, 2021
2a9df26
core.main: FreeConsole returns 0 on failure rather than raising an ex…
michaelDCurran Feb 25, 2021
459e3a3
Added runnvdaw.bat which runs NVDA without blocking. this provides th…
michaelDCurran Feb 25, 2021
12ae5a8
Merge branch 'master' into py3.8
michaelDCurran Mar 1, 2021
ada0b85
Merge branch 'py3.8' into py3.8_manualVenv
michaelDCurran Mar 1, 2021
73c8490
appveyor: push the list of installed python packages directly as an …
michaelDCurran Mar 1, 2021
19120dd
linting for venvUtils/ensureVenv.py
michaelDCurran Mar 1, 2021
e924a87
Linting for source/setup.py
michaelDCurran Mar 1, 2021
1b827b6
add rununittests.bat to provide a faster way of running the unit test…
michaelDCurran Mar 1, 2021
1039dc5
Add runsystemtests.bat as a quick way of running the system tests, wi…
michaelDCurran Mar 1, 2021
8a13814
Add runlint.bat which provides a quicker way of linting. Rather than …
michaelDCurran Mar 1, 2021
91193e2
Add diff-match-patch as a Python package requirement as NVDA_DMP need…
michaelDCurran Mar 3, 2021
f47db8e
Sync with latest nvda_dmp. (#12113)
codeofdusk Mar 3, 2021
8375c3e
Cnfigobj is now fetched by pip, rather than it being a git submodule.
michaelDCurran Mar 3, 2021
2f01c39
Address review comments: final line ending / extra spaces.
michaelDCurran Mar 3, 2021
f1eb3e9
venvCmd.bat: allow executing a command when already inside an NVDA Py…
michaelDCurran Mar 3, 2021
89922ec
appveyor: abort on failure of scons and other commands.
michaelDCurran Mar 3, 2021
b834a4e
Ensure that scons.bat and other high-level commands correctly propaga…
michaelDCurran Mar 3, 2021
2039871
Revert "core.main: FreeConsole returns 0 on failure rather than raisi…
michaelDCurran Mar 4, 2021
e2e23ed
core.main: revert addition of FreeConsole. This will be handled in a …
michaelDCurran Mar 4, 2021
34e7107
For now runnvda.bat (python) has been removed, and runnvdaw.bat (pyth…
michaelDCurran Mar 4, 2021
711eb37
garbageHandler: revert fix to "Nonetype is not callable" when Python …
michaelDCurran Mar 4, 2021
ed432bf
Remove targets for unit tests, system tests and linting from SCons as…
michaelDCurran Mar 4, 2021
b0cb717
Appveyor now calls runlint, rununittests and runsystemtests rather th…
michaelDCurran Mar 7, 2021
7eb2584
Update system tests readme to talk about runsystemtests, and not SCons.
michaelDCurran Mar 7, 2021
ee498f3
readme: briefly mention Nose and Robot and providing them extra argum…
michaelDCurran Mar 7, 2021
7b125c6
tests/sconscript: remove all code unrelated to checkPot.
michaelDCurran Mar 7, 2021
b59263d
appveyor: call our batch files as a relative path otherise Powershell…
michaelDCurran Mar 7, 2021
e820763
appveyor: py3.8 is a branch we should run builds for.
michaelDCurran Mar 7, 2021
d8a89c0
runlint.bat: fix path.
michaelDCurran Mar 7, 2021
d5e480c
add a description of the build system to the devDocs directory.
michaelDCurran Mar 7, 2021
e0f9c6b
NVDA build system commands no longer refuse to run if not in NVDA's s…
michaelDCurran Mar 8, 2021
c6c13e0
Linting
michaelDCurran Mar 8, 2021
dd70ba8
Apply suggestions from code review
michaelDCurran Mar 8, 2021
95339d6
System tests: use runnvda.bat rather than pyw source\nvda.pyw directly.
michaelDCurran Mar 8, 2021
9ab0f6d
scons dist: copy crt dlls from the latest installed sdk (I.e. the one…
michaelDCurran Mar 9, 2021
e008f1d
appveyor: Move generation of the installed_python_packages.txt file t…
michaelDCurran Mar 9, 2021
110edc1
Call pip freeze from a batch file in appveyor, as it seems that power…
michaelDCurran Mar 9, 2021
778e512
Update buildSystemNotes
feerrenrut Mar 10, 2021
06411a0
buildSystemNotes: address some typos.
michaelDCurran Mar 11, 2021
9b1c16a
Remove workaround for issue #9762 (#12142)
lukaszgo1 Mar 11, 2021
cc7d219
Python 3.8: Mention additional system requirements for Windows 7 (#12…
lukaszgo1 Mar 11, 2021
0b78587
Python 3.8/gettext: replace custom pgettext implementation with built…
josephsl Mar 11, 2021
0dbdaed
Merge branch 'master' into py3.8
michaelDCurran Mar 11, 2021
49ea5ae
Merge branch 'py3.8' into py3.8_manualVenv
michaelDCurran Mar 11, 2021
7a6fc4d
Update what's new
michaelDCurran Mar 11, 2021
cca866a
appveyor: remove mention of py3.8 branch, no longer needed.
michaelDCurran Mar 11, 2021
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ tests/unit/nvda.ini
source/locale/*/cldr.dic
.vscode
.vs
.venv
16 changes: 0 additions & 16 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,12 @@
path = include/sonic
url = https://github.com/waywardgeek/sonic.git
ignore = untracked
[submodule "include/pyserial"]
path = include/pyserial
url = https://github.com/pyserial/pyserial.git
ignore = untracked
[submodule "include/comtypes"]
path = include/comtypes
url = https://github.com/nvaccess/comtypes-bin
[submodule "include/scons"]
path = include/scons
url = https://github.com/SCons/scons
[submodule "include/ia2"]
path = include/ia2
url = https://github.com/LinuxA11y/IAccessible2.git
[submodule "include/wxPython"]
path = include/wxPython
url = https://github.com/nvaccess/wxPython-bin.git
[submodule "include/configobj"]
path = include/configobj
url = https://github.com/DiffSK/configobj.git
[submodule "include/py2exe"]
path = include/py2exe
url = https://github.com/nvaccess/py2exe-bin
[submodule "include/javaAccessBridge32"]
path = include/javaAccessBridge32
url = https://github.com/nvaccess/javaAccessBridge32-bin.git
Expand Down
19 changes: 11 additions & 8 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ branches:
- /release-.*/

environment:
PY_PYTHON: 3.7-32
PY_PYTHON: 3.8-32
encFileKey:
secure: ekOvuyywHuDdGZmRmoj+b3jfrq39A2xlx4RD5ZUGd/8=
mozillaSymsAuthToken:
Expand Down Expand Up @@ -59,6 +59,12 @@ init:
clone_depth: 1

install:
# Ensure we have the latest version of pip
- py -m pip install --upgrade pip

This comment was marked as outdated.

# Activate the NvDA build system Python virtual environment, creating / updating it if necessary.
- .\venvUtils\ensureAndActivate.bat
# Save an exact list of the actual Python packages and their versions that got installed, to aide in reproducing a build
- py -m pip freeze >output\pip_packages.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point there is no directory called 'output' - it is created later on by SCons, so this command fails.

- cd appveyor
# Decrypt files.
- ps: |
Expand Down Expand Up @@ -95,12 +101,12 @@ build_script:
Set-AppveyorBuildVariable "sconsOutTargets" $sconsOutTargets
Set-AppveyorBuildVariable "sconsArgs" $sconsArgs
- 'echo scons args: %sconsArgs%'
- py scons.py source %sconsArgs%
- scons source %sconsArgs%
# We don't need launcher to run checkPot, so run the checkPot before launcher.
- py scons.py checkPot %sconsArgs%
- scons checkPot %sconsArgs%
feerrenrut marked this conversation as resolved.
Show resolved Hide resolved
# The pot gets built by tests, but we don't actually need it as a build artifact.
- 'echo scons output targets: %sconsOutTargets%'
- py scons.py %sconsOutTargets% %sconsArgs%
- scons %sconsOutTargets% %sconsArgs%
# Build symbol store.
- ps: |
foreach ($syms in
Expand All @@ -118,9 +124,6 @@ build_script:
- cd ..

before_test:
# install required packages
- py -m pip install --upgrade pip
- py -m pip install -r tests/system/requirements.txt -r tests/lint/lintInstall/requirements.txt
- mkdir testOutput
- mkdir testOutput\unit
- mkdir testOutput\system
Expand Down Expand Up @@ -153,7 +156,7 @@ test_script:
$errorCode=0
$outDir = (Resolve-Path .\testOutput\unit\)
$unitTestsXml = "$outDir\unitTests.xml"
py -m nose -sv --with-xunit --xunit-file="$unitTestsXml" ./tests/unit
py -m nose -sv --with-xunit --xunit-file="$unitTestsXml" --traverse-namespace -w ./tests/unit
if($LastExitCode -ne 0) {
$errorCode=$LastExitCode
Add-AppveyorMessage "Unit test failure"
Expand Down
1 change: 0 additions & 1 deletion devDocs/devDocsInstall/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions devDocs/devDocsInstall/requirements.txt

This file was deleted.

35 changes: 0 additions & 35 deletions devDocs/devDocsInstall/sconscript

This file was deleted.

5 changes: 0 additions & 5 deletions devDocs/sconscript
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ Import("env", "outputDir", "sourceDir", "t2tBuildConf")

env = env.Clone()

devDocsInstall = env.SConscript("devDocsInstall/sconscript", exports=["env"])
env.Depends(devDocsInstall, env.Dir("devDocs/devDocsInstall/requirements.txt"))
env.Alias("devDocsInstall", devDocsInstall)

devDocsOutputDir=outputDir.Dir('devDocs')

#Build the developer guide and move it to the output directory
Expand Down Expand Up @@ -69,7 +65,6 @@ sphinxAPIDocs = env.Command(
] + [f"{sourceDir}\\{f}" for f in ignorePaths]
]
)
env.Depends(sphinxAPIDocs, devDocsInstall)
sphinxHtml = env.Command(
"_build",
sphinxAPIDocs,
Expand Down
1 change: 0 additions & 1 deletion include/comtypes
Submodule comtypes deleted from 8c4558
1 change: 0 additions & 1 deletion include/py2exe
Submodule py2exe deleted from c496ae
1 change: 0 additions & 1 deletion include/pyserial
Submodule pyserial deleted from c54c81
1 change: 0 additions & 1 deletion include/scons
Submodule scons deleted from dfcc78
1 change: 0 additions & 1 deletion include/wxPython
Submodule wxPython deleted from 11de93
2 changes: 1 addition & 1 deletion nvdaHelper/espeak/sconscript
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from include.scons.SCons.Util import CLVar
from SCons.Util import CLVar

This comment was marked as outdated.


Import([
'thirdPartyEnv',
Expand Down
4 changes: 2 additions & 2 deletions nvdaHelper/liblouis/sconscript
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import re
import glob
from SCons.Tool.MSCommon.vc import find_vc_pdir
import typing
from include.scons.SCons.Environment import Environment
from include.scons.SCons.Environment import Base
from SCons.Environment import Environment
from SCons.Environment import Base

Import([
"thirdPartyEnv",
Expand Down
37 changes: 12 additions & 25 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ The NVDA source depends on several other packages to run correctly.
### Installed Dependencies
The following dependencies need to be installed on your system:

* [Python](https://www.python.org/), version 3.7, 32 bit
* [Python](https://www.python.org/), version 3.8, 32 bit
* Use latest minor version if possible.
* Don't use `3.7.6` it causes an error while building, see #10696.
* Microsoft Visual Studio 2019 Community, Version 16.3 or later:
* Download from https://visualstudio.microsoft.com/vs/
* When installing Visual Studio, you need to enable the following:
Expand All @@ -75,20 +74,17 @@ The following dependencies need to be installed on your system:


### Git Submodules
Most of the dependencies are contained in Git submodules.
Some of the dependencies are contained in Git submodules.
If you didn't pass the `--recursive` option to git clone, you will need to run `git submodule update --init`.
Whenever a required submodule commit changes (e.g. after git pull), you will need to run `git submodule update`.
If you aren't sure, run `git submodule update` after every git pull, merge or checkout.

For reference, the following run time dependencies are included in Git submodules:

* [comtypes](https://github.com/enthought/comtypes), version 1.1.7
* [wxPython](https://www.wxpython.org/), version 4.0.3
* [eSpeak NG](https://github.com/espeak-ng/espeak-ng), version 1.51-dev commit 82d5b7b04
* [Sonic](https://github.com/waywardgeek/sonic), commit 4f8c1d11
* [IAccessible2](https://wiki.linuxfoundation.org/accessibility/iaccessible2/start), commit cbc1f29631780
* [ConfigObj](https://github.com/DiffSK/configobj), commit f9a265c
* [Six](https://pypi.python.org/pypi/six), version 1.12.0, required by wxPython and ConfigObj
* [liblouis](http://www.liblouis.org/), version 3.16.1
* [Unicode Common Locale Data Repository (CLDR)](http://cldr.unicode.org/), version 38.1
* NVDA images and sounds
Expand All @@ -97,37 +93,27 @@ For reference, the following run time dependencies are included in Git submodule
* [MinHook](https://github.com/RaMMicHaeL/minhook), tagged version 1.2.2
* brlapi Python bindings, version 0.8 or later, distributed with [BRLTTY for Windows](https://brltty.app/download.html), version 6.1
* lilli.dll, version 2.1.0.0
* [pySerial](https://pypi.python.org/pypi/pyserial), version 3.4
* [Python interface to FTDI driver/chip](http://fluidmotion.dyndns.org/zenphoto/index.php?p=news&title=Python-interface-to-FTDI-driver-chip)
* Java Access Bridge 32 bit, from Zulu Community OpenJDK build 13.0.1+10Zulu (13.28.11)

Additionally, the following build time dependencies are included in Git submodules:
Additionally, the following build time dependencies are included in the miscDeps git submodule:

* [Py2Exe](https://github.com/albertosottile/py2exe/), version 0.9.3.2 commit b372a8e
* [Python Windows Extensions](https://sourceforge.net/projects/pywin32/ ), build 224, required by py2exe
* [txt2tags](https://txt2tags.org/), version 2.5
* [SCons](https://www.scons.org/), version 4.0.1
* [Nulsoft Install System](https://nsis.sourceforge.io/Main_Page/), version 2.51
* [NSIS UAC plug-in](https://nsis.sourceforge.io/UAC_plug-in), version 0.2.4, ansi
* xgettext and msgfmt from [GNU gettext](https://sourceforge.net/projects/cppcms/files/boost_locale/gettext_for_windows/)
* [Boost Optional (stand-alone header)](https://github.com/akrzemi1/Optional), from commit [3922965](https://github.com/akrzemi1/Optional/commit/3922965396fc455c6b1770374b9b4111799588a9)

### Other Dependencies
To lint using Flake 8 locally using our SCons integration, some dependencies are installed (automatically) via pip.
Although this [must be run manually](#linting-your-changes), developers may wish to first configure a Python Virtual Environment to ensure their general install is not affected.
* Flake8
* Flake8-tabs


The following dependencies aren't needed by most people, and are not included in Git submodules:

* To generate developer documentation: [Sphinx](http://sphinx-doc.org/), version 3.4.1
* To generate developer documentation for nvdaHelper: [Doxygen Windows installer](http://www.doxygen.nl/download.html), version 1.8.15:
* When you are using Visual Studio Code as your integrated development environment of preference, you can make use of our [prepopulated workspace configuration](https://github.com/nvaccess/vscode-nvda/) for [Visual Studio Code](https://code.visualstudio.com/).
While this VSCode project is not included as a submodule in the NVDA repository, you can easily check out the workspace configuration in your repository by executing the following from the root of the repository.

```git clone https://github.com/nvaccess/vscode-nvda.git .vscode```

### Python dependencies
NVDA and its build system also depend on an extensive list of Python packages. They are all listed with their specific versions in a requirements.txt file in the root of this repository. However, the build system takes care of fetching these itself when needed. these packages will be installed into an isolated Python virtual environment within this repository, and will not affect your system-wide set of packages.

## Preparing the Source Tree
Before you can run the NVDA source code, you must prepare the source tree.
You do this by opening a command prompt, changing to the root of the NVDA source distribution and typing:
Expand Down Expand Up @@ -173,13 +159,14 @@ By default, builds also do not use any compiler optimizations.
Please see the `release` keyword argument for what compiler optimizations it will enable.

## Running the Source Code
Most developers run directly from source by:
Most developers run directly from source by executing:
```
runnvda.bat
```
This command will block until NVDA is exited. However, you can run it in the background with:
```
cd source
pythonw.exe nvda.pyw
start /b runnvda.bat
```
Note: Since NVDA is a Windows application (rather than command line), it is best to run it with `pythonw.exe`.
However, if during development you encounter an error early in the startup of NVDA, you can use `python.exe` which is likely to give more information about the error.

To view help on the arguments that NVDA will accept, use the `-h` or `--help` option.
These arguments are also documented in the user guide.
Expand Down
26 changes: 26 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# NVDA's build system is SCons
SCons==4.1.0.post1

# NVDA's runtime dependencies
michaelDCurran marked this conversation as resolved.
Show resolved Hide resolved
comtypes==1.1.7
pyserial==3.5
wxPython==4.1.1
feerrenrut marked this conversation as resolved.
Show resolved Hide resolved
michaelDCurran marked this conversation as resolved.
Show resolved Hide resolved

# Packaging NVDA
py2exe==0.10.1.0

# For building developer documentation
sphinx==3.4.1
sphinx_rtd_theme

# Requirements for automated linting
flake8 ~= 3.7.7
flake8-tabs == 2.1.0

# Requirements for unit tests
nose==1.3.7

# Requirements for system tests
robotframework==3.2.2
robotremoteserver==1.1
robotframework-screencaplibrary==1.5.0
2 changes: 2 additions & 0 deletions runnvda.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
call "%~dp0\venvUtils\venvCmd.bat" py "%~dp0\source\nvda.pyw" %*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you're using py not pyw here? Current readme on master recommends to use pythonw in most cases unless more debugging info is needed. If the only concern is the fact thatpyw` does not block by default you can just use start /wait.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If called from a batch file, pythonw will actually block. Calls in batch files always wait on any process executed. And since it blocks, and I added the freeConsole call in core.py so that the console is still usable by NVDA, we may as well use python rather than pythonw so that critical errors are not missed.
However, I have now also added runnvdaw.bat which executes NvDA in the virtual environment with start pyw, which again provides the behaviour developers were used to by using pyw or executing nvda.pyw directly from Explorer etc. I.e. it does not block, and no console window stays around for the life time of its execution.
Of course this being a draft pr, all this is still up for debate -- I certainly welcome other ideas on the best way we can allow developers to run NVDA.

14 changes: 2 additions & 12 deletions scons.bat
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
@echo off
rem We need this script because .py probably isn't in pathext.
rem We can't just call python -c because it may not be in the path.
rem Instead, find the python launcher (installed by python 3)
where py 1>nul 2>&1
if "%ERRORLEVEL%" == "0" (
rem Python launcher is present in the PATH
rem Call python 3.7 for 32 bits
py -3.7-32 "%~dp0\scons.py" %*
) else (
rem Python registers itself with the .py extension, so call scons.py.
"%~dp0\scons.py" %*
)
rem Executes SScons within the NVDA build system's Python virtual environment.
"%~dp0\venvUtils\venvCmd.bat" py -m SCons %*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a new line to the end of this file.

16 changes: 0 additions & 16 deletions scons.py

This file was deleted.

16 changes: 11 additions & 5 deletions sconstruct
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@ import sys
import os
import platform

# Ensure we are inside the NVDA build system's Python virtual environment.
nvdaVenv = os.getenv("NVDA_VENV")
virtualEnv = os.getenv("VIRTUAL_ENV")
if not nvdaVenv or nvdaVenv != virtualEnv:
print(
"Error: SCons cannot detect the NVDA build system Python virtual environment.\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double space after 'detect'

"SCons must be executed using scons.bat in the root of this repository."
)
sys.exit(1)

# Variables for storing required version of Python, and the version which is used to run this script.
requiredPythonMajor ="3"
requiredPythonMinor = "7"
requiredPythonMinor = "8"
requiredPythonArchitecture = "32bit"
installedPythonMajor = str(sys.version_info.major)
installedPythonMinor = str(sys.version_info.minor)
Expand All @@ -34,10 +44,6 @@ if (
requiredPythonArchitecture
)
)
if sys.version_info.micro == 6:
# #10696: Building with Python 3.7.6 fails. Innform user and exit.
Py376FailMsg = "Building with Python 3.7.6 is not possible.\nPlease use more recent version of Python 3."
raise RuntimeError(Py376FailMsg)
sourceEnvPath = os.path.abspath(os.path.join(Dir('.').srcnode().path, "source"))
sys.path.append(sourceEnvPath)
import sourceEnv
Expand Down
9 changes: 9 additions & 0 deletions source/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,15 @@ def run(self):
else:
log.debug("initializing updateCheck")
updateCheck.initialize()
# If running from source, try to disconnect from the console we may have been executed in.
# NVDA may reconnect to read it later,
# but it is better to assume we are not connected to anything at the start.
try:
ctypes.windll.kernel32.FreeConsole()

This comment was marked as outdated.

except WindowsError:
pass
else:
log.debug("Freed from parent console process.")
log.info("NVDA initialized")
postNvdaStartup.notify()

Expand Down
Loading