Skip to main content

pylibretro

⚠️ This library is currently in a severe pre-alpha state. At the moment it is however able to load the 2048 core, press buttons and get screen output (as you can see below!). However, many callbacks and functions aren't handled, other cores may segfault etc. Use at your peril.

Installation

pip install pylibretro

You can install the dependencies for the examples in examples or the snippet below by running pip install pylibretro[examples]

Usage

You can create the GIF shown above by using the example file in this repository. However, here's a condensed, minimal usage example:

from pylibretro import Core, buttons
import platform

from PIL import Image

lastframe = None

def on_frame(frame):
    global lastframe
    lastframe = frame

# Load the core
if platform.system() == "Linux":
    core = Core("./2048_libretro.so")
elif platform.system() == "Windows":
    core = Core("2048_libretro.dll")

core.on_video_refresh = on_frame
core.init()
core.load_game(None)

# Start a 2048 game (by pressing the START button for one frame)
core.joystick[buttons.START] = True
core.run()
core.joystick[buttons.START] = False

# Run core for 10 frames
for i in range(10):
    core.run()

# Show the last screen output
lastframe = Image.fromarray(lastframe)
lastframe.show()

Licenses

pylibretro is licensed under GPLv3 or later.

Credits to the RetroArch team for the libretro API and also the 2048 core included within this repository as an example. Their corresponding licenses are also included in the license file.

Metadata

Release files for pylibretro 0.4.1

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

Source distribution (sdist)

Source distribution for pylibretro 0.4.1
File Size Uploaded
pylibretro-0.4.1.tar.gz 79.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pylibretro 0.4.1
File Interpreter ABI Platform
pylibretro-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 157.9 kB

Release files / pylibretro-0.4.1.tar.gz

Download URL pylibretro-0.4.1.tar.gz
Size 79.1 kB
Tags Source
SHA-256 checksum
How to use checksums
18fe4ba8680bc00227a9c669ec23dde45945b26aa462f8debc3c29bfa9faf83a
BLAKE2b-256 checksum
How to use checksums
46973f0ddc352006bcb0fd8d916c4336a919b566fbcb631c9cb1ea2155634fc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.7

Release files / pylibretro-0.4.1-py3-none-any.whl

Download URL pylibretro-0.4.1-py3-none-any.whl
Size 78.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
865663237a92220d388ad82c08214ca0cb30f957c50019722ceb9d8ccd778749
BLAKE2b-256 checksum
How to use checksums
b1702d27472ac0a0a8d44c9223e1eac74c7020b769e7e42d557521ebef46d496
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.7

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

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