pylibretro


Namepylibretro JSON
Version 0.4.0 PyPI version JSON
download
home_pageNone
SummaryWIP Python library that runs Libretro cores
upload_time2024-09-30 21:12:38
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 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.

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

## 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](examples/producegif.py) in this repository. However, here's a condensed, minimal usage example:

```python
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](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/2d/e8/8ad41dd278616315cf138b88628000f4db372ed5da5f12fad628421895ea/pylibretro-0.4.0.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 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.\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\nYou can install the dependencies for the examples in `examples` or the snippet below by running `pip install pylibretro[examples]`\r\n\r\n## Usage\r\nYou can create the GIF shown above by using the [example file](examples/producegif.py) in this repository. However, here's a condensed, minimal usage example:\r\n\r\n```python\r\nfrom pylibretro import Core, buttons\r\nimport platform\r\n\r\nfrom PIL import Image\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\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\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.4.0",
    "project_urls": {
        "Repository": "https://github.com/jamesravi/pylibretro"
    },
    "split_keywords": [
        "libretro",
        " emulator",
        " retroarch"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "257a5906e2bc701d7b8d0cb7d93f3850de4b437aaee4fa1cc3f18d5e1ff34418",
                "md5": "7cc3b53be00b440fefb0aef3b1443266",
                "sha256": "9ca3268fc9ef39e9823c32da3e44f92f2f5cc69c2e097ec9e775522dd26fb2c0"
            },
            "downloads": -1,
            "filename": "pylibretro-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7cc3b53be00b440fefb0aef3b1443266",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 78739,
            "upload_time": "2024-09-30T21:12:36",
            "upload_time_iso_8601": "2024-09-30T21:12:36.474391Z",
            "url": "https://files.pythonhosted.org/packages/25/7a/5906e2bc701d7b8d0cb7d93f3850de4b437aaee4fa1cc3f18d5e1ff34418/pylibretro-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2de88ad41dd278616315cf138b88628000f4db372ed5da5f12fad628421895ea",
                "md5": "a1ca125b112b0b50c6892fe013215da1",
                "sha256": "6484ee1e9bff0be9c13c5a6cf31ddc0ae2fcfc90f8563dd1f99773d7c22f2637"
            },
            "downloads": -1,
            "filename": "pylibretro-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a1ca125b112b0b50c6892fe013215da1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 79095,
            "upload_time": "2024-09-30T21:12:38",
            "upload_time_iso_8601": "2024-09-30T21:12:38.184934Z",
            "url": "https://files.pythonhosted.org/packages/2d/e8/8ad41dd278616315cf138b88628000f4db372ed5da5f12fad628421895ea/pylibretro-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-30 21:12:38",
    "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: 1.48942s