steamworks-bindings 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- steamworks_bindings-0.1.0/.github/workflows/ci.yml +77 -0
- steamworks_bindings-0.1.0/.github/workflows/release.yml +35 -0
- steamworks_bindings-0.1.0/.gitignore +32 -0
- steamworks_bindings-0.1.0/CLAUDE.md +80 -0
- steamworks_bindings-0.1.0/CMakeLists.txt +122 -0
- steamworks_bindings-0.1.0/LICENSE +202 -0
- steamworks_bindings-0.1.0/NOTICE +2 -0
- steamworks_bindings-0.1.0/PKG-INFO +83 -0
- steamworks_bindings-0.1.0/README.md +60 -0
- steamworks_bindings-0.1.0/build_support/backend.py +126 -0
- steamworks_bindings-0.1.0/build_support/sdk_locate.py +295 -0
- steamworks_bindings-0.1.0/codegen/__init__.py +1 -0
- steamworks_bindings-0.1.0/codegen/__main__.py +35 -0
- steamworks_bindings-0.1.0/codegen/config.py +161 -0
- steamworks_bindings-0.1.0/codegen/docs.py +194 -0
- steamworks_bindings-0.1.0/codegen/emit.py +653 -0
- steamworks_bindings-0.1.0/codegen/model.py +92 -0
- steamworks_bindings-0.1.0/docs/wiki/API-conventions.md +80 -0
- steamworks_bindings-0.1.0/docs/wiki/Contributing.md +26 -0
- steamworks_bindings-0.1.0/docs/wiki/Examples.md +57 -0
- steamworks_bindings-0.1.0/docs/wiki/FAQ.md +31 -0
- steamworks_bindings-0.1.0/docs/wiki/Home.md +54 -0
- steamworks_bindings-0.1.0/docs/wiki/Installation.md +62 -0
- steamworks_bindings-0.1.0/docs/wiki/Quick-start.md +58 -0
- steamworks_bindings-0.1.0/docs/wiki/Shipping-your-game.md +58 -0
- steamworks_bindings-0.1.0/docs/wiki/Troubleshooting.md +43 -0
- steamworks_bindings-0.1.0/examples/basic.py +79 -0
- steamworks_bindings-0.1.0/examples/callbacks.py +30 -0
- steamworks_bindings-0.1.0/examples/game_server.py +29 -0
- steamworks_bindings-0.1.0/examples/pygame_game/README.md +30 -0
- steamworks_bindings-0.1.0/examples/pygame_game/game.py +110 -0
- steamworks_bindings-0.1.0/examples/pygame_game/game.spec +23 -0
- steamworks_bindings-0.1.0/examples/restart_via_steam.py +42 -0
- steamworks_bindings-0.1.0/pyproject.toml +46 -0
- steamworks_bindings-0.1.0/scripts/install_compiler.py +119 -0
- steamworks_bindings-0.1.0/src/cpp/common.h +152 -0
- steamworks_bindings-0.1.0/src/cpp/extras.cpp +303 -0
- steamworks_bindings-0.1.0/src/cpp/hooks.cpp +232 -0
- steamworks_bindings-0.1.0/src/cpp/matchmaking.cpp +261 -0
- steamworks_bindings-0.1.0/src/cpp/module.cpp +233 -0
- steamworks_bindings-0.1.0/src/steamworks/__init__.py +27 -0
- steamworks_bindings-0.1.0/src/steamworks/_callbacks.py +113 -0
- steamworks_bindings-0.1.0/src/steamworks/_matchmaking.py +38 -0
- steamworks_bindings-0.1.0/src/steamworks/py.typed +0 -0
- steamworks_bindings-0.1.0/tests/test_core.py +206 -0
- steamworks_bindings-0.1.0/tests/test_sdk_locate.py +123 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [dev, master]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
# Needs no Steamworks SDK: syntax checks and the SDK-discovery tests (fake SDK layouts only).
|
|
13
|
+
unit:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.15"
|
|
20
|
+
allow-prereleases: true
|
|
21
|
+
- run: python -m pip install pytest ruff
|
|
22
|
+
- run: python -m compileall -q codegen build_support scripts src/steamworks
|
|
23
|
+
- run: ruff check --select E9,F63,F7,F82 .
|
|
24
|
+
- run: python -m pytest -q tests/test_sdk_locate.py
|
|
25
|
+
|
|
26
|
+
# Builds the real extension. Valve's SDK is never in this repo, so the job downloads the zip from a
|
|
27
|
+
# location you control. Add repository secrets:
|
|
28
|
+
# STEAMWORKS_SDK_URL direct download URL of steamworks_sdk_165.zip (e.g. private storage)
|
|
29
|
+
# STEAMWORKS_SDK_SHA256 its SHA-256 (optional but recommended)
|
|
30
|
+
# Without the secret (e.g. pull requests from forks) the job is skipped with a notice.
|
|
31
|
+
build:
|
|
32
|
+
name: build (${{ matrix.name }})
|
|
33
|
+
runs-on: ${{ matrix.os }}
|
|
34
|
+
strategy:
|
|
35
|
+
fail-fast: false
|
|
36
|
+
matrix:
|
|
37
|
+
include:
|
|
38
|
+
- { name: linux-x64, os: ubuntu-latest }
|
|
39
|
+
- { name: linux-arm64, os: ubuntu-24.04-arm }
|
|
40
|
+
- { name: windows-x64, os: windows-latest }
|
|
41
|
+
- { name: windows-x86, os: windows-latest, arch: x86 }
|
|
42
|
+
- { name: macos-arm64, os: macos-latest }
|
|
43
|
+
- { name: macos-x64, os: macos-15-intel }
|
|
44
|
+
env:
|
|
45
|
+
SDK_URL: ${{ secrets.STEAMWORKS_SDK_URL }}
|
|
46
|
+
SDK_SHA256: ${{ secrets.STEAMWORKS_SDK_SHA256 }}
|
|
47
|
+
steps:
|
|
48
|
+
- name: SDK secret present?
|
|
49
|
+
shell: bash
|
|
50
|
+
run: |
|
|
51
|
+
if [ -z "$SDK_URL" ]; then echo "::notice::STEAMWORKS_SDK_URL is not set; skipping the build."; fi
|
|
52
|
+
- uses: actions/checkout@v4
|
|
53
|
+
if: env.SDK_URL != ''
|
|
54
|
+
- uses: actions/setup-python@v5
|
|
55
|
+
if: env.SDK_URL != ''
|
|
56
|
+
with:
|
|
57
|
+
python-version: "3.15"
|
|
58
|
+
allow-prereleases: true
|
|
59
|
+
architecture: ${{ matrix.arch || 'x64' }}
|
|
60
|
+
- name: Download the SDK
|
|
61
|
+
if: env.SDK_URL != ''
|
|
62
|
+
shell: bash
|
|
63
|
+
run: |
|
|
64
|
+
mkdir -p "$RUNNER_TEMP/sdk"
|
|
65
|
+
curl -fsSL --retry 3 -o "$RUNNER_TEMP/sdk/steamworks_sdk.zip" "$SDK_URL"
|
|
66
|
+
if [ -n "$SDK_SHA256" ]; then
|
|
67
|
+
python -c "import hashlib,sys;h=hashlib.sha256(open(sys.argv[1],'rb').read()).hexdigest();sys.exit(0 if h==sys.argv[2].lower() else 'SDK checksum mismatch: '+h)" "$RUNNER_TEMP/sdk/steamworks_sdk.zip" "$SDK_SHA256"
|
|
68
|
+
fi
|
|
69
|
+
echo "STEAMWORKS_SDK=$RUNNER_TEMP/sdk/steamworks_sdk.zip" >> "$GITHUB_ENV"
|
|
70
|
+
- name: Build and install
|
|
71
|
+
if: env.SDK_URL != ''
|
|
72
|
+
run: python -m pip install -v ".[test]"
|
|
73
|
+
- name: Test
|
|
74
|
+
if: env.SDK_URL != ''
|
|
75
|
+
run: python -m pytest -q tests
|
|
76
|
+
# No wheel upload: the build contains Valve's steam_api binary, which must not be redistributed
|
|
77
|
+
# (artifacts of a public repository are downloadable).
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
|
|
3
|
+
# Publishes the sdist only. No wheels: the extension is built on the user's machine against their own SDK.
|
|
4
|
+
# Triggered by the tag only: also listening for "release published" would publish twice.
|
|
5
|
+
on:
|
|
6
|
+
push:
|
|
7
|
+
tags: ["v*"]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
sdist:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: actions/setup-python@v5
|
|
15
|
+
with:
|
|
16
|
+
python-version: "3.13"
|
|
17
|
+
- run: python -m pip install build
|
|
18
|
+
- run: python -m build --sdist
|
|
19
|
+
- uses: actions/upload-artifact@v4
|
|
20
|
+
with:
|
|
21
|
+
name: sdist
|
|
22
|
+
path: dist/*.tar.gz
|
|
23
|
+
|
|
24
|
+
publish:
|
|
25
|
+
needs: sdist
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
environment: pypi
|
|
28
|
+
permissions:
|
|
29
|
+
id-token: write
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/download-artifact@v4
|
|
32
|
+
with:
|
|
33
|
+
name: sdist
|
|
34
|
+
path: dist
|
|
35
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.eggs/
|
|
6
|
+
dist/
|
|
7
|
+
build/
|
|
8
|
+
_skbuild/
|
|
9
|
+
*.so
|
|
10
|
+
*.pyd
|
|
11
|
+
*.dylib
|
|
12
|
+
*.dll
|
|
13
|
+
.venv/
|
|
14
|
+
venv/
|
|
15
|
+
.pytest_cache/
|
|
16
|
+
.mypy_cache/
|
|
17
|
+
.ruff_cache/
|
|
18
|
+
|
|
19
|
+
# Steamworks SDK: never commit it
|
|
20
|
+
sdk/
|
|
21
|
+
steamworks_sdk*
|
|
22
|
+
steam_appid.txt
|
|
23
|
+
|
|
24
|
+
# Editors / OS
|
|
25
|
+
.vscode/
|
|
26
|
+
.idea/
|
|
27
|
+
.DS_Store
|
|
28
|
+
Thumbs.db
|
|
29
|
+
|
|
30
|
+
# Local secrets
|
|
31
|
+
.NOTE
|
|
32
|
+
.env
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# steamworks-py
|
|
2
|
+
|
|
3
|
+
Python bindings **generator** for the Steamworks SDK. Status: core + `ISteamUser` working (pre-alpha).
|
|
4
|
+
|
|
5
|
+
- PyPI name: `steamworks-bindings` (`steamworks-py` was rejected as too similar to `steamworkspy`); GitHub repo stays `steamworks-py`. Import name: `steamworks`.
|
|
6
|
+
- License: Apache-2.0 (see `LICENSE`, `NOTICE` credits Schunche).
|
|
7
|
+
|
|
8
|
+
## Branches
|
|
9
|
+
|
|
10
|
+
`dev` is the working branch: commit and push straight to `dev` (no task branches, no PRs; decided because
|
|
11
|
+
branches can't be deleted from the cloud sessions). `master` stays stable and only gets merges from `dev`
|
|
12
|
+
when Schun asks.
|
|
13
|
+
|
|
14
|
+
## Core idea
|
|
15
|
+
|
|
16
|
+
Turn a user-supplied Steamworks SDK (latest from partner.steamgames.com; currently v1.65)
|
|
17
|
+
into a compiled Python module. **We never ship the SDK, its headers, or its binaries.**
|
|
18
|
+
Never commit SDK files to this repo.
|
|
19
|
+
|
|
20
|
+
## Plan
|
|
21
|
+
|
|
22
|
+
- **Source of truth:** generate from `sdk/public/steam/steam_api.json`
|
|
23
|
+
(v1.65: 34 interfaces, 921 methods, 196 callbacks).
|
|
24
|
+
- **Extension:** compiled for speed. Toolchain: nanobind + scikit-build-core (decided).
|
|
25
|
+
Compile against the user's real SDK headers so struct packing is correct per platform.
|
|
26
|
+
- **Install is pip-native:** `STEAMWORKS_SDK=/path/to/sdk pip install steamworks-bindings`
|
|
27
|
+
builds at install time. Error messages must be very clear (missing SDK path, wrong
|
|
28
|
+
layout, no compiler, etc.). Provide an optional script that installs a C++ compiler
|
|
29
|
+
for users who want it. Goal: as user-friendly as possible.
|
|
30
|
+
- **SDK discovery (decided, no auto-download):** we never download the SDK ourselves (partner login required; Valve's terms).
|
|
31
|
+
1. `STEAMWORKS_SDK` accepts either the SDK zip directly or an extracted folder.
|
|
32
|
+
2. If unset, auto-detect `steamworks_sdk_*.zip` files and extracted SDK folders in common locations (project dir, `~/Downloads`); newest SDK version wins.
|
|
33
|
+
3. If nothing is found, fail with a guided error: the partner download link (https://partner.steamgames.com/downloads/list) and the exact next command to run.
|
|
34
|
+
- **Cloud dev sessions:** the SDK zip is kept in the project's shared files at
|
|
35
|
+
`/mnt/project-files/sdk/` (use the newest zip there; build with
|
|
36
|
+
`STEAMWORKS_SDK=/mnt/project-files/sdk/steamworks_sdk_165.zip pip install .`). Never from git.
|
|
37
|
+
- **Python:** >= 3.15.
|
|
38
|
+
- **SDK version:** target the latest SDK only.
|
|
39
|
+
- **Platforms:** desktop first: Windows 32/64, Linux 32/64/arm64, macOS. Android later.
|
|
40
|
+
- **Testing:** use app ID 480 (Spacewar).
|
|
41
|
+
- **CI:** `.github/workflows/ci.yml` runs unit tests without the SDK; the multi-platform build job skips cleanly (no failure) while the `STEAMWORKS_SDK_URL` repo secret is absent. Adding that secret (and optionally `STEAMWORKS_SDK_SHA256`) turns the build/test matrix on. For 0.1.0 only Linux x64 is tested.
|
|
42
|
+
|
|
43
|
+
## API design rules
|
|
44
|
+
|
|
45
|
+
- Exact 1:1 mirror of the C++ API names. Minimize changes; the goal is none.
|
|
46
|
+
- Overloads that the flat API splits (e.g. `GetStatInt32` / `GetStatFloat`) are
|
|
47
|
+
re-merged into one method dispatching on argument type (e.g. `GetStat`).
|
|
48
|
+
- Out-parameter overloads that differ only in output type (decided): one method with a trailing
|
|
49
|
+
`type=int` (or `type=float`, or a ctypes type such as `ctypes.c_int32` / `ctypes.c_float`) argument, returning `(ok, value)`, e.g. `ok, v = GetStat(name, type=int)`.
|
|
50
|
+
Only the `type=` selector accepts ctypes; there is no ctypes out-parameter form (decided).
|
|
51
|
+
The generator merges these automatically. Use the same convention for future cases.
|
|
52
|
+
- Matchmaking `*Response` interfaces need a C++ shim.
|
|
53
|
+
- `CSteamID` / `CGameID` are handled by hand.
|
|
54
|
+
- Normal synchronous callbacks and call results; **no asyncio**.
|
|
55
|
+
- Ship generated `.pyi` stubs.
|
|
56
|
+
- Docstrings (methods, interfaces, structs, callbacks, enums, fields) are extracted at build time from the comments in the
|
|
57
|
+
user's own SDK headers (`codegen/docs.py`) and appear in hovers and the stubs. We never ship Valve's text.
|
|
58
|
+
|
|
59
|
+
## Roadmap
|
|
60
|
+
|
|
61
|
+
Module by module, goal is the full API:
|
|
62
|
+
1. Core init + `ISteamUser` (done)
|
|
63
|
+
2. `ISteamUserStats` (done)
|
|
64
|
+
3. Remaining interfaces: all bound (incl. game server) except `ISteamClient`. Hand-written wrappers live in `src/cpp/extras.cpp`, `hooks.cpp` and `matchmaking.cpp`; `config.HAND_WRITTEN` and `config.UNSUPPORTED` (types missing from the public SDK) are reported in `codegen_report.txt`
|
|
65
|
+
|
|
66
|
+
## Layout
|
|
67
|
+
|
|
68
|
+
- `build_support/` : PEP 517 backend wrapper (SDK discovery/extraction, compiler check, guided errors).
|
|
69
|
+
- `codegen/` : `steam_api.json` -> nanobind C++. `config.py` lists bound interfaces (`INTERFACES`),
|
|
70
|
+
overrides and exclusions. The build writes `codegen_report.txt` listing anything skipped.
|
|
71
|
+
- `src/cpp/` : hand-written core (`SteamAPI_*`, `CSteamID`, `CGameID`, callback pump). Generated code is
|
|
72
|
+
never committed.
|
|
73
|
+
- `src/steamworks/` : Python package; `CCallback` / `CCallResult` (sync, run inside `SteamAPI_RunCallbacks`).
|
|
74
|
+
- Dev: `python3.15 -m venv v && v/bin/pip install . pytest && v/bin/python -I -m pytest tests`.
|
|
75
|
+
|
|
76
|
+
## Generator safety rules
|
|
77
|
+
|
|
78
|
+
Pointer params are never guessed: a non-const pointer next to a count/size param must be classified by the
|
|
79
|
+
JSON annotation (`out_array_count`, `array_count`, ...) or `config.OVERRIDES` (`in_array`, `out_array[:expr]`),
|
|
80
|
+
otherwise the method is skipped and reported. Never bind an array pointer as a single element.
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.18...3.31)
|
|
2
|
+
project(steamworks_py LANGUAGES CXX)
|
|
3
|
+
|
|
4
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
5
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
6
|
+
|
|
7
|
+
find_package(Python 3.15 REQUIRED COMPONENTS Interpreter Development.Module)
|
|
8
|
+
execute_process(
|
|
9
|
+
COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir
|
|
10
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE nanobind_ROOT)
|
|
11
|
+
find_package(nanobind CONFIG REQUIRED)
|
|
12
|
+
|
|
13
|
+
# ---------------------------------------------------------------- SDK
|
|
14
|
+
# Normally set by build_support/backend.py (pip install). For plain CMake
|
|
15
|
+
# builds, fall back to the same locator script.
|
|
16
|
+
set(STEAMWORKS_SDK_DIR "" CACHE PATH "Path to the Steamworks SDK 'sdk' folder")
|
|
17
|
+
set(STEAMWORKS_SDK_VERSION "" CACHE STRING "Steamworks SDK version (e.g. 1.65)")
|
|
18
|
+
if(NOT STEAMWORKS_SDK_DIR)
|
|
19
|
+
execute_process(
|
|
20
|
+
COMMAND "${Python_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/build_support/sdk_locate.py"
|
|
21
|
+
RESULT_VARIABLE _sdk_rc OUTPUT_VARIABLE STEAMWORKS_SDK_DIR
|
|
22
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
23
|
+
if(NOT _sdk_rc EQUAL 0)
|
|
24
|
+
message(FATAL_ERROR "steamworks-py: Steamworks SDK not found (see the message above).")
|
|
25
|
+
endif()
|
|
26
|
+
endif()
|
|
27
|
+
file(TO_CMAKE_PATH "${STEAMWORKS_SDK_DIR}" STEAMWORKS_SDK_DIR)
|
|
28
|
+
set(STEAM_JSON "${STEAMWORKS_SDK_DIR}/public/steam/steam_api.json")
|
|
29
|
+
if(NOT EXISTS "${STEAM_JSON}")
|
|
30
|
+
message(FATAL_ERROR "steamworks-py: ${STEAM_JSON} not found. STEAMWORKS_SDK_DIR must be the SDK's 'sdk' folder.")
|
|
31
|
+
endif()
|
|
32
|
+
|
|
33
|
+
# Pick the redistributable for this platform.
|
|
34
|
+
set(_bin "${STEAMWORKS_SDK_DIR}/redistributable_bin")
|
|
35
|
+
if(WIN32)
|
|
36
|
+
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
37
|
+
set(STEAM_IMPLIB "${_bin}/win64/steam_api64.lib")
|
|
38
|
+
set(STEAM_RUNTIME "${_bin}/win64/steam_api64.dll")
|
|
39
|
+
else()
|
|
40
|
+
set(STEAM_IMPLIB "${_bin}/steam_api.lib")
|
|
41
|
+
set(STEAM_RUNTIME "${_bin}/steam_api.dll")
|
|
42
|
+
endif()
|
|
43
|
+
elseif(APPLE)
|
|
44
|
+
set(STEAM_RUNTIME "${_bin}/osx/libsteam_api.dylib")
|
|
45
|
+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
46
|
+
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" _proc)
|
|
47
|
+
if(_proc MATCHES "aarch64|arm64")
|
|
48
|
+
set(_dir linuxarm64)
|
|
49
|
+
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
|
50
|
+
set(_dir linux32)
|
|
51
|
+
else()
|
|
52
|
+
set(_dir linux64)
|
|
53
|
+
endif()
|
|
54
|
+
set(STEAM_RUNTIME "${_bin}/${_dir}/libsteam_api.so")
|
|
55
|
+
else()
|
|
56
|
+
message(FATAL_ERROR "steamworks-py: unsupported platform ${CMAKE_SYSTEM_NAME}. Supported: Windows, Linux, macOS.")
|
|
57
|
+
endif()
|
|
58
|
+
foreach(_f IN ITEMS ${STEAM_RUNTIME} ${STEAM_IMPLIB})
|
|
59
|
+
if(NOT EXISTS "${_f}")
|
|
60
|
+
message(FATAL_ERROR "steamworks-py: ${_f} is missing from your SDK. Re-download the SDK zip.")
|
|
61
|
+
endif()
|
|
62
|
+
endforeach()
|
|
63
|
+
|
|
64
|
+
add_library(steam_api SHARED IMPORTED)
|
|
65
|
+
set_target_properties(steam_api PROPERTIES IMPORTED_LOCATION "${STEAM_RUNTIME}")
|
|
66
|
+
if(WIN32)
|
|
67
|
+
set_target_properties(steam_api PROPERTIES IMPORTED_IMPLIB "${STEAM_IMPLIB}")
|
|
68
|
+
endif()
|
|
69
|
+
|
|
70
|
+
# ---------------------------------------------------------------- codegen
|
|
71
|
+
set(GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
|
72
|
+
set(GEN_SOURCES
|
|
73
|
+
"${GEN_DIR}/gen_enums.cpp"
|
|
74
|
+
"${GEN_DIR}/gen_structs.cpp"
|
|
75
|
+
"${GEN_DIR}/gen_callbacks.cpp"
|
|
76
|
+
"${GEN_DIR}/gen_interfaces.cpp")
|
|
77
|
+
# No CONFIGURE_DEPENDS: it makes the VS generator run a VerifyGlobs cmd step that
|
|
78
|
+
# breaks when the project path has non-ASCII characters.
|
|
79
|
+
file(GLOB CODEGEN_PY "${CMAKE_CURRENT_SOURCE_DIR}/codegen/*.py")
|
|
80
|
+
add_custom_command(
|
|
81
|
+
OUTPUT ${GEN_SOURCES}
|
|
82
|
+
COMMAND "${Python_EXECUTABLE}" -m codegen --json "${STEAM_JSON}" --out "${GEN_DIR}"
|
|
83
|
+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
84
|
+
DEPENDS ${CODEGEN_PY} "${STEAM_JSON}"
|
|
85
|
+
COMMENT "Generating Steamworks bindings from steam_api.json"
|
|
86
|
+
VERBATIM)
|
|
87
|
+
|
|
88
|
+
# ---------------------------------------------------------------- module
|
|
89
|
+
nanobind_add_module(_steamworks NB_STATIC
|
|
90
|
+
src/cpp/module.cpp
|
|
91
|
+
src/cpp/extras.cpp
|
|
92
|
+
src/cpp/hooks.cpp
|
|
93
|
+
src/cpp/matchmaking.cpp
|
|
94
|
+
${GEN_SOURCES})
|
|
95
|
+
target_include_directories(_steamworks PRIVATE
|
|
96
|
+
"${STEAMWORKS_SDK_DIR}/public"
|
|
97
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/src/cpp")
|
|
98
|
+
target_compile_definitions(_steamworks PRIVATE
|
|
99
|
+
STEAMWORKS_SDK_VERSION_STR="${STEAMWORKS_SDK_VERSION}")
|
|
100
|
+
target_link_libraries(_steamworks PRIVATE steam_api)
|
|
101
|
+
if(APPLE)
|
|
102
|
+
set_target_properties(_steamworks PROPERTIES INSTALL_RPATH "@loader_path" BUILD_RPATH "@loader_path")
|
|
103
|
+
elseif(UNIX)
|
|
104
|
+
set_target_properties(_steamworks PROPERTIES INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN")
|
|
105
|
+
endif()
|
|
106
|
+
# Put the Steam runtime next to the module so it loads (and stubgen can import it).
|
|
107
|
+
add_custom_command(TARGET _steamworks POST_BUILD
|
|
108
|
+
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${STEAM_RUNTIME}" "$<TARGET_FILE_DIR:_steamworks>")
|
|
109
|
+
|
|
110
|
+
install(TARGETS _steamworks LIBRARY DESTINATION steamworks RUNTIME DESTINATION steamworks)
|
|
111
|
+
install(FILES "${STEAM_RUNTIME}" DESTINATION steamworks)
|
|
112
|
+
|
|
113
|
+
# ---------------------------------------------------------------- stubs
|
|
114
|
+
option(STEAMWORKS_STUBS "Generate .pyi stubs" ON)
|
|
115
|
+
if(STEAMWORKS_STUBS)
|
|
116
|
+
nanobind_add_stub(_steamworks_stub
|
|
117
|
+
MODULE _steamworks
|
|
118
|
+
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_steamworks.pyi"
|
|
119
|
+
PYTHON_PATH "$<TARGET_FILE_DIR:_steamworks>"
|
|
120
|
+
DEPENDS _steamworks)
|
|
121
|
+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/_steamworks.pyi" DESTINATION steamworks)
|
|
122
|
+
endif()
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: steamworks-bindings
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python bindings for the Steamworks SDK, generated from your own copy of the SDK
|
|
5
|
+
Author: Schunche
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
License-File: NOTICE
|
|
9
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
10
|
+
Classifier: Programming Language :: C++
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
13
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
14
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
15
|
+
Classifier: Operating System :: MacOS
|
|
16
|
+
Classifier: Topic :: Games/Entertainment
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Project-URL: Homepage, https://github.com/Schunche/steamworks-py
|
|
19
|
+
Requires-Python: >=3.15
|
|
20
|
+
Provides-Extra: test
|
|
21
|
+
Requires-Dist: pytest; extra == "test"
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# steamworks-py
|
|
25
|
+
|
|
26
|
+
Python bindings for the [Steamworks SDK](https://partner.steamgames.com/doc/sdk),
|
|
27
|
+
generated from your own copy of the SDK.
|
|
28
|
+
|
|
29
|
+
> **Status: pre-alpha.** Core (`SteamAPI_*`, callbacks) and `ISteamUser` work; more interfaces coming.
|
|
30
|
+
|
|
31
|
+
## What it is
|
|
32
|
+
|
|
33
|
+
`steamworks-py` (PyPI: `steamworks-bindings`) turns the official Steamworks SDK into a compiled Python module.
|
|
34
|
+
The API mirrors the C++ API 1:1, so the Steamworks docs apply directly:
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import steamworks
|
|
38
|
+
|
|
39
|
+
steamworks.SteamAPI_Init()
|
|
40
|
+
print(steamworks.SteamUser().GetSteamID())
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The SDK is **not** bundled. You download it from Valve and point the installer at it.
|
|
44
|
+
|
|
45
|
+
## Planned install
|
|
46
|
+
|
|
47
|
+
Requirements: Python 3.15+, a C++ compiler, and the latest Steamworks SDK
|
|
48
|
+
(download it from https://partner.steamgames.com/downloads/list; a free Steamworks account is required).
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
pip install steamworks-bindings
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The installer looks for the SDK zip (or an extracted SDK folder) in the current directory
|
|
55
|
+
and `~/Downloads`, and uses the newest version it finds. To point it somewhere else,
|
|
56
|
+
set `STEAMWORKS_SDK` to the zip or folder:
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
STEAMWORKS_SDK=/path/to/steamworks_sdk_165.zip pip install steamworks-bindings
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The module is built at install time against your SDK headers. If no SDK is found,
|
|
63
|
+
the error tells you exactly where to get it and what to run next.
|
|
64
|
+
|
|
65
|
+
## Platforms
|
|
66
|
+
|
|
67
|
+
Desktop platforms first.
|
|
68
|
+
|
|
69
|
+
| Platform | Status |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| Linux x64 | tested |
|
|
72
|
+
| Windows (x64, x86) | untested; supported in principle |
|
|
73
|
+
| macOS (arm64, x64) | untested; supported in principle |
|
|
74
|
+
| Linux arm64 | untested; supported in principle |
|
|
75
|
+
|
|
76
|
+
Reports from these platforms are welcome (open an issue). Android later.
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
Apache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
|
|
81
|
+
|
|
82
|
+
Not affiliated with or endorsed by Valve Corporation. Steam and Steamworks are
|
|
83
|
+
trademarks of Valve Corporation.
|