WIP Python library that runs Libretro cores
Project description
pylibretro
⚠️ This library is currently (and probably will remain) 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 (such as the PCSX ReARMed core) segfault etc. Use at your peril.
Installation
pip install pylibretro
(the only dependency is Pillow if you wish to install it manually)
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
lastframe = None
def on_frame(frame):
global lastframe
lastframe = frame
# Load the core
import platform
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
from PIL import Image
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pylibretro-0.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6cedbbd04a6311e9b0b29559c8b6f5da867d7e0457a6e70a23b749989a89988 |
|
MD5 | 09dc2d79c92ddccdca78d8737f39876c |
|
BLAKE2b-256 | b68a9342c368584ebe99813f79a1993494d7053e5a9c92d4099b431a85ab30c0 |