1
0
Fork 0
mirror of https://github.com/VSadov/Satori.git synced 2025-06-08 03:27:04 +09:00
Satori/eng/python.targets
Dan Moseley d021235cde
Improve error for missing Python (#81202)
* add error

* Fix a case were missing VC components didn't error

* handle non empty stdout

* Remove self assignment
2023-01-26 17:44:46 -07:00

31 lines
1.4 KiB
XML

<Project>
<Target Name="_FindPythonWindows"
Condition="$([MSBuild]::IsOSPlatform(Windows)) and '$(PYTHON)' == ''"
Returns="$(PYTHON)">
<PropertyGroup>
<_PythonLocationScript>-c "import sys; sys.stdout.write(sys.executable)"</_PythonLocationScript>
</PropertyGroup>
<Exec Command="py -3 $(_PythonLocationScript) 2&gt; nul || python3 $(_PythonLocationScript) 2&gt; nul || python $(_PythonLocationScript) 2&gt; nul"
StandardOutputImportance="Low"
EchoOff="true"
ContinueOnError="ErrorAndContinue"
ConsoleToMsBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="PYTHON" />
</Exec>
</Target>
<Target Name="_FindPythonUnix"
Condition="!$([MSBuild]::IsOSPlatform(Windows)) and '$(PYTHON)' == ''"
Returns="$(PYTHON)">
<Exec Command="command -v python3 || command -v python || command -v py"
StandardOutputImportance="Low"
EchoOff="true"
ContinueOnError="ErrorAndContinue"
ConsoleToMsBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="PYTHON" />
</Exec>
</Target>
<Target Name="FindPython" DependsOnTargets="_FindPythonWindows;_FindPythonUnix">
<Error Condition="'$(PYTHON)' == ''"
Text="Python not found. Please add Python 3 to your path and try again."/>
</Target>
</Project>