Welcome to mirror list, hosted at ThFree Co, Russian Federation.

python.targets « eng - github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0158d38270d6378db9cdc86d52f39d3b1ca798a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<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"
          ConsoleToMsBuild="true">
      <Output TaskParameter="ConsoleOutput" PropertyName="PYTHON" />
    </Exec>
    <PropertyGroup>
      <PYTHON>"$(PYTHON)"</PYTHON>
    </PropertyGroup>
  </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"
          ConsoleToMsBuild="true">
      <Output TaskParameter="ConsoleOutput" PropertyName="PYTHON" />
    </Exec>
    <PropertyGroup>
      <PYTHON>"$(PYTHON)"</PYTHON>
    </PropertyGroup>
  </Target>
  <Target Name="FindPython" DependsOnTargets="FindPythonWindows;FindPythonUnix" />
</Project>