-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
build,windows: Implement python detection #13900
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
@IF NOT DEFINED DEBUG_HELPER @ECHO OFF | ||
SETLOCAL | ||
:: If python.exe is in %Path%, just validate | ||
FOR /F "delims=" %%a IN ('where python 2^> NUL') DO ( | ||
SET need_path=0 | ||
SET p=%%~dpa | ||
IF NOT ERRORLEVEL 1 GOTO :validate | ||
) | ||
|
||
:: Query the 3 locations mentioned in PEP 514 for a python2 InstallPath | ||
FOR %%K IN ( "HKCU\Software", "HKLM\SOFTWARE", "HKLM\Software\Wow6432Node") DO ( | ||
SET need_path=1 | ||
CALL :find-main-branch %%K | ||
:: If validate returns 0 just jump to the end | ||
IF NOT ERRORLEVEL 1 GOTO :validate | ||
) | ||
EXIT /B 1 | ||
|
||
:: Helper subroutine to handle quotes in %1 | ||
:find-main-branch | ||
SET main_key="%~1\Python\PythonCore" | ||
REG QUERY %main_key% /s | findstr "2." | findstr InstallPath > NUL 2> NUL | ||
IF NOT ERRORLEVEL 1 CALL :find-key %main_key% | ||
EXIT /B | ||
|
||
:: Query registry sub-tree for InstallPath | ||
:find-key | ||
FOR /F "delims=" %%a IN ('REG QUERY %1 /s ^| findstr "2." ^| findstr InstallPath') DO IF NOT ERRORLEVEL 1 CALL :find-path %%a | ||
EXIT /B | ||
|
||
:: Parse the value of %1 as the path for python.exe | ||
:find-path | ||
FOR /F "tokens=3*" %%a IN ('REG QUERY %1 /ve') DO ( | ||
SET pt=%%a | ||
IF NOT ERRORLEVEL 1 SET p=%pt% | ||
EXIT /B 0 | ||
) | ||
EXIT /B 1 | ||
|
||
:: Check if %p% holds a path to a real python2 executable | ||
:validate | ||
IF NOT EXIST "%p%python.exe" EXIT /B 1 | ||
:: Check if %p% is python2 | ||
%p%python.exe -V 2>&1 | findstr /R "^Python.2.*" > NUL | ||
IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL% | ||
:: We can wrap it up | ||
ENDLOCAL & SET pt=%p%& SET need_path_ext=%need_path% | ||
SET VCBUILD_PYTHON_LOCATION=%pt%python.exe | ||
IF %need_path_ext%==1 SET Path=%Path%;%pt% | ||
SET need_path_ext= | ||
EXIT /B %ERRORLEVEL% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@refack I was not able to do a careful review of this PR, but this line caught my eye. Is there a good reason for completely removing this? I believe this will completely break or release process, if DISTTYPEDIR is not set.
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.
Confirmed this breaks. Will try a fix in the build script instead.
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.
Woops. Opening a reversion PR.
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.
So I removed it because of
:exit
is redefined from L511Fix PR #13969