-
-
Notifications
You must be signed in to change notification settings - Fork 826
Allow NVDA build system to still function if NvDA repository is moved or copied to another location #12184
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
Allow NVDA build system to still function if NvDA repository is moved or copied to another location #12184
Changes from all commits
714e345
bd23724
7a487d6
9cbca82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,28 @@ | ||
| @echo off | ||
| rem this script ensures the NVDA build system Python virtual environment is created and up to date, | ||
| rem and then activates it. | ||
| 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. | ||
| rem E.g. an Appveyor build. | ||
| rem This is an internal script and should not be used directly. | ||
|
|
||
| rem Ensure the environment is created and up to date | ||
| py -3.8-32 "%~dp0\ensureVenv.py" | ||
| if ERRORLEVEL 1 goto :EOF | ||
| call "%~dp0\..\.venv\scripts\activate.bat" | ||
|
|
||
| rem Set the necessary environment variables to have Python use this virtual environment. | ||
| rem This should set all the necessary environment variables that the standard .venv\scripts\activate.bat does | ||
| rem Except that we set VIRTUAL_ENV to a path relative to this script, | ||
| rem rather than it being hard-coded to where the virtual environment was first created. | ||
|
|
||
| rem unset the PYTHONHOME variable so as to ensure that Python does not use a customized Python standard library. | ||
| set PYTHONHOME= | ||
| rem set the VIRTUAL_ENV variable instructing Python to use a virtual environment | ||
| rem py.exe will honor VIRTUAL_ENV and launch the python.exe that it finds in %VIRTUAL_ENV%\scripts. | ||
| rem %VIRTUAL_ENV%\scripts\python.exe will find pyvenv.cfg in its parent directory, | ||
| rem which is actually what then causes Python to use the site-packages found in this virtual environment. | ||
| set VIRTUAL_ENV=%~dp0..\.venv | ||
| rem Add the virtual environment's scripts directory to the path | ||
| set PATH=%VIRTUAL_ENV%\scripts;%PATH% | ||
| rem Set an NVDA-specific variable to identify this official NVDA virtual environment from other 3rd party ones | ||
| set NVDA_VENV=%VIRTUAL_ENV% | ||
| rem mention the environment in the prompt to make it obbvious it is active | ||
| rem just in case this script is executed outside of a local block and not cleaned up. | ||
| set PROMPT=[NVDA Venv] %PROMPT% | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,12 +16,14 @@ if "%VIRTUAL_ENV%" NEQ "" ( | |
| goto :EOF | ||
| ) | ||
|
|
||
| rem call setlocal to make sure that any environment variable changes made by activating the virtual environment | ||
| rem can be completely undone when endlocal is called or this script exits. | ||
| setlocal | ||
| echo Ensuring NVDA Python virtual environment | ||
| call "%~dp0\ensureAndActivate.bat" | ||
| if ERRORLEVEL 1 goto :EOF | ||
| echo call %* | ||
| call %* | ||
| rem the virtual environment will now be deactivated as endlocal will be reached. | ||
| echo Deactivating NVDA Python virtual environment | ||
| call "%~dp0\..\.venv\scripts\deactivate.bat" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. deactivate.bat sets particular environment variables back to their old values.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh ok. Might be worth a comment to point that out. Otherwise this all looks good. |
||
| endlocal | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to have comments that delineate the following set of steps as having been adapted from the
activate.batscript. This will help us to understand their origin and how to update them if they stop working (eg the requirements of theactivate.batscript change).