Compiling Steamworks-py

Steamworks-Py Setup on Windows 11

Steamworks-py is the only library currently available to connect Python-made games into Steam for achievements, workshop items, etc. However, it is not installed using pip, and setup is involved. This guide is for future meβ€”and anyone elseβ€”who wants a working steamworks-py setup.

πŸ”§ Requirements: Windows 11 Compilation

1. Install Visual Studio Build Tools

You'll need the proper terminal environment to compile. Run the following in PowerShell to install the tools:

Invoke-RestMethod -Uri https://aka.ms/vs/17/release/vs_buildtools.exe -OutFile vs_buildtools.exe
Start-Process -FilePath vs_buildtools.exe -ArgumentList "--add", "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", "--add", "Microsoft.VisualStudio.Component.Windows10SDK.19041", "--norestart", "--passive", "--wait" -Wait -PassThru
Remove-Item vs_buildtools.exe

This will launch the Visual Studio installer and download required components. It takes time!

2. Get the steamworks-py Repository

Clone or download the repository: - Steamworks-Py GitHub - Or download as ZIP if you're not planning to contribute

3. Get the Steam SDK

4. Move Files Into Place

  • Extract the Steam SDK
  • Copy the steam folder from:

    sdk/public/
    

    into:

    Steamworks-Py-master/library/sdk/
    
  • Copy steam_api64.dll and steam_api64.lib from:

    sdk/redistributable_bin/win64/
    

    into:

    Steamworks-Py-master/library/
    

5. Compile the DLL

Open the Developer Command Prompt for VS (from terminal dropdown in VS Code) and navigate to:

Steamworks-Py-master/library/

Then run:

cl /D_USRDLL /D_WINDLL SteamworksPy.cpp steam_api64.lib /link /DLL /OUT:SteamworksPy64.dll

You should now see SteamworksPy64.dll in the library/ folder.


πŸ“¦ Turn It Into a Pip Installable Package

You'll create a package like this:

SteamworksWrapper/  
β”œβ”€β”€ setup.py  
β”œβ”€β”€ pyproject.toml  
β”œβ”€β”€ MANIFEST.in  
└── src/  
    └── steamworks/ 
        β”œβ”€β”€ __init__.py  
        β”œβ”€β”€ util.py  
        β”œβ”€β”€ enums.py  
        β”œβ”€β”€ structs.py  
        β”œβ”€β”€ SteamworksPy64.dll  
        β”œβ”€β”€ steam_api64.dll  
        └── steam_appid.txt                 

πŸ“ Folder Setup

Create the structure above. Then copy:

  • All .dll, .txt, and .py files into src/steamworks/

✍️ setup.py

from setuptools import setup, find_packages

setup(
    name="steamworks",
    version="0.1.0",
    packages=find_packages(where="src"),
    package_dir={"": "src"},
    include_package_data=True,
    package_data={"steamworks": ["*.dll", "*.txt"]},
)

πŸ“‹ pyproject.toml

[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

πŸ“¦ MANIFEST.in

recursive-include src/steamworks *.dll

πŸ“₯ Install

With your game environment active (venv), navigate to SteamworksWrapper/ and run:

pip install -e .

βœ… Usage

from steamworks import STEAMWORKS

Everything should now "just work".

Comments

Log in to add a comment.