Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 6 additions & 2 deletions .github/workflows/msbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jobs:
with:
submodules: recursive
- uses: actions/setup-python@v5
id: cp310
id: cpy
with:
python-version: '3.10'
python-version: '3.14'

- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2
Expand All @@ -53,6 +53,10 @@ jobs:

- name: Build
working-directory: ${{env.GITHUB_WORKSPACE}}
env:
# setup-python installs into the tool cache, not C:\Python3XY, so point
# python.props straight at that root via the override env var.
SPLITGATE_PYTHON_DIR: ${{ env.pythonLocation }}
run: Tools/build.bat

- name: Upload Release Artifact
Expand Down
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"files.associations": {
"format": "cpp",
"chrono": "cpp"
},
"search.exclude": {
"**/Internal/external/pybind11/**": true,
"**/vcpkg_installed/**": true,
"**/x64/**": true
},
"files.watcherExclude": {
"**/Internal/external/pybind11/**": true,
"**/vcpkg_installed/**": true,
"**/x64/**": true
}
}
5 changes: 3 additions & 2 deletions Internal/Internal.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="$(ProjectDir)python.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
Expand All @@ -33,7 +34,7 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(ProjectDir)\external\pybind11\include;C:\Python310\include;C:\Python313\include;$(IncludePath)</IncludePath>
<IncludePath>$(ProjectDir)\external\pybind11\include;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)external\discord-rpc\lib\;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Label="Vcpkg">
Expand Down Expand Up @@ -62,7 +63,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>d3d11.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>C:\Python310\libs;C:\Python313\libs</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
73 changes: 73 additions & 0 deletions Internal/python.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?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 CPython 3.x works; the newest one found wins.

Resolution order:
1. /p:PythonRoot=<dir> (explicit MSBuild property)
2. %SPLITGATE_PYTHON_DIR% (environment variable override)
3. Well-known install locations, newest version first:
C:\Python3XY
%LOCALAPPDATA%\Programs\Python\Python3XY (per-user installer)
%ProgramFiles%\Python3XY (all-users installer)

To support a version not listed below, just add a <PythonCandidate> line.
-->

<ItemGroup>
<!-- 1/2. Explicit override (env var or /p:SPLITGATE_PYTHON_DIR) wins. -->
<PythonCandidate Include="$(SPLITGATE_PYTHON_DIR)\" Condition="'$(SPLITGATE_PYTHON_DIR)' != ''" />

<!-- 3. Well-known locations, newest first. Each line = one version, 3 tiers. -->
<PythonCandidate Include="C:\Python314\;$(LOCALAPPDATA)\Programs\Python\Python314\;$(ProgramW6432)\Python314\" />
<PythonCandidate Include="C:\Python313\;$(LOCALAPPDATA)\Programs\Python\Python313\;$(ProgramW6432)\Python313\" />
<PythonCandidate Include="C:\Python312\;$(LOCALAPPDATA)\Programs\Python\Python312\;$(ProgramW6432)\Python312\" />
<PythonCandidate Include="C:\Python311\;$(LOCALAPPDATA)\Programs\Python\Python311\;$(ProgramW6432)\Python311\" />
<PythonCandidate Include="C:\Python310\;$(LOCALAPPDATA)\Programs\Python\Python310\;$(ProgramW6432)\Python310\" />
<PythonCandidate Include="C:\Python39\;$(LOCALAPPDATA)\Programs\Python\Python39\;$(ProgramW6432)\Python39\" />
<PythonCandidate Include="C:\Python38\;$(LOCALAPPDATA)\Programs\Python\Python38\;$(ProgramW6432)\Python38\" />
<PythonCandidate Include="C:\Python37\;$(LOCALAPPDATA)\Programs\Python\Python37\;$(ProgramW6432)\Python37\" />
<PythonCandidate Include="C:\Python36\;$(LOCALAPPDATA)\Programs\Python\Python36\;$(ProgramW6432)\Python36\" />

