syphon-python


Namesyphon-python JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/cansik/syphon-python
SummaryPython wrapper for the GPU texture sharing framework Syphon.
upload_time2023-12-28 15:36:00
maintainer
docs_urlNone
authorFlorian Bruggisser
requires_python
licenseMIT License
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Syphon for Python

[![Documentation](https://img.shields.io/badge/read-documentation-blue)](https://cansik.github.io/syphon-python/)
[![Build](https://github.com/cansik/syphon-python/actions/workflows/build.yml/badge.svg)](https://github.com/cansik/syphon-python/actions/workflows/build.yml)
[![PyPI](https://img.shields.io/pypi/v/syphon-python)](https://pypi.org/project/syphon-python/)

⚠️ This library is still *in development*.

Python wrapper for the Syphon GPU texture sharing framework. This library was created to support both the Metal backend
and the deprecated OpenGL backend. It requires **macOS 11 or above**.

The implementation is based on [PyObjC](https://github.com/ronaldoussoren/pyobjc) to wrap the
Syphon framework](https://github.com/Syphon/Syphon-Framework) directly from Python. This approach eliminates
native wrapper and allows Python developers to extend the library as needed.

## State of Development

- [x] Syphon Server Discovery
- [x] Metal Server
- [x] Metal Client
- [x] OpenGL Server
- [x] OpenGL Client
- [ ] Syphon Client On Frame Callback

## Usage
To install `syphon-python` it is recommended to use a prebuilt binary from PyPi:

```bash
pip install syphon-python
```

To run all the examples, please also install [Numpy](https://numpy.org/) and [OpenCV](https://opencv.org/):

```bash
pip install numpy opencv-python
```

The following code snippet is a basic example showing how to share `numpy` images as `MTLTexture` with a `SyphonMetalServer`. There are more examples in [examples](/examples).

```python
import time

import numpy as np

import syphon
from syphon.utils.numpy import copy_image_to_mtl_texture
from syphon.utils.raw import create_mtl_texture

# create server and texture
server = syphon.SyphonMetalServer("Demo")
texture = create_mtl_texture(server.device, 512, 512)

# create texture data
texture_data = np.zeros((512, 512, 4), dtype=np.uint8)
texture_data[:, :, 0] = 255  # fill red
texture_data[:, :, 3] = 255  # fill alpha

while True:
    # copy texture data to texture and publish frame
    copy_image_to_mtl_texture(texture_data, texture)
    server.publish_frame_texture(texture)
    time.sleep(1)

server.stop()
```

## Development
To develop or manually install the library, use the following commands to set up the local repository.

### Installation

```bash
# clone the repository and it's submodules
git clone --recurse-submodules https://github.com/cansik/syphon-python.git

# install dependencies
pip install -r dev-requirements.txt
pip install -r requirements.txt

# for some examples the following dependencies are needed
pip install numpy
pip install opencv-python
```

### Build

Build the Syphon framework on your machine:

```bash
python setup.py build
```

### Distribute

Create a wheel package (also runs `build` automatically)

```bash
python setup.py bdist_wheel
```

### Generate Documentation

```bash
# create documentation into "./docs
python setup.py doc

# launch pdoc webserver
python setup.py doc --launch
```

## About

MIT License - Copyright (c) 2023 Florian Bruggisser

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cansik/syphon-python",
    "name": "syphon-python",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Florian Bruggisser",
    "author_email": "github@broox.ch",
    "download_url": "",
    "platform": null,
    "description": "# Syphon for Python\n\n[![Documentation](https://img.shields.io/badge/read-documentation-blue)](https://cansik.github.io/syphon-python/)\n[![Build](https://github.com/cansik/syphon-python/actions/workflows/build.yml/badge.svg)](https://github.com/cansik/syphon-python/actions/workflows/build.yml)\n[![PyPI](https://img.shields.io/pypi/v/syphon-python)](https://pypi.org/project/syphon-python/)\n\n\u26a0\ufe0f This library is still *in development*.\n\nPython wrapper for the Syphon GPU texture sharing framework. This library was created to support both the Metal backend\nand the deprecated OpenGL backend. It requires **macOS 11 or above**.\n\nThe implementation is based on [PyObjC](https://github.com/ronaldoussoren/pyobjc) to wrap the\nSyphon framework](https://github.com/Syphon/Syphon-Framework) directly from Python. This approach eliminates\nnative wrapper and allows Python developers to extend the library as needed.\n\n## State of Development\n\n- [x] Syphon Server Discovery\n- [x] Metal Server\n- [x] Metal Client\n- [x] OpenGL Server\n- [x] OpenGL Client\n- [ ] Syphon Client On Frame Callback\n\n## Usage\nTo install `syphon-python` it is recommended to use a prebuilt binary from PyPi:\n\n```bash\npip install syphon-python\n```\n\nTo run all the examples, please also install [Numpy](https://numpy.org/) and [OpenCV](https://opencv.org/):\n\n```bash\npip install numpy opencv-python\n```\n\nThe following code snippet is a basic example showing how to share `numpy` images as `MTLTexture` with a `SyphonMetalServer`. There are more examples in [examples](/examples).\n\n```python\nimport time\n\nimport numpy as np\n\nimport syphon\nfrom syphon.utils.numpy import copy_image_to_mtl_texture\nfrom syphon.utils.raw import create_mtl_texture\n\n# create server and texture\nserver = syphon.SyphonMetalServer(\"Demo\")\ntexture = create_mtl_texture(server.device, 512, 512)\n\n# create texture data\ntexture_data = np.zeros((512, 512, 4), dtype=np.uint8)\ntexture_data[:, :, 0] = 255  # fill red\ntexture_data[:, :, 3] = 255  # fill alpha\n\nwhile True:\n    # copy texture data to texture and publish frame\n    copy_image_to_mtl_texture(texture_data, texture)\n    server.publish_frame_texture(texture)\n    time.sleep(1)\n\nserver.stop()\n```\n\n## Development\nTo develop or manually install the library, use the following commands to set up the local repository.\n\n### Installation\n\n```bash\n# clone the repository and it's submodules\ngit clone --recurse-submodules https://github.com/cansik/syphon-python.git\n\n# install dependencies\npip install -r dev-requirements.txt\npip install -r requirements.txt\n\n# for some examples the following dependencies are needed\npip install numpy\npip install opencv-python\n```\n\n### Build\n\nBuild the Syphon framework on your machine:\n\n```bash\npython setup.py build\n```\n\n### Distribute\n\nCreate a wheel package (also runs `build` automatically)\n\n```bash\npython setup.py bdist_wheel\n```\n\n### Generate Documentation\n\n```bash\n# create documentation into \"./docs\npython setup.py doc\n\n# launch pdoc webserver\npython setup.py doc --launch\n```\n\n## About\n\nMIT License - Copyright (c) 2023 Florian Bruggisser\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Python wrapper for the GPU texture sharing framework Syphon.",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/cansik/syphon-python"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2cf2460c9cc7c4682353abccb1d3f8cf5ca0af2a59af97b5c57b72f87e1f296c",
                "md5": "770d88be8d616e7982d9ea6af4d662d0",
                "sha256": "be4a25818cf228e895ff49255ebfbae3ce9578dcb0eae9c6f5b9083df721e8ff"
            },
            "downloads": -1,
            "filename": "syphon_python-0.1.1-cp310-cp310-macosx_10_9_universal2.whl",
            "has_sig": false,
            "md5_digest": "770d88be8d616e7982d9ea6af4d662d0",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": null,
            "size": 459805,
            "upload_time": "2023-12-28T15:36:00",
            "upload_time_iso_8601": "2023-12-28T15:36:00.026154Z",
            "url": "https://files.pythonhosted.org/packages/2c/f2/460c9cc7c4682353abccb1d3f8cf5ca0af2a59af97b5c57b72f87e1f296c/syphon_python-0.1.1-cp310-cp310-macosx_10_9_universal2.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b0bc42b2adacacb9392a1c1a879ad7674f9c677489a180d9539d1bad9dc153ed",
                "md5": "2748bde3b5ddc54a61ff4a078cb53437",
                "sha256": "863f884bb0665a7038596bcacedc81ebc0e627c9980f0a5c22b7defe67af25bb"
            },
            "downloads": -1,
            "filename": "syphon_python-0.1.1-cp311-cp311-macosx_10_9_universal2.whl",
            "has_sig": false,
            "md5_digest": "2748bde3b5ddc54a61ff4a078cb53437",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": null,
            "size": 459793,
            "upload_time": "2023-12-28T15:36:01",
            "upload_time_iso_8601": "2023-12-28T15:36:01.715670Z",
            "url": "https://files.pythonhosted.org/packages/b0/bc/42b2adacacb9392a1c1a879ad7674f9c677489a180d9539d1bad9dc153ed/syphon_python-0.1.1-cp311-cp311-macosx_10_9_universal2.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ee94ccc2749af546a080f3ce96e344c01591dd0758bd9edcf19de0c92b37b591",
                "md5": "6ad55c1a9d7fe33fa2a441f690a8291f",
                "sha256": "07e47ce5380de1832c30c21e460209db0c4d5771d27cb42912eff4ab431b12e1"
            },
            "downloads": -1,
            "filename": "syphon_python-0.1.1-cp312-cp312-macosx_10_9_universal2.whl",
            "has_sig": false,
            "md5_digest": "6ad55c1a9d7fe33fa2a441f690a8291f",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": null,
            "size": 459778,
            "upload_time": "2023-12-28T15:36:03",
            "upload_time_iso_8601": "2023-12-28T15:36:03.728256Z",
            "url": "https://files.pythonhosted.org/packages/ee/94/ccc2749af546a080f3ce96e344c01591dd0758bd9edcf19de0c92b37b591/syphon_python-0.1.1-cp312-cp312-macosx_10_9_universal2.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "43ff90bf6703a611721ae31c738345ef93b6c7eac2139cd0b6b0965afea073c4",
                "md5": "8b425d84fe20459fb4d16bc4edfd56b0",
                "sha256": "221d71a17819660e81a12a43b85f9310ec35248eadac988d3a20eeffc9b0fdd1"
            },
            "downloads": -1,
            "filename": "syphon_python-0.1.1-cp38-cp38-macosx_10_9_universal2.whl",
            "has_sig": false,
            "md5_digest": "8b425d84fe20459fb4d16bc4edfd56b0",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": null,
            "size": 459897,
            "upload_time": "2023-12-28T15:36:05",
            "upload_time_iso_8601": "2023-12-28T15:36:05.172765Z",
            "url": "https://files.pythonhosted.org/packages/43/ff/90bf6703a611721ae31c738345ef93b6c7eac2139cd0b6b0965afea073c4/syphon_python-0.1.1-cp38-cp38-macosx_10_9_universal2.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5a1dff37940336e807f451c817c30277c4140a6f669030e84769309725cf894e",
                "md5": "94ee7f763cc38f20b3d598912c3a8b51",
                "sha256": "c3be9ad989e30acc051c82d6204316016975ba3e78d0edb09abff7b3481ba76d"
            },
            "downloads": -1,
            "filename": "syphon_python-0.1.1-cp39-cp39-macosx_10_9_universal2.whl",
            "has_sig": false,
            "md5_digest": "94ee7f763cc38f20b3d598912c3a8b51",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": null,
            "size": 459822,
            "upload_time": "2023-12-28T15:36:06",
            "upload_time_iso_8601": "2023-12-28T15:36:06.449250Z",
            "url": "https://files.pythonhosted.org/packages/5a/1d/ff37940336e807f451c817c30277c4140a6f669030e84769309725cf894e/syphon_python-0.1.1-cp39-cp39-macosx_10_9_universal2.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-28 15:36:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cansik",
    "github_project": "syphon-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "syphon-python"
}
        
Elapsed time: 0.19372s