Steamworks SWIG Python Wrapper
Experimental Python bindings for the Steamworks SDK using SWIG over a generated C ABI. This project currently targets SDK v1.65 and may require changes to build against a different version.
The wrapper is generated from:
sdk/public/steam/steam_api.json
sdk/public/steam/steam_api_flat.h
See PYTHON.md for Python API usage and examples. The project also includes experimental Go and Lua wrappers; see GO.md for Go binding generation and LUA.md for Lua SWIG build instructions.
Requirements
- Linux, macOS, or Windows
- Python 3.9+
swig- A C++17 compiler
- Python development headers
- Steam running and logged in
steam_appid.txtin the project root for local development
SDK Layout
The Steamworks SDK is not included in this repository or its source distribution. Obtain an authorized copy directly from Valve through the Steamworks downloads page. This project expects that local SDK to be available at:
sdk/
For this repo, sdk may be a symlink to a versioned SDK directory such as
sdk_v165.
Alternatively, set STEAMWORKS_SDK_DIR to build against a specific installed
SDK without changing the symlink:
STEAMWORKS_SDK_DIR=/path/to/steamworks/sdk_158a pip install .
The generator validates each JSON-described interface accessor and method
against that SDK version's actual steam_api_flat.h. This handles SDK releases
whose steam_api.json contains entries that are absent from their shipped
headers. Functions unavailable in the selected SDK are omitted from that build.
Builds are currently verified against Steamworks SDK 1.65.
Do not commit, vendor, or republish the SDK headers, API JSON, examples, tools, or other SDK source files with this project.
Install
From the project root:
pip install .
The install step regenerates the C ABI helper layer from Valve's
steam_api.json, runs SWIG, builds the Python extension, and bundles the
platform-specific Steamworks runtime library into the installed package.
Source archives contain only SteamworksSwig project files. Consequently, a
source archive cannot be built directly by pip until the developer has
unpacked it and supplied their separately obtained SDK at sdk/.
Release artifacts should be platform-specific binary wheels. Each wheel
contains only the Steamworks runtime for its target platform from
redistributable_bin; it must not contain SDK headers, API JSON, examples, or
other Valve SDK source files.
Build release artifacts with:
python3 tools/build_distributions.py --sdk-dir /path/to/steamworks/sdk --clean
This runs the two required builds separately:
STEAMWORKS_SDK_DIR=/path/to/steamworks/sdk python3 -m build --sdist
STEAMWORKS_SDK_DIR=/path/to/steamworks/sdk python3 -m build --wheel
Do not use bare python3 -m build for this project. Its default workflow first
creates the intentionally SDK-free source archive and then attempts to compile
a wheel from that isolated archive. Such a wheel build cannot succeed unless
the external SDK location is explicitly available inside the second build.
Generation Pipeline
Steamworks SDK metadata
sdk/public/steam/steam_api.json
sdk/public/steam/steam_api_flat.h
read by tools/generate_model.py
|
v
shared normalized API model
generated/steamworks_c_api_model.json
written by tools/generate_model.py
|
v
C ABI + helper shim
generated/steamworks_c_api.h
generated/steamworks_c_api.cpp
generated/steamworks_helpers.h
generated/steamworks_helpers.cpp
generated/steamworks.i
written by tools/generate_core.py
|
v
Python / Go / Lua / other bindings
Python: tools/generate_python.py, then setup.py runs SWIG/build_ext
Go: tools/build_go_swig.py orchestrates SWIG and tools/generate_go.py
Lua: tools/build_lua_swig.py orchestrates SWIG and tools/generate_lua.py
The C ABI is the primary generated product. Language bindings wrap the same
SWS_* surface so lifecycle fixes, helper functions, callback IDs, and type
rules are shared.
tools/generate_model.py reads the SDK and is the main metadata/classification
step. It pulls in curated helper metadata from tools/helper_specs.json
through tools/steamworks_helpers.py, callback metadata from
tools/steamworks_callbacks.py through tools/generate_callbacks.py, and
promoted output helpers from tools/generate_output_helpers.py. It records the
generated wrappers, output-helper implementation metadata, SDK feature flags,
supported C ABI methods, and skipped methods in the shared model.
tools/generate_core.py then renders the C++ helper shim, C ABI files, and
SWIG interface from the generated model without rereading the SDK metadata.
For Python package builds, setup.py runs tools/generate_model.py,
tools/generate_core.py, tools/generate_python.py, and SWIG automatically
before compiling the steamworks._steamworks extension. API coverage docs are
generated separately with tools/generate_api_docs.py.
Shared API Model
tools/generate_model.py writes a shared model file:
generated/steamworks_c_api_model.json
Each entry should include enough information for language backends and docs:
{
"interface": "Apps",
"method": "IsSubscribed",
"raw_c_name": "SWS_SteamAPI_ISteamApps_BIsSubscribed",
"friendly_name": "IsSubscribed",
"return_type": "bool",
"params": [],
"callback_safe": true,
"language_support": "scalar_string"
}
The model now records skipped methods and reasons, such as pointer output buffers, unsupported structs, callback function pointers, interface pointers, or owned result lifetimes.
Linux wheels for PyPI
PyPI does not accept generic linux_x86_64 wheels. Build repaired manylinux
wheels using Docker or Podman:
tools/build_manylinux_wheels.sh --sdk-dir sdk
By default this uses quay.io/pypa/manylinux2014_x86_64 and builds CPython
3.10-3.15 wheels into wheelhouse/. Limit the matrix when required:
tools/build_manylinux_wheels.sh \
--sdk-dir sdk_158a \
--python-tags "cp311-cp311 cp312-cp312"
Use Podman with --engine podman. Validate and upload the repaired wheels:
python3 -m twine check wheelhouse/*.whl
python3 -m twine upload wheelhouse/*.whl
Windows wheels for PyPI
Run the PowerShell build script on 64-bit Windows with Visual Studio Build Tools, SWIG, and the Python Launcher installed for each version of Python that is required:
winget install --id Python.Python.3.10 -e
To build the wheels for windows:
.\tools\build_windows_wheels.ps1 -SdkDir C:\path\to\steamworks\sdk
It builds CPython 3.10-3.15 win_amd64 wheels into wheelhouse. Build a smaller
matrix with:
.\tools\build_windows_wheels.ps1 `
-SdkDir C:\path\to\steamworks\sdk `
-PythonVersions 3.11,3.12
It validates each wheel with Twine and checks that the resulting
filename has a win_amd64 platform tag. Upload with:
py -3.12 -m twine upload wheelhouse\*.whl
Licensing
Original SteamworksSwig code is licensed under BSD-3-Clause. Valve's Steamworks runtime libraries are excluded from that grant and remain governed by Valve's Steamworks terms. See THIRD_PARTY_NOTICES.md.
Other Language Targets
Although this project currently generates Python and experimental Go bindings, the generated C ABI is intended to be the common foundation for other language targets such as Lua, Ruby, Zig, Rust FFI, C#, Java, or JavaScript.
Supporting another target requires a separate language-specific build and package layer. Exception mapping, callback/event delivery, native object ownership, string and buffer typemaps, and runtime-library loading must be reviewed for that language. The manual-versus-automatic callback dispatch restriction must also remain enforced.
The internal C++ helper layer remains an implementation detail for Steamworks
quirks, callback decoding, and APIs that need explicit adapters. Language
bindings should target generated/steamworks_c_api.h, not the helper layer.
The same Steamworks SDK distribution rules apply to every target language:
obtain the SDK separately from Valve, do not redistribute SDK headers, API JSON,
examples, or tools, and distribute only the permitted platform runtime files
from redistributable_bin with generated or compiled wrapper outputs.
At runtime it links against the Steamworks redistributable for the current platform:
Linux x86_64: sdk/redistributable_bin/linux64/libsteam_api.so
Linux arm64: sdk/redistributable_bin/linuxarm64/libsteam_api.so
macOS: sdk/redistributable_bin/osx/libsteam_api.dylib
Windows x64: sdk/redistributable_bin/win64/steam_api64.dll
Windows x86: sdk/redistributable_bin/steam_api.dll
Runtime Shutdown
Applications should still call the binding shutdown function when they are done
with Steamworks. The shutdown helpers clear wrapper-owned callback/helper state
and then call Valve's SteamAPI_Shutdown() / SteamGameServer_Shutdown().
During Linux testing with Steamworks SDK 1.65, a minimal C++ program using only
Valve's SDK reproduced an intermittent segfault inside the Steam client during
SteamAPI_Shutdown() after an async lobby query. The repro lives in
shutdown/ and is intended for reporting/debugging the upstream issue.
Skipping shutdown is not treated as a supported workaround for this project: it can leave Steam client internals and networking state uncleared. If you hit this crash, keep calling the shutdown function in normal application code and use the standalone repro when reporting or isolating the Steam client behavior.
Python Usage
See PYTHON.md for the Python grouped API, smoke tests, callback usage, lobby helpers, and networking examples.
C ABI Layer
The generator emits generated/steamworks_c_api.h,
generated/steamworks_c_api.cpp, and generated/steamworks_c_api_model.json
as the primary language-neutral ABI foundation. Python and Go both bind through
this layer. The public header avoids Steam C++ types and STL containers;
generated functions use fixed-width C types, bool, const char *,
SWS_String for owned string results, SWS_StringList for owned string-list
results, and SWS_Bytes / SWS_BytesList for binary payload helpers.
Automatically generated C ABI functions are named after Valve's unique flat API
symbols with an SWS_ prefix, for example
SWS_SteamAPI_ISteamApps_BIsSubscribed(). Curated global helpers keep their
helper names with the same prefix, for example SWS_Steam_Init().
This layer currently covers scalar/string-safe JSON methods plus core init, game-server, lobby, manual-dispatch, callback cleanup, byte-buffer helpers, string/vector helpers, and selected async helper APIs. Pointer output buffers, callback function pointers, C++ reference types, interface pointers, and unsupported SDK structs still need explicit C-safe adapters.
Helper Specs
A helper is project-owned adapter code around Valve SDK calls, used when the raw SDK shape needs lifecycle handling, ownership handling, output conversion, or callback state to be usable from language bindings.
Most C ABI functions are generated directly from Valve's flat API metadata. Helpers are the exception: they are project-defined adapters for APIs that need more intent than the SDK headers provide. Examples include lifecycle entry points, lobby conveniences, callback/manual-dispatch glue, byte buffers, owned strings, owned string lists, and APIs where the native SDK expects caller-owned output memory.
These helpers are listed in tools/helper_specs.json and loaded by
tools/steamworks_helpers.py. Keeping the list as data makes the curated API
surface easier to review while still letting tools/generate_model.py record
the matching model entries and tools/generate_core.py emit the C declarations
and wrappers. The C++ helper
implementations remain in the templates where behavior is required.
Some helper candidates can be discovered automatically from common SDK signature patterns, such as string output buffers. Those generated candidates still need promotion into the helper spec before they become part of the stable binding surface, because the headers do not always say whether a buffer is text, binary data, an array, or part of a multi-call ownership protocol.
API Coverage
Coverage is measured against the interface methods listed in
sdk/public/steam/steam_api.json. The generated model records supported
methods plus skipped methods and reasons, such as pointer output buffers,
interface pointers, callback function pointers, and unsupported SDK structs.
Run this after changing the SDK or generator:
python3 tools/generate_api_docs.py
See docs/API_COVERAGE.md for current counts by interface, C ABI function source, skipped reason, and representative skipped methods.
Regenerating
The generator can be run directly:
python3 tools/generate_model.py --output generated/steamworks_c_api_model.json
python3 tools/generate_core.py --model generated/steamworks_c_api_model.json --output-dir generated
The generated wrapper currently covers methods with SWIG-friendly value and
const char * parameters. Pointer/out/ref-heavy APIs, callbacks, and structured
result handling are intentionally skipped until explicit typemaps are added.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file steamworks_swig-0.1.2-cp315-cp315-win_amd64.whl.
File metadata
- Download URL: steamworks_swig-0.1.2-cp315-cp315-win_amd64.whl
- Upload date:
- Size: 460.7 kB
- Tags: CPython 3.15, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bfbe70734a355e423882917ec27576a358b5ea7a39cee8a81404f3182bdc4f3
|
|
| MD5 |
90ff9a6c68e585be026ed14b2538116d
|
|
| BLAKE2b-256 |
4e3bcee53c874a63ace571b4b069cf4aebbabf909653c2eea3ace491283e4b84
|
File details
Details for the file steamworks_swig-0.1.2-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: steamworks_swig-0.1.2-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.15, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7d819e2cc4c5507bf2c123ccac32bdfb06925a5bba954e280b5da583303a33a
|
|
| MD5 |
7be7ef09ff6f7405ac01d3738e0bba74
|
|
| BLAKE2b-256 |
f12e356b3bac1e62175f4dbc90d33fd3ba2a1988faf18585b1e48a6a97d8c864
|
File details
Details for the file steamworks_swig-0.1.2-cp314-cp314-win_amd64.whl.
File metadata
- Download URL: steamworks_swig-0.1.2-cp314-cp314-win_amd64.whl
- Upload date:
- Size: 460.7 kB
- Tags: CPython 3.14, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
570528e975eebe10cb73734b92bf4648956a80ede0236e078a363cffd126ccea
|
|
| MD5 |
095c7592b1707308c1d47d5406f8f60d
|
|
| BLAKE2b-256 |
3e27d8f9756a62e68c974169bbd5ef0c05ca0dc2430aef159b0a904763380f34
|
File details
Details for the file steamworks_swig-0.1.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: steamworks_swig-0.1.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.14, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f90947a91c64b08c108f0607df28219318f3a16d86ff76e15ab63bec5ae4dfa
|
|
| MD5 |
1a6ee7aa49238972e8208cf1e6a9fb61
|
|
| BLAKE2b-256 |
f2ed7234c181b4f05b1728fb1cf9e1b5ba427efcd06ff5a29b16ca4bda6cc123
|
File details
Details for the file steamworks_swig-0.1.2-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: steamworks_swig-0.1.2-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 446.6 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78a96b7833f1bfb7cd609b870cd1d0f9f5464f7a1f0b7dd5784377d0ac11cf91
|
|
| MD5 |
4da7dbc1d442d92ba46c7b110a4f77f3
|
|
| BLAKE2b-256 |
1f8f9aeaa40fd2ade885321932743ac91ef767c9c29944f4e0cfc96acc9127a2
|
File details
Details for the file steamworks_swig-0.1.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: steamworks_swig-0.1.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
440d0b0bd29e719580f8cae155dc1f662507d9d9a20f08417f5118fc2068f466
|
|
| MD5 |
d5fb6e5707298c188685dd41f0f29383
|
|
| BLAKE2b-256 |
daeb26856725c1f115beb597ba7646b2ef28a9da28f97941001812a979287cd5
|
File details
Details for the file steamworks_swig-0.1.2-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: steamworks_swig-0.1.2-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 446.7 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9665dab635130c179118a284b98595f93735c669ecffbefb6bbbe7fa72fcc7e
|
|
| MD5 |
d9868f8f1361d8e128a1776506883990
|
|
| BLAKE2b-256 |
7ef33e2b39dfdd6a7f63b81c08b24bc2fe1edf326571304181c0c786aca0a472
|
File details
Details for the file steamworks_swig-0.1.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: steamworks_swig-0.1.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74b499ce3d7e4af6a2f1c416ff4d4941ee4e25d4f5d7a995ede6792d8b25cbcd
|
|
| MD5 |
2d9dc80b543bcf1ea82e5b6583e0ba63
|
|
| BLAKE2b-256 |
9e51fb08d38ef59bbd190bdf914040aca31dabf128c7d88fb440f9a7609ff30c
|
File details
Details for the file steamworks_swig-0.1.2-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: steamworks_swig-0.1.2-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 446.3 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b91bd020deaef4e4594780405c9b0e75c2a606491bc924728fd7e1acac446ef0
|
|
| MD5 |
72d3f7f8b61821365ac67ba09981aacf
|
|
| BLAKE2b-256 |
76f8a3dc5bbf3c0594c37afa7e72a41489571e3bf944d557b6eeae6922a631e5
|
File details
Details for the file steamworks_swig-0.1.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: steamworks_swig-0.1.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2937e7adacde66e7e6c66f183897dfe369925620677d397c8c1dc74f971f9c4
|
|
| MD5 |
fd2672f70c78ad7dd9e8e7a997e3611d
|
|
| BLAKE2b-256 |
e8dfa7fa4f4780d2d102142ff28182ba34d9d494cd8a0d8fc580ce8c342a1073
|
File details
Details for the file steamworks_swig-0.1.2-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: steamworks_swig-0.1.2-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 446.3 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5328e8fd526087c3d97643d5dc2a0f99b6eebf2635863d89d660ae24e8ab974
|
|
| MD5 |
4ca61193c159fa062127ce7d23154e86
|
|
| BLAKE2b-256 |
e30ef5bb48748534ac493b9f0fbef12394ca32eb6440f996958c59bab8fe9e64
|
File details
Details for the file steamworks_swig-0.1.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: steamworks_swig-0.1.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4edad8f76a5c8fdd77781588f90996745fd09e51120c02237915f3895a9ffe45
|
|
| MD5 |
fa93523d850999e6b53c6aaa3e369677
|
|
| BLAKE2b-256 |
a3a416d824c25e795bbbe5b08dac27755d4fc7430b5d50c09f68bf42073edd0c
|