pylibretro


Namepylibretro JSON
Version 0.2.2 PyPI version JSON
download
home_pageNone
SummaryWIP Python library that runs Libretro cores
upload_time2024-09-27 20:08:43
maintainerNone
docs_urlNone
authorJames Ravindran
requires_python>=3.10
licenseGPL-3.0-or-later
keywords libretro emulator retroarch
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pylibretro

[![](https://img.shields.io/pypi/v/pylibretro)](https://pypi.org/project/pylibretro)
[![](https://img.shields.io/pypi/status/pylibretro)](https://pypi.org/project/pylibretro)
[![](https://img.shields.io/pypi/pyversions/pylibretro)](https://pypi.org/project/pylibretro)
[![](https://img.shields.io/badge/platform-windows%20|%20linux-lightgrey)](https://pypi.org/project/pylibretro)
[![](https://img.shields.io/pypi/l/pylibretro)](https://pypi.org/project/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.

![](https://raw.githubusercontent.com/jamesravi/pylibretro/master/examples/2048example.gif)

## Installation
`pip install pylibretro`

(the only dependency is [Pillow](https://pypi.org/project/Pillow/) if you wish to install it manually)

## Usage
You can create the GIF shown above by using the [example file](examples/example.py) in this repository. However, here's a condensed, minimal usage example:

```python
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](https://github.com/jamesravi/pylibretro/blob/master/LICENSE.md).

Credits to the RetroArch team for the [libretro API](https://www.libretro.com/index.php/api/) and also the [2048 core](https://github.com/libretro/libretro-2048) included within this repository as an example. Their corresponding licenses are also included in the [license file](https://github.com/jamesravi/pylibretro/blob/master/LICENSE.md).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pylibretro",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "libretro, emulator, retroarch",
    "author": "James Ravindran",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/75/c8/3aa025c21a34946c07175116d92c26ea755f6621cbe45efcf287ec386c9e/pylibretro-0.2.2.tar.gz",
    "platform": null,
    "description": "# pylibretro\r\n\r\n[![](https://img.shields.io/pypi/v/pylibretro)](https://pypi.org/project/pylibretro)\r\n[![](https://img.shields.io/pypi/status/pylibretro)](https://pypi.org/project/pylibretro)\r\n[![](https://img.shields.io/pypi/pyversions/pylibretro)](https://pypi.org/project/pylibretro)\r\n[![](https://img.shields.io/badge/platform-windows%20|%20linux-lightgrey)](https://pypi.org/project/pylibretro)\r\n[![](https://img.shields.io/pypi/l/pylibretro)](https://pypi.org/project/pylibretro)\r\n\r\n\u26a0\ufe0f 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.\r\n\r\n![](https://raw.githubusercontent.com/jamesravi/pylibretro/master/examples/2048example.gif)\r\n\r\n## Installation\r\n`pip install pylibretro`\r\n\r\n(the only dependency is [Pillow](https://pypi.org/project/Pillow/) if you wish to install it manually)\r\n\r\n## Usage\r\nYou can create the GIF shown above by using the [example file](examples/example.py) in this repository. However, here's a condensed, minimal usage example:\r\n\r\n```python\r\nfrom pylibretro import Core, buttons\r\n\r\nlastframe = None\r\n\r\ndef on_frame(frame):\r\n    global lastframe\r\n    lastframe = frame\r\n\r\n# Load the core\r\nimport platform\r\nif platform.system() == \"Linux\":\r\n    core = Core(\"./2048_libretro.so\")\r\nelif platform.system() == \"Windows\":\r\n    core = Core(\"2048_libretro.dll\")\r\n\r\ncore.on_video_refresh = on_frame\r\ncore.init()\r\ncore.load_game(None)\r\n\r\n# Start a 2048 game (by pressing the START button for one frame)\r\ncore.joystick[buttons.START] = True\r\ncore.run()\r\ncore.joystick[buttons.START] = False\r\n\r\n# Run core for 10 frames\r\nfor i in range(10):\r\n    core.run()\r\n\r\n# Show the last screen output\r\nfrom PIL import Image\r\nlastframe = Image.fromarray(lastframe)\r\nlastframe.show()\r\n```\r\n\r\n## Licenses\r\npylibretro is licensed under [GPLv3 or later](https://github.com/jamesravi/pylibretro/blob/master/LICENSE.md).\r\n\r\nCredits to the RetroArch team for the [libretro API](https://www.libretro.com/index.php/api/) and also the [2048 core](https://github.com/libretro/libretro-2048) included within this repository as an example. Their corresponding licenses are also included in the [license file](https://github.com/jamesravi/pylibretro/blob/master/LICENSE.md).\r\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-or-later",
    "summary": "WIP Python library that runs Libretro cores",
    "version": "0.2.2",
    "project_urls": {
        "Repository": "https://github.com/jamesravi/pylibretro"
    },
    "split_keywords": [
        "libretro",
        " emulator",
        " retroarch"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b68a9342c368584ebe99813f79a1993494d7053e5a9c92d4099b431a85ab30c0",
                "md5": "09dc2d79c92ddccdca78d8737f39876c",
                "sha256": "e6cedbbd04a6311e9b0b29559c8b6f5da867d7e0457a6e70a23b749989a89988"
            },
            "downloads": -1,
            "filename": "pylibretro-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "09dc2d79c92ddccdca78d8737f39876c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 78403,
            "upload_time": "2024-09-27T20:08:42",
            "upload_time_iso_8601": "2024-09-27T20:08:42.091132Z",
            "url": "https://files.pythonhosted.org/packages/b6/8a/9342c368584ebe99813f79a1993494d7053e5a9c92d4099b431a85ab30c0/pylibretro-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "75c83aa025c21a34946c07175116d92c26ea755f6621cbe45efcf287ec386c9e",
                "md5": "93f1f1dc1b79777d67088b8b877bd633",
                "sha256": "b3263399af3e39741cd3824e4d955a7d36cd7f378519ed52cfc4ee81f29b726c"
            },
            "downloads": -1,
            "filename": "pylibretro-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "93f1f1dc1b79777d67088b8b877bd633",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 78460,
            "upload_time": "2024-09-27T20:08:43",
            "upload_time_iso_8601": "2024-09-27T20:08:43.195349Z",
            "url": "https://files.pythonhosted.org/packages/75/c8/3aa025c21a34946c07175116d92c26ea755f6621cbe45efcf287ec386c9e/pylibretro-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-27 20:08:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jamesravi",
    "github_project": "pylibretro",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pylibretro"
}
        
Elapsed time: 0.53869s