Skip to main content

WIP Python library that runs Libretro cores

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylibretro-0.4.1.tar.gz (79.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pylibretro-0.4.1-py3-none-any.whl (78.8 kB view details)

Uploaded Python 3

File details

Details for the file pylibretro-0.4.1.tar.gz.

File metadata

  • Download URL: pylibretro-0.4.1.tar.gz
  • Upload date:
  • Size: 79.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for pylibretro-0.4.1.tar.gz
Algorithm Hash digest
SHA256 18fe4ba8680bc00227a9c669ec23dde45945b26aa462f8debc3c29bfa9faf83a
MD5 a9ac73dce3748941bad44d61c357481e
BLAKE2b-256 46973f0ddc352006bcb0fd8d916c4336a919b566fbcb631c9cb1ea2155634fc6

See more details on using hashes here.

File details

Details for the file pylibretro-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: pylibretro-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 78.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for pylibretro-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 865663237a92220d388ad82c08214ca0cb30f957c50019722ceb9d8ccd778749
MD5 4e502c8b68e60850ed60484d3f488db4
BLAKE2b-256 b1702d27472ac0a0a8d44c9223e1eac74c7020b769e7e42d557521ebef46d496

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page