Repository navigation
Expand file tree
/
Copy pathpython.props
More file actions
63 lines (56 loc) · 6.06 KB
/
Copy pathpython.props
File metadata and controls
63 lines (56 loc) · 6.06 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
Resolves the Python root used to compile/link the embedded interpreter
(pybind11 + <Python.h>). Any 64-bit CPython 3.x works; the newest one found
wins. Internal is an x64 build, so only 64-bit installs are considered.
Resolution order (first match wins):
1. /p:PythonRoot=<dir> (explicit MSBuild property)
2. %SPLITGATE_PYTHON_DIR% (environment variable)
3. C:\Python3XY (manual install convention)
4. Official installer InstallPath, HKCU then HKLM (covers per-user and
all-user installs in any folder)
Resolution is done here (static, at import time) rather than in a target on
purpose: IncludePath/LibraryPath below feed the compiler/linker search paths
(%INCLUDE% / %LIB%), which MSBuild freezes before a BeforeTargets="Link"
target would run — so resolving in a target links against a lib dir the
linker never searches. To support another version, add a pair of lines below.
-->
<PropertyGroup Label="PythonResolve">
<!-- 2. Environment-variable override. -->
<PythonRoot Condition="'$(PythonRoot)' == '' and '$(SPLITGATE_PYTHON_DIR)' != '' and Exists('$(SPLITGATE_PYTHON_DIR)\include\Python.h')">$(SPLITGATE_PYTHON_DIR)\</PythonRoot>
<!-- 3. Manual C:\Python3XY convention, newest first. -->
<PythonRoot Condition="'$(PythonRoot)' == '' and Exists('C:\Python315\include\Python.h')">C:\Python315\</PythonRoot>
<PythonRoot Condition="'$(PythonRoot)' == '' and Exists('C:\Python314\include\Python.h')">C:\Python314\</PythonRoot>
<PythonRoot Condition="'$(PythonRoot)' == '' and Exists('C:\Python313\include\Python.h')">C:\Python313\</PythonRoot>
<PythonRoot Condition="'$(PythonRoot)' == '' and Exists('C:\Python312\include\Python.h')">C:\Python312\</PythonRoot>
<PythonRoot Condition="'$(PythonRoot)' == '' and Exists('C:\Python311\include\Python.h')">C:\Python311\</PythonRoot>
<PythonRoot Condition="'$(PythonRoot)' == '' and Exists('C:\Python310\include\Python.h')">C:\Python310\</PythonRoot>
<!-- 4. Official installer InstallPath from the registry (HKCU then HKLM),
newest first. The value already ends with a backslash. -->
<PythonRoot Condition="'$(PythonRoot)' == '' and Exists('$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.15\InstallPath@)include\Python.h')">$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.15\InstallPath@)</PythonRoot>
<PythonRoot Condition="'$(PythonRoot)' == '' and Exists('$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.15\InstallPath@)include\Python.h')">$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.15\InstallPath@)</PythonRoot>
<PythonRoot Condition="'$(PythonRoot)' == '' and Exists('$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.14\InstallPath@)include\Python.h')">$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.14\InstallPath@)</PythonRoot>
<PythonRoot Condition="'$(PythonRoot)' == '' and Exists('$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.14\InstallPath@)include\Python.h')">$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.14\InstallPath@)</PythonRoot>
<PythonRoot Condition="'$(PythonRoot)' == '' and Exists('$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.13\InstallPath@)include\Python.h')">$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.13\InstallPath@)</PythonRoot>
<PythonRoot Condition="'$(PythonRoot)' == '' and Exists('$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.13\InstallPath@)include\Python.h')">$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.13\InstallPath@)</PythonRoot>
<PythonRoot Condition="'$(PythonRoot)' == '' and Exists('$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.12\InstallPath@)include\Python.h')">$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.12\InstallPath@)</PythonRoot>
<PythonRoot Condition="'$(PythonRoot)' == '' and Exists('$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.12\InstallPath@)include\Python.h')">$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.12\InstallPath@)</PythonRoot>
<PythonRoot Condition="'$(PythonRoot)' == '' and Exists('$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.11\InstallPath@)include\Python.h')">$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.11\InstallPath@)</PythonRoot>
<PythonRoot Condition="'$(PythonRoot)' == '' and Exists('$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.11\InstallPath@)include\Python.h')">$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.11\InstallPath@)</PythonRoot>
<PythonRoot Condition="'$(PythonRoot)' == '' and Exists('$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.10\InstallPath@)include\Python.h')">$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.10\InstallPath@)</PythonRoot>
<PythonRoot Condition="'$(PythonRoot)' == '' and Exists('$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.10\InstallPath@)include\Python.h')">$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.10\InstallPath@)</PythonRoot>
<!-- Normalize the trailing slash for a /p:PythonRoot=... override. -->
<PythonRoot Condition="'$(PythonRoot)' != '' and !HasTrailingSlash('$(PythonRoot)')">$(PythonRoot)\</PythonRoot>
</PropertyGroup>
<PropertyGroup Condition="'$(PythonRoot)' != ''">
<IncludePath>$(PythonRoot)include;$(IncludePath)</IncludePath>
<LibraryPath>$(PythonRoot)libs;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<!-- Fail early with a clear message (and echo the chosen root) at build time. -->
<Target Name="CheckPython" BeforeTargets="ClCompile">
<Error Condition="'$(PythonRoot)' == ''"
Text="No 64-bit CPython 3.x installation found. Install Python (official installer) or set the SPLITGATE_PYTHON_DIR environment variable to your Python root (the folder containing include\ and libs\)." />
<Message Importance="high" Text="Splitgate: using Python at $(PythonRoot)" />
</Target>
</Project>