Skip to main content

Endless Sky bindings for Python

Play with the Endless Sky C++ classes from Python or interact with the game as it runs.

pip install endless-sky-bindings

This library does not include the Endless Sky data, so to load that data you'll need to find the installed copy on your system or clone the Endless Sky repo to get it. The code samples below assume a checkout of endless-sky at ~/endless-sky.

Library

Once you get a handle on the endless_sky.bindings module (bound to 'es' variable here), C++ classes are exposed to Python pretty directly; for documentation, see the header files in Endless Sky.

>>> from endless_sky.loader import load_data
>>> es = load_data(resources="/Users/tomb/endless-sky")
>>> ships = es.GameData.Ships() # these objects correspond to 
>>> ships.<tab><tab>
ships.Get(   ships.Has(   ships.size(
>>> shuttle = ships.Get("Shuttle")
<endless_sky.bindings.Ship object at 0x1087391b0>
>>> ship = es.Ship(shuttle)  # make a copy to avoid modifying the template
>>> ship.<tab><tab>
ship.Acceleration(          ship.Hull(                  ship.Mass(
ship.AddCrew(               ship.HyperdriveFuel(        ship.MaxReverseVelocity(
ship.Attributes(            ship.IdleHeat(              ship.MaxVelocity(
ship.BaseAttributes(        ship.IsBoarding(            ship.MaximumHeat(
... and many more, see header files for documentation
>>> ship.Attributes().Attributes()
<endless_sky.bindings.Dictionary object at 0x1087392f0>
>>> dict(ship.Attributes().Attributes())
{'bunks': 6.0, 'cargo space': 20.0, 'drag': 1.7000000000000002, ...}
>>> ship.SetName("Summer Breeze")
>>> x.Name()
'Summer Breeze'

Warning: endless_sky.bindings contains non-resetable singletons like GameData, so once you load some data (directly with GameData.BeginLoad(), with a load_data, or indirectly with a parser function) you can't unload that data without exiting Python.

Command line use

Loading data files:

% echo -e 'ship Rocket\n\tattributes\n\t\tdrag 10' > myData.txt
$ python -m endless_sky load --empty-resources myData.txt  # only prints ships atm
'Rocket': {'drag': 10.0, 'gun ports': 0.0, 'turret mounts': 0.0},
$ python -m endless_sky load -- --resources ~/endless-sky
{'Aerie': {'bunks': 28.0,
           'capture attack': 1.8000000000000003,
           'capture defense': 2.4000000000000004,
           'cargo space': 50.0,
...
$ # In order to parse a file with vanilla outfits defined, use --resources
$ python -m endless_sky load --resources ~/endless-sky myData.txt
{'Aerie': {'bunks': 28.0,
...
<'Rocket' is somewhere in here>
...

Runing the game and a Python interpreter at the same time:

$ python -m endless_sky run --resources ~/endless-sky --default-config

Building from source

git clone --recursive git@github.com:thomasballinger/endless-sky-bindings-python.git
cd endless-sky-bindings-python

Mac

brew install libmad libpng jpeg-turbo SDL2 openal-soft

Linux

sudo apt-get install libsdl2-dev libpng-dev libjpeg-turbo8-dev libopenal-dev libmad0-dev libglew-dev libgl1-mesa-dev libegl1-mesa-dev libgles2-mesa-dev uuid-dev

Windows

Invoke-WebRequest https://endless-sky.github.io/win64-dev.zip -OutFile win64-dev.zip
Expand-Archive win64-dev.zip -DestinationPath . -Force
Remove-Item win64-dev.zip

cd endless_sky/endless-sky
patch -p1 < ../../patch.diff
cd ../..
pip install 

Dev notes

Updating the Endless Sky patch

These bindings use a patched version of Endless Sky to patch out threads and make a few other changes.

To update the patch:

  • make changes in the submodule at endless_sky/endless-sky
  • with that directory as the working directory, run git diff > ../../patch.diff

This is likely to be necessary after updating the version of Endless Sky used.

This patch is intended to be the minimum to make Python bindings work; if this repo is combined with Emscripten-compiled JavaScript bindings at a later date it will need to be expanded.

Release files for endless-sky-bindings 0.0.14

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for endless-sky-bindings 0.0.14
File Size Uploaded
endless-sky-bindings-0.0.14.tar.gz 686.1 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for endless-sky-bindings 0.0.14
File
endless_sky_bindings-0.0.14-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
endless_sky_bindings-0.0.14-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
endless_sky_bindings-0.0.14-cp39-cp39-macosx_10_15_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.15+ x86-64 Details
endless_sky_bindings-0.0.14-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
endless_sky_bindings-0.0.14-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details
endless_sky_bindings-0.0.14-cp38-cp38-macosx_10_15_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.15+ x86-64 Details

Total release size: 21.9 MB

Release files / endless-sky-bindings-0.0.14.tar.gz

Download URL endless-sky-bindings-0.0.14.tar.gz
Size 686.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ab79933c15a4f0a2611a1b39ba2f1b9dc4e29cceb6d07874cdcfe0abb26d9e0c
BLAKE2b-256 checksum
How to use checksums
e7767c886eb5ec95f762138abf8dcbdee3427df00efab93e795adbfa9f35abcb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / endless_sky_bindings-0.0.14-cp39-cp39-win_amd64.whl

Download URL endless_sky_bindings-0.0.14-cp39-cp39-win_amd64.whl
Size 4.1 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
15745bb3e4e5b2c2995dd0e3736dd0d7d9c36a5b0bc8018a7ed509fd1fb625c1
BLAKE2b-256 checksum
How to use checksums
2310f39479b1a48747be08233d269081737b4bc5f8b4e801919f56f37f7db2dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / endless_sky_bindings-0.0.14-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL endless_sky_bindings-0.0.14-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.7 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
ac7398d1756f0b8ae7f1eb2de93e2b0154b90f0483bcfcf8055f8a5adf7af159
BLAKE2b-256 checksum
How to use checksums
26ba93ae848d601cb4ab5ca1b9f258bc2d039898a244b64944466335c728afbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / endless_sky_bindings-0.0.14-cp39-cp39-macosx_10_15_x86_64.whl

Download URL endless_sky_bindings-0.0.14-cp39-cp39-macosx_10_15_x86_64.whl
Size 2.8 MB
Tags CPython 3.9 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
7f28c843f7f8878691b30eee86c89a658ad02ba02877e29820099954e71f0542
BLAKE2b-256 checksum
How to use checksums
5abd2de12d5be6e6dcd497d565bdacbf35b8b7293638ba9150b342fe99540f7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / endless_sky_bindings-0.0.14-cp38-cp38-win_amd64.whl

Download URL endless_sky_bindings-0.0.14-cp38-cp38-win_amd64.whl
Size 4.1 MB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
3c82f9b7f790fd76a6fab6b2c62ebedea6fa829e95d58213576c2971d90e6465
BLAKE2b-256 checksum
How to use checksums
d885b70ad5ca5285f60b4bb5806fa03583e2d5df4e2dbb9f050ebb88d45f3a62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / endless_sky_bindings-0.0.14-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL endless_sky_bindings-0.0.14-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.7 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
f7d3e4f39798644a1e6267e76e35ae0bf9981392a3b79a1cacbf415d21ce4a98
BLAKE2b-256 checksum
How to use checksums
fcca3b808611c26db49394b04d3423cc14db4e4d80557f5313ae76745df443f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / endless_sky_bindings-0.0.14-cp38-cp38-macosx_10_15_x86_64.whl

Download URL endless_sky_bindings-0.0.14-cp38-cp38-macosx_10_15_x86_64.whl
Size 2.8 MB
Tags CPython 3.8 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
49aadbe781c01c09c503ee6f134d73f58b2b410d104c64d7f2264dfe0fbd3eb1
BLAKE2b-256 checksum
How to use checksums
635eb80c6eb9b998560510bad4e94c133919a6f7c889e320b636165e5857bb15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release history Release notifications | RSS feed

This release

0.0.14 This release

7 release files

0.0.13

7 release files

0.0.12

7 release files

0.0.11

7 release files

0.0.10

7 release files

0.0.8

5 release files

0.0.7

5 release files

0.0.6

5 release files

0.0.5

5 release files

0.0.4

3 release files

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page