Skip to content
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

Improve error for missing Python #81202

Merged
merged 4 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eng/native/init-vs-env.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ exit /b 1
if "%__VCBuildArch%"=="" exit /b 0

:: Set the environment for the native build
if not exist "%VCINSTALLDIR%Auxiliary\Build\vcvarsall.bat" goto :VSMissing
call "%VCINSTALLDIR%Auxiliary\Build\vcvarsall.bat" %__VCBuildArch%
if not "%ErrorLevel%"=="0" exit /b 1

Expand Down
15 changes: 10 additions & 5 deletions eng/python.targets
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<Target Name="FindPythonWindows"
<Target Name="_FindPythonWindows"
Condition="$([MSBuild]::IsOSPlatform(Windows)) and '$(PYTHON)' == ''"
Returns="$(PYTHON)">
<PropertyGroup>
Expand All @@ -8,25 +8,30 @@
<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>
<PropertyGroup>
<PYTHON>"$(PYTHON)"</PYTHON>
<PYTHON>$(PYTHON)</PYTHON>
</PropertyGroup>
danmoseley marked this conversation as resolved.
Show resolved Hide resolved
</Target>
<Target Name="FindPythonUnix"
<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>
<PropertyGroup>
<PYTHON>"$(PYTHON)"</PYTHON>
<PYTHON>$(PYTHON)</PYTHON>
</PropertyGroup>
</Target>
<Target Name="FindPython" DependsOnTargets="FindPythonWindows;FindPythonUnix" />
<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>
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@

</PropertyGroup>

<Exec Command="$(PYTHON) -B $(_PythonWarningParameter) &quot;@(EventingGenerationScript)&quot; --man &quot;@(EventManifestFile)&quot; --intermediate &quot;$(_EventingSourceFileDirectory)&quot;" />
<Exec Command="&quot;$(PYTHON)&quot; -B $(_PythonWarningParameter) &quot;@(EventingGenerationScript)&quot; --man &quot;@(EventManifestFile)&quot; --intermediate &quot;$(_EventingSourceFileDirectory)&quot;" />

<ItemGroup>
<FileWrites Include="@(EventingSourceFile)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@
<_EventingSourceFileDirectory Condition="HasTrailingSlash('$(_EventingSourceFileDirectory)')">$(_EventingSourceFileDirectory.TrimEnd('\'))</_EventingSourceFileDirectory>
</PropertyGroup>

<Exec Command="$(PYTHON) -B $(_PythonWarningParameter) &quot;@(EventingGenerationScript)&quot; --man &quot;@(EventManifestFile)&quot; --intermediate &quot;$(_EventingSourceFileDirectory)&quot; --runtimeflavor mono" />
<Exec Command="&quot;$(PYTHON)&quot; -B $(_PythonWarningParameter) &quot;@(EventingGenerationScript)&quot; --man &quot;@(EventManifestFile)&quot; --intermediate &quot;$(_EventingSourceFileDirectory)&quot; --runtimeflavor mono" />

<ItemGroup>
<FileWrites Include="@(EventingSourceFile)" />
Expand Down