<!-- 4. Fallback: read the path the official installer records in the registry
(catches non-standard install folders). Per version: HKCU, native HKLM,
and WOW6432Node HKLM so a 32-bit Python is found from a 64-bit MSBuild.
Missing keys expand to empty segments and are dropped. -->
<PythonCandidate Include="$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.14\InstallPath@);$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.14\InstallPath@);$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Python\PythonCore\3.14\InstallPath@)" />
<PythonCandidate Include="$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.13\InstallPath@);$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.13\InstallPath@);$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Python\PythonCore\3.13\InstallPath@)" />
<PythonCandidate Include="$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.12\InstallPath@);$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.12\InstallPath@);$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Python\PythonCore\3.12\InstallPath@)" />
<PythonCandidate Include="$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.11\InstallPath@);$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.11\InstallPath@);$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Python\PythonCore\3.11\InstallPath@)" />
<PythonCandidate Include="$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.10\InstallPath@);$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.10\InstallPath@);$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Python\PythonCore\3.10\InstallPath@)" />
<PythonCandidate Include="$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.9\InstallPath@);$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.9\InstallPath@);$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Python\PythonCore\3.9\InstallPath@)" />
<PythonCandidate Include="$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.8\InstallPath@);$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.8\InstallPath@);$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Python\PythonCore\3.8\InstallPath@)" />
<PythonCandidate Include="$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.7\InstallPath@);$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.7\InstallPath@);$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Python\PythonCore\3.7\InstallPath@)" />
<PythonCandidate Include="$(registry:HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.6\InstallPath@);$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.6\InstallPath@);$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Python\PythonCore\3.6\InstallPath@)" />
</ItemGroup>

<Target Name="ResolvePython" BeforeTargets="ClCompile;Link">
<!-- Honor an explicit /p:PythonRoot=... ; just normalize the trailing slash. -->
<PropertyGroup Condition="'$(PythonRoot)' != '' and !HasTrailingSlash('$(PythonRoot)')">
<PythonRoot>$(PythonRoot)\</PythonRoot>
</PropertyGroup>

<!-- First candidate that actually contains Python.h wins (batched, empty-guarded). -->
<PropertyGroup>
<PythonRoot Condition="'$(PythonRoot)' == '' and Exists('%(PythonCandidate.Identity)include\Python.h')">%(PythonCandidate.Identity)</PythonRoot>
</PropertyGroup>

<Error Condition="'$(PythonRoot)' == ''"
Text="No 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)" />

<ItemGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(PythonRoot)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(PythonRoot)libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemGroup>
</Target>
</Project>
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
• Use the `Ins` button to show/hide the gui

## Compile
To compile the project make you you have [Visual Studio 22](https://visualstudio.microsoft.com/it/downloads/), [vcpkg](https://vcpkg.io/en/getting-started) integrated with `MSBuild` and Python 3.13 installed
To compile the project make sure you have [Visual Studio 22](https://visualstudio.microsoft.com/it/downloads/), [vcpkg](https://vcpkg.io/en/getting-started) integrated with `MSBuild` and any [Python](https://www.python.org/downloads/) 3.x installed

> [!IMPORTANT]
> Internal.vcxproj expects python path to be `C:\Python313`, either match it or update header import configuration
> `Internal` embeds Python (via pybind11 + `<Python.h>`), so a Python 3.x installation is required to compile.

`Internal/python.props` auto-detects the newest Python installed in a standard location (`C:\Python3XY`, `%LOCALAPPDATA%\Programs\Python\Python3XY`, or `%ProgramFiles%\Python3XY`), falling back to the install path recorded in the registry — no configuration needed for a default install.

If Python is installed somewhere custom that isn't picked up, set the `SPLITGATE_PYTHON_DIR` environment variable to your Python root (the folder containing `include\` and `libs\`), or pass `/p:PythonRoot=<dir>` to MSBuild. Whichever version is selected must match the `python3XY.dll` present at runtime.

- Install `Internal` dependencies:
```sh
Expand Down
Loading