|
1 | 1 | @echo off |
2 | 2 | rem this script ensures the NVDA build system Python virtual environment is created and up to date, |
3 | 3 | rem and then activates it. |
4 | | -rem this script should be used only in the case where many commands will be executed within the environment and the shell will be eventually thrown away. |
5 | | -rem E.g. an Appveyor build. |
| 4 | +rem This is an internal script and should not be used directly. |
| 5 | + |
| 6 | +rem Ensure the environment is created and up to date |
6 | 7 | py -3.8-32 "%~dp0\ensureVenv.py" |
7 | 8 | if ERRORLEVEL 1 goto :EOF |
8 | | -call "%~dp0\..\.venv\scripts\activate.bat" |
| 9 | + |
| 10 | +rem Set the necessary environment variables to have Python use this virtual environment. |
| 11 | +rem This should set all the necessary environment variables that the standard .venv\scripts\activate.bat does |
| 12 | +rem Except that we set VIRTUAL_ENV to a path relative to this script, |
| 13 | +rem rather than it being hard-coded to where the virtual environment was first created. |
| 14 | + |
| 15 | +rem unset the PYTHONHOME variable so as to ensure that Python does not use a customized Python standard library. |
| 16 | +set PYTHONHOME= |
| 17 | +rem set the VIRTUAL_ENV variable instructing Python to use a virtual environment |
| 18 | +rem py.exe will honor VIRTUAL_ENV and launch the python.exe that it finds in %VIRTUAL_ENV%\scripts. |
| 19 | +rem %VIRTUAL_ENV%\scripts\python.exe will find pyvenv.cfg in its parent directory, |
| 20 | +rem which is actually what then causes Python to use the site-packages found in this virtual environment. |
| 21 | +set VIRTUAL_ENV=%~dp0..\.venv |
| 22 | +rem Add the virtual environment's scripts directory to the path |
| 23 | +set PATH=%VIRTUAL_ENV%\scripts;%PATH% |
| 24 | +rem Set an NVDA-specific variable to identify this official NVDA virtual environment from other 3rd party ones |
9 | 25 | set NVDA_VENV=%VIRTUAL_ENV% |
| 26 | +rem mention the environment in the prompt to make it obbvious it is active |
| 27 | +rem just in case this script is executed outside of a local block and not cleaned up. |
| 28 | +set PROMPT=[NVDA Venv] %PROMPT% |
0 commit comments