Compiling Steamworks-py

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 is involved. I am writing this to help future me, and anyone else get a working steamworks-py setup for their game.

This is to compile on windows 11

First you will need the proper terminal to compile on. To get this, copy the following into a terminal. What it does is downloads the Visual studio installer, and get the build tools installed for terminal. I pulled this from saikyun's github but as I don't trust anything to stay on the internet, here it is. To execute, paste and run. Accept the Visual Studio launch, and continue. It's huge, so it will take a while to download


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


Once you have this, copy the git repository of steamworks-py. Do this however you want, I am still partial to the zip download, as I do not plan on pushing it back to them.

Once you get that unpacked in whatever surrounding directory you want, download the steam sdk from steamworks. As of this writing, the sdk is located in the right sidebar near the bottom.

Unpack/unzip the sdk. Now enter into it and locate the steam folder within "sdk\public" inside the steamworks folder. Cut it and paste it inside steamworks-py at "Steamworks-Py-master\library\sdk".

Inside the steamworks folder again, navigate to "sdk\redistributable_bin\win64". Cut and paste both the steam_api64.dll and steam_api64.lib into "Steamworks-Py-master\library"

Open a terminal. In the dropdown beside the terminal tab, select "Developer Command Prompt for VS <year>". Once it opens, navigate to the library folder within Steamworks-Py-master.

Paste and run the following command:


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


Let it execute.

Once it runs, inside the library folder, there will be a file called "SteamworksPy64.dll". 


Now to make it into a pip installable library.


The following steps will make the folder structure match 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


To start, setup a new project structure like this:

SteamworksWrapper/
├── setup.py
├── pyproject.toml
├── MANIFEST.in
└── src/

Copy the SteamworksPy64.dll, steam_api64.dll, and steam_appid.txt into the steamworks folder. Then copy the entire steamworks folder (containing all the .py and .dll files) into src/.


Edit the setup.py script to the following:


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



With the terminal set to the environment you are building your game in (venv) navigate to SteamworksWrapper/


Run:

pip install -e .


It is now installed!


To call it, write the following:


from steamworks import STEAMWORKS


and everything will just work

Comments

Log in to add a comment.