nvda
daf53a1d - Integrate the Python virtual environment transparently into the build system.

Commit
4 years ago
Integrate the Python virtual environment transparently into the build system. It is now possible to run the scons command the same way you normally would, with out worrying about having to create or activate a virtual environment. This is now done behind the scenes for you. Note that you must execute scons, or scons.bat though, not py -m SCons or some other invocation. To run NVDA from source, it is now necessary to execute runnvda (runnvda.bat) in the root of the repository. This script will block until NVDA exits, though you can still run it in the background by doing ``` start /b runnvda ``` Note that trying to execute source\nvda.pyw directly will now display an error as the NVDA build system Python virtual environment will not be detected doing it this way. Behind the scenes, SCons and runnvda ensure that the Python virtual environment is created and up to date, activates the environment, runs the command and then deactivates. All transparently. A developer should not have to know about the Python virtual environment at all. venvUtils/ensureVenv.py contains the logic to check for, create and update the virtual environment. If a previous virtual environment exists but has a miss-matching Python version or pip package requirements have changed, The virtual environement is recreated with the updated version of Python and packages. If a virtual environement is found but does not seem to be ours, the user is asked if it should be overwritten or not. This script also detects if it is being run from an existing 3rd party Python virtual environment and aborts if so. thus, it is impossible to execute SScons or NVDA from source within another Python virtual environment. venvUtils/ensureAndActivate.bat can be used to ensure the virtual environment exists and is up to date, and then activates it in the current shell, ready for other commands to be executed in the context of NVDA's build system Python virtual environment. this would never nroamlly be executed by itself, though appveyor uses it at the beginning of its execution and leaves the environment active for the remainder of its execution. venvUtils/venvCmd.bat is a script that runs a single command within the context of the NVDA build system Python virtual environment. It ensures and activates the environment, executes the command, and then deactivates the environment. this script is what scons.bat and runnvda.bat use internally. SConstruct, and source/nvda.pyw both contain logic that detects the NVDA build system Python virtual environment, and abort if it is not active.
Parents
Loading