SteamworksPy

This is the documentation page for SteamworksPy, a Python module for Steamworks. You can find the GitHub repository here. Additionally, you can acquire the pre-built versions of the Linux SO files and Windows DLL files here.

Starting Out

You will need the following things to begin working with the module:

  • The Steamworks SDK
  • A Steamworks account
  • A valid AppID for more advanced functions (set achievements, set stats, etc.)
    • Alternatively you can use the SpaceWars AppID of 480 for testing the basics

Once you have those basics, you'll probably need these too:

  • Be logged into your Steam client (or suffer crashes)
  • A library with OpenGL or D3D for Steam overlay

Getting Started

First you will need to download the repository and unpack it into a project folder. After that you will need to download and unpack the Steamworks SDK and copy the following into your unpacked repo folder:

  • Steam header (steam) folder from the /sdk/public folder
  • Steam API lib file from the /sdk/redistributable_bin folder

Depending on your operating system, you will need to acquire different files from /sdk/redistributable_bin and follow a different set of instructions. We will address each below.


Linux

Look in either the linux32 or linux64 folder, depending on your installation, and copy the libsteam_api.so over to your project folder.

At this point you can either run the makefile that is included in the repository or you can just run the following in terminal:


g++ -std=c++11 -o SteamworksPy.so -shared -fPIC SteamworksPy.cpp -l steam_api -L.
							

This should result in the SteamworksPy.so file you need to use with the module.


Windows

Look in either the base of the /sdk/redistributable_bin or the win64 folder, depending on your installation, and copy the steam_api.dll and steam_api.lib or the steam_api64.dll and steam_api64.lib files to your project folder.

If you have Native Tools Command Prompt installed for Visual Studio (or compiling tools for console), then you can use these handy commands to compile your DLL file. For 64-bit use:


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

If you are using 32-bit then use:


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

Alternatively you can create a new project in Visual Studio to create the DLL file using these steps:

  • Create a new DLL project in Visual Studio.
  • New > Project.
  • Templates > Visual C++ > Win32 > Win32 Project.
  • Follow the wizard and pick the DLL Application Type.
  • Add SteamworksPy.cpp to Source Files and steam_api.h from /steam/ folder to Header Files.
  • Go to Project > Properties in the toolbar.
  • Under C/C++ > Precompiled Headers, turn off Precompiled Header option.
  • Under Linker > Input, add steam_api.lib or steam_api64.lib to Additional Dependenices.
  • You may also want to add _CRT_SECURE_NO_WARNINGS under C/C++ > Preprocessor > Preprocessor Definitions.
  • Clean and build.

This will proce the SteamworksPy.dll somewhere deep in your Visual Studio output folders.


MacOS

Follow these steps to create your SteamworksPy.dylib file:

  • Create a new library project in Xcode.
  • New > Project > Library
  • When configuring options, set Framework to "None (Plain C/C++ Library)" and Type to "Dynamic".
  • Move libsteam_api.dylib to the project directory created by Xcode.
  • In the Build Phases tab:
    • Add SteamworksPy.cpp to Compile Sources.
    • Add steam_api.h from /steam/ folder to the public section of Headers.
    • Add libsteam_api.dylib to Link Binary with Libraries.
  • Build.
  • Find the resultant library and rename it SteamworksPy.dylib.

Add It

Copy the steamworks.py file and the newly compiled SteamworksPy.dll or SteamworksPy.so or SteamworksPy.dylib file to your project folder. You may also have to copy the libsteam_api.so, steam_api.so, or libsteam_api.dylib file as well.

You will also need to copy the Steamworks module folder from the repo into your project. This contains the full Python module for Steamworks.

Add the following code to your main file or whatever file you plan on calling Steam from:


from steamworks import STEAMWORKS

# Declare the steamworks variable and create a new instance of the Steamworks class
steamworks = STEAMWORKS()

# Initialize Steam
steamworks.initialize()
							

At this point you can start adding in additional functions as you need them.

In Closing

And those are the basics to using the SteamworksPy module. A list of available functions, their responses, and what they do will be available in the repository's wiki page soon. In addition, you should be able to read the Steamworks API documentation to see what all is available and cross-reference with the steamworks.py!