linuxpy


Namelinuxpy JSON
Version 0.23.0 PyPI version JSON
download
home_pageNone
SummaryHuman friendly interface to linux subsystems using python
upload_time2025-08-13 06:30:42
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords linux video system midi gpio led input gamepad joystick keyboard mouse thermal asyncio
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # linuxpy

[![linuxpy][pypi-version]](https://pypi.python.org/pypi/linuxpy)
[![Python Versions][pypi-python-versions]](https://pypi.python.org/pypi/linuxpy)
![License][license]
[![CI][CI]](https://github.com/tiagocoutinho/linuxpy/actions/workflows/ci.yml)

[![Source][source]](https://github.com/tiagocoutinho/linuxpy/)
[![Documentation][documentation]](https://tiagocoutinho.github.io/linuxpy/)

Human friendly interface to linux subsystems using python.

Provides python access to several linux subsystems like V4L2, GPIO, Led, thermal,
input and MIDI.

There is experimental, undocumented, incomplete and unstable access to USB.

Requirements:
* python >= 3.11
* Fairly recent linux kernel
* Installed kernel modules you want to access

And yes, it is true: there are no python libraries required! Also there are no
C libraries required. Everything is done here through direct ioctl, read and
write calls. Ain't linux wonderful?

## Installation

From within your favorite python environment:

```console
$ pip install linuxpy
```

To run the examples you'll need:

```console
$ pip install linuxpy[examples]
```

To develop, run tests, build package, lint, etc you'll need:

```console
$ pip install linuxpy[dev]
```

## Subsystems

### GPIO

```python
from linuxpy.gpio import Device

with Device.from_id(0) as gpio:
    info = gpio.get_info()
    print(info.name, info.label, len(info.lines))
    l0 = info.lines[0]
    print(f"L0: {l0.name!r} {l0.flags.name}")

# output should look somethig like:
# gpiochip0 INT3450:00 32
# L0: '' INPUT
```

Check the [GPIO user guide](https://tiagocoutinho.github.io/linuxpy/user_guide/gpio/) and
[GPIO reference](https://tiagocoutinho.github.io/linuxpy/api/gpio/) for more information.

### Input

```python
import time
from linuxpy.input.device import find_gamepads

pad = next(find_gamepads())
abs = pad.absolute

with pad:
    while True:
	    print(f"X:{abs.x:>3} | Y:{abs.y:>3} | RX:{abs.rx:>3} | RY:{abs.ry:>3}", end="\r", flush=True)
	    time.sleep(0.1)
```

Check the [Input user guide](https://tiagocoutinho.github.io/linuxpy/user_guide/input/) and
[Input reference](https://tiagocoutinho.github.io/linuxpy/api/input/) for more information.

### Led

```python
from linuxpy.led import find

caps_lock = find(function="capslock")
print(caps_lock.brightness)
print(caps_lock.max_brightness)
```

Check the [LED user guide](https://tiagocoutinho.github.io/linuxpy/user_guide/led/) and
[LED reference](https://tiagocoutinho.github.io/linuxpy/api/led/) for more information.

### MIDI Sequencer

```console
$ python

>>> from linuxpy.midi.device import Sequencer, event_stream

>>> seq = Sequencer()
>>> with seq:
        port = seq.create_port()
        port.connect_from(14, 0)
        for event in seq:
            print(event)
 14:0   Note on              channel=0, note=100, velocity=3, off_velocity=0, duration=0
 14:0   Clock                queue=0, pad=b''
 14:0   System exclusive     F0 61 62 63 F7
 14:0   Note off             channel=0, note=55, velocity=3, off_velocity=0, duration=0
```
Check the [MIDI user guide](https://tiagocoutinho.github.io/linuxpy/user_guide/midi/) and
[MIDI reference](https://tiagocoutinho.github.io/linuxpy/api/midi/) for more information.

### Thermal and cooling

```python
from linuxpy.thermal import find
with find(type="x86_pkg_temp") as tz:
    print(f"X86 temperature: {tz.temperature/1000:6.2f} C")
```

Check the [Thermal and cooling user guide](https://tiagocoutinho.github.io/linuxpy/user_guide/thermal/) and
[Thermal and cooling reference](https://tiagocoutinho.github.io/linuxpy/api/thermal/) for more information.

### Video

Video for Linux 2 (V4L2) python library

Without further ado:

```python
>>> from linuxpy.video.device import Device
>>> with Device.from_id(0) as cam:
>>>     for i, frame in enumerate(cam):
...         print(f"frame #{i}: {len(frame)} bytes")
...         if i > 9:
...             break
...
frame #0: 54630 bytes
frame #1: 50184 bytes
frame #2: 44054 bytes
frame #3: 42822 bytes
frame #4: 42116 bytes
frame #5: 41868 bytes
frame #6: 41322 bytes
frame #7: 40896 bytes
frame #8: 40844 bytes
frame #9: 40714 bytes
frame #10: 40662 bytes
```

Check the [V4L2 user guide](https://tiagocoutinho.github.io/linuxpy/user_guide/video/) and
[V4L2 reference](https://tiagocoutinho.github.io/linuxpy/api/video/) for more information.

[pypi-python-versions]: https://img.shields.io/pypi/pyversions/linuxpy.svg
[pypi-version]: https://img.shields.io/pypi/v/linuxpy.svg
[pypi-status]: https://img.shields.io/pypi/status/linuxpy.svg
[license]: https://img.shields.io/pypi/l/linuxpy.svg
[CI]: https://github.com/tiagocoutinho/linuxpy/actions/workflows/ci.yml/badge.svg
[documentation]: https://img.shields.io/badge/Documentation-blue?color=grey&logo=mdBook
[source]: https://img.shields.io/badge/Source-grey?logo=git

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "linuxpy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "linux, video, system, midi, gpio, led, input, gamepad, joystick, keyboard, mouse, thermal, asyncio",
    "author": null,
    "author_email": "Jose Tiago Macara Coutinho <coutinhotiago@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/32/0d/2b059cb682a00d884e1c5a4a36d7552c0e13c073dc763bce06091a48664f/linuxpy-0.23.0.tar.gz",
    "platform": null,
    "description": "# linuxpy\n\n[![linuxpy][pypi-version]](https://pypi.python.org/pypi/linuxpy)\n[![Python Versions][pypi-python-versions]](https://pypi.python.org/pypi/linuxpy)\n![License][license]\n[![CI][CI]](https://github.com/tiagocoutinho/linuxpy/actions/workflows/ci.yml)\n\n[![Source][source]](https://github.com/tiagocoutinho/linuxpy/)\n[![Documentation][documentation]](https://tiagocoutinho.github.io/linuxpy/)\n\nHuman friendly interface to linux subsystems using python.\n\nProvides python access to several linux subsystems like V4L2, GPIO, Led, thermal,\ninput and MIDI.\n\nThere is experimental, undocumented, incomplete and unstable access to USB.\n\nRequirements:\n* python >= 3.11\n* Fairly recent linux kernel\n* Installed kernel modules you want to access\n\nAnd yes, it is true: there are no python libraries required! Also there are no\nC libraries required. Everything is done here through direct ioctl, read and\nwrite calls. Ain't linux wonderful?\n\n## Installation\n\nFrom within your favorite python environment:\n\n```console\n$ pip install linuxpy\n```\n\nTo run the examples you'll need:\n\n```console\n$ pip install linuxpy[examples]\n```\n\nTo develop, run tests, build package, lint, etc you'll need:\n\n```console\n$ pip install linuxpy[dev]\n```\n\n## Subsystems\n\n### GPIO\n\n```python\nfrom linuxpy.gpio import Device\n\nwith Device.from_id(0) as gpio:\n    info = gpio.get_info()\n    print(info.name, info.label, len(info.lines))\n    l0 = info.lines[0]\n    print(f\"L0: {l0.name!r} {l0.flags.name}\")\n\n# output should look somethig like:\n# gpiochip0 INT3450:00 32\n# L0: '' INPUT\n```\n\nCheck the [GPIO user guide](https://tiagocoutinho.github.io/linuxpy/user_guide/gpio/) and\n[GPIO reference](https://tiagocoutinho.github.io/linuxpy/api/gpio/) for more information.\n\n### Input\n\n```python\nimport time\nfrom linuxpy.input.device import find_gamepads\n\npad = next(find_gamepads())\nabs = pad.absolute\n\nwith pad:\n    while True:\n\t    print(f\"X:{abs.x:>3} | Y:{abs.y:>3} | RX:{abs.rx:>3} | RY:{abs.ry:>3}\", end=\"\\r\", flush=True)\n\t    time.sleep(0.1)\n```\n\nCheck the [Input user guide](https://tiagocoutinho.github.io/linuxpy/user_guide/input/) and\n[Input reference](https://tiagocoutinho.github.io/linuxpy/api/input/) for more information.\n\n### Led\n\n```python\nfrom linuxpy.led import find\n\ncaps_lock = find(function=\"capslock\")\nprint(caps_lock.brightness)\nprint(caps_lock.max_brightness)\n```\n\nCheck the [LED user guide](https://tiagocoutinho.github.io/linuxpy/user_guide/led/) and\n[LED reference](https://tiagocoutinho.github.io/linuxpy/api/led/) for more information.\n\n### MIDI Sequencer\n\n```console\n$ python\n\n>>> from linuxpy.midi.device import Sequencer, event_stream\n\n>>> seq = Sequencer()\n>>> with seq:\n        port = seq.create_port()\n        port.connect_from(14, 0)\n        for event in seq:\n            print(event)\n 14:0   Note on              channel=0, note=100, velocity=3, off_velocity=0, duration=0\n 14:0   Clock                queue=0, pad=b''\n 14:0   System exclusive     F0 61 62 63 F7\n 14:0   Note off             channel=0, note=55, velocity=3, off_velocity=0, duration=0\n```\nCheck the [MIDI user guide](https://tiagocoutinho.github.io/linuxpy/user_guide/midi/) and\n[MIDI reference](https://tiagocoutinho.github.io/linuxpy/api/midi/) for more information.\n\n### Thermal and cooling\n\n```python\nfrom linuxpy.thermal import find\nwith find(type=\"x86_pkg_temp\") as tz:\n    print(f\"X86 temperature: {tz.temperature/1000:6.2f} C\")\n```\n\nCheck the [Thermal and cooling user guide](https://tiagocoutinho.github.io/linuxpy/user_guide/thermal/) and\n[Thermal and cooling reference](https://tiagocoutinho.github.io/linuxpy/api/thermal/) for more information.\n\n### Video\n\nVideo for Linux 2 (V4L2) python library\n\nWithout further ado:\n\n```python\n>>> from linuxpy.video.device import Device\n>>> with Device.from_id(0) as cam:\n>>>     for i, frame in enumerate(cam):\n...         print(f\"frame #{i}: {len(frame)} bytes\")\n...         if i > 9:\n...             break\n...\nframe #0: 54630 bytes\nframe #1: 50184 bytes\nframe #2: 44054 bytes\nframe #3: 42822 bytes\nframe #4: 42116 bytes\nframe #5: 41868 bytes\nframe #6: 41322 bytes\nframe #7: 40896 bytes\nframe #8: 40844 bytes\nframe #9: 40714 bytes\nframe #10: 40662 bytes\n```\n\nCheck the [V4L2 user guide](https://tiagocoutinho.github.io/linuxpy/user_guide/video/) and\n[V4L2 reference](https://tiagocoutinho.github.io/linuxpy/api/video/) for more information.\n\n[pypi-python-versions]: https://img.shields.io/pypi/pyversions/linuxpy.svg\n[pypi-version]: https://img.shields.io/pypi/v/linuxpy.svg\n[pypi-status]: https://img.shields.io/pypi/status/linuxpy.svg\n[license]: https://img.shields.io/pypi/l/linuxpy.svg\n[CI]: https://github.com/tiagocoutinho/linuxpy/actions/workflows/ci.yml/badge.svg\n[documentation]: https://img.shields.io/badge/Documentation-blue?color=grey&logo=mdBook\n[source]: https://img.shields.io/badge/Source-grey?logo=git\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Human friendly interface to linux subsystems using python",
    "version": "0.23.0",
    "project_urls": {
        "Documentation": "https://tiagocoutinho.github.io/linuxpy/",
        "Homepage": "https://github.com/tiagocoutinho/linuxpy",
        "Repository": "https://github.com/tiagocoutinho/linuxpy"
    },
    "split_keywords": [
        "linux",
        " video",
        " system",
        " midi",
        " gpio",
        " led",
        " input",
        " gamepad",
        " joystick",
        " keyboard",
        " mouse",
        " thermal",
        " asyncio"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "56cdddbc4ca232fa54aa6e0003021b38a886d9a45563bb07b24058e95a291199",
                "md5": "4047e642440494fd3aa2d4048e7af143",
                "sha256": "c6da5cd268ec7edf0911806a313d81e5816aa403449e328fdc6a2aef84bb7309"
            },
            "downloads": -1,
            "filename": "linuxpy-0.23.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4047e642440494fd3aa2d4048e7af143",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 448039,
            "upload_time": "2025-08-13T06:30:37",
            "upload_time_iso_8601": "2025-08-13T06:30:37.636680Z",
            "url": "https://files.pythonhosted.org/packages/56/cd/ddbc4ca232fa54aa6e0003021b38a886d9a45563bb07b24058e95a291199/linuxpy-0.23.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "320d2b059cb682a00d884e1c5a4a36d7552c0e13c073dc763bce06091a48664f",
                "md5": "89436aa8aaab5377ed66c9479d03cdbd",
                "sha256": "ab780f5092fc33592b4a370f66892630dc44fa0d562d614960fe20e90e7f00f7"
            },
            "downloads": -1,
            "filename": "linuxpy-0.23.0.tar.gz",
            "has_sig": false,
            "md5_digest": "89436aa8aaab5377ed66c9479d03cdbd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 445483,
            "upload_time": "2025-08-13T06:30:42",
            "upload_time_iso_8601": "2025-08-13T06:30:42.483482Z",
            "url": "https://files.pythonhosted.org/packages/32/0d/2b059cb682a00d884e1c5a4a36d7552c0e13c073dc763bce06091a48664f/linuxpy-0.23.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-13 06:30:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tiagocoutinho",
    "github_project": "linuxpy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "linuxpy"
}
        
Elapsed time: 1.83601s