Skip to main content

Python ctypes bindings for the RedNoise CPU software renderer, with the native library bundled.

Project description

RedNoise Python bindings

Python ctypes bindings for the RedNoise CPU software renderer. They call the stable C ABI declared in include/rednoise/rednoise.h. There is no compiled extension module: the bindings load the RedNoise shared library at runtime. The native library is built and bundled into the package, so a normal install is self-contained.

Install

pip install rednoise

Prebuilt wheels ship the native library, so on a supported platform this is all you need. Installing from an sdist compiles the native library on your machine via CMake, so you need a C++23-capable compiler (GCC 12+, Clang 15+, or MSVC 2022+) and CMake 3.24 or newer. The build uses the vendored glm in third_party/ and runs fully offline; it does not fetch SDL3 or any other optional dependency.

Under the hood, pip install drives scikit-build-core and CMake to build only the installable rednoise library (-DBUILD_LIB=ON, everything else off) and installs the resulting shared library into the importable rednoise/ package:

  • Linux: librednoise.so
  • macOS: librednoise.dylib
  • Windows: rednoise.dll

Pillow is optional and only needed for Image.to_pillow() or saving non-PNG formats:

pip install "rednoise[pillow]"

Library discovery

The bundled library is found automatically. For development against a separately built library, the bindings locate it in this order:

  1. The library bundled next to the package (what a wheel installs).
  2. The REDNOISE_LIBRARY environment variable (an explicit path to the file).
  3. The system search path (ctypes.util.find_library("rednoise")).
  4. Common local build paths (build/, next to the package, and similar).

To override with a locally built library, set REDNOISE_LIBRARY:

# Linux
export REDNOISE_LIBRARY="$PWD/build/librednoise.so"

# macOS
export REDNOISE_LIBRARY="$PWD/build/librednoise.dylib"

# Windows (cmd)
set REDNOISE_LIBRARY=%CD%\build\rednoise.dll

Develop from a local checkout

Install the bindings straight from this directory:

pip install ./bindings/python

Add the Pillow extra with:

pip install "./bindings/python[pillow]"

You can still build the shared library by hand from the repository root and point REDNOISE_LIBRARY at it:

cmake -B build -S . -DBUILD_LIB=ON -DBUILD_APP=OFF
cmake --build build

Usage

import rednoise

print(rednoise.version())

with rednoise.Scene.load_obj("assets/cornell-box.obj") as scene:
    print("triangles:", scene.triangle_count)
    image = scene.render(mode="pathtraced", width=400, height=300, samples=64)
    image.save("cornell.png")

Scene.render accepts a render mode as a RenderMode enum, an integer, or a name string: "wireframe", "rasterised", "raytraced", or "pathtraced". The returned Image exposes .rgba (raw RGBA8 bytes), .size, .save(path), and .to_pillow() when Pillow is installed.

A complete runnable example lives in example.py. Run it from the repository root (after building the library and setting REDNOISE_LIBRARY):

python bindings/python/example.py

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

rednoise-0.2.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distributions

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

rednoise-0.2.0-py3-none-win_amd64.whl (1.2 MB view details)

Uploaded Python 3Windows x86-64

rednoise-0.2.0-py3-none-win32.whl (1.1 MB view details)

Uploaded Python 3Windows x86

rednoise-0.2.0-py3-none-manylinux_2_34_x86_64.whl (1.9 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ x86-64

rednoise-0.2.0-py3-none-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file rednoise-0.2.0.tar.gz.

File metadata

  • Download URL: rednoise-0.2.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rednoise-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6436f88c501899d05d4774965ada30387b394dc0b57553621115d305c0ae872e
MD5 1d4a6c2c7c591b20ac3800791262cf40
BLAKE2b-256 ec7dface095dc4b99eb8c8e88e2020a47e83b17deb4ce772cefe091a4c122f00

See more details on using hashes here.

Provenance

The following attestation bundles were made for rednoise-0.2.0.tar.gz:

Publisher: release.yml on ReverseZoom2151/rednoise

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rednoise-0.2.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: rednoise-0.2.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rednoise-0.2.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 5001aca3d72d52abc4eb78b399d950ef970e3b0ada3702eb956aa0051012d9a3
MD5 73d48fc1554b76621e4a66d54333eed6
BLAKE2b-256 cea279171d9d5100430b4d1120884097b7bafee168c87ad32f752e1a43c932dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for rednoise-0.2.0-py3-none-win_amd64.whl:

Publisher: release.yml on ReverseZoom2151/rednoise

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rednoise-0.2.0-py3-none-win32.whl.

File metadata

  • Download URL: rednoise-0.2.0-py3-none-win32.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rednoise-0.2.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 c6aacb46995ed114417bd51c603b895e9b1072260a462a08271c1f3db5619e33
MD5 706c1a1c6955934db97c399aa89ccc09
BLAKE2b-256 e74c1f92a087e1d8c0b599f9632117f9efa6958acff5383de3f14201bbe4e93a

See more details on using hashes here.

Provenance

The following attestation bundles were made for rednoise-0.2.0-py3-none-win32.whl:

Publisher: release.yml on ReverseZoom2151/rednoise

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rednoise-0.2.0-py3-none-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for rednoise-0.2.0-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 15ac96343853a72800937ba9d434db076ddb3e277a1b228642cadd5d05fa8b5c
MD5 853fbf9dff2dc33bda767feb7a9128c7
BLAKE2b-256 a9fdaa6230b22b2c25fb99c4daeb8785a72bb93bfbc0393a9b97d3f26d60d2f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for rednoise-0.2.0-py3-none-manylinux_2_34_x86_64.whl:

Publisher: release.yml on ReverseZoom2151/rednoise

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rednoise-0.2.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rednoise-0.2.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e62fcd5819e0537cda61d317e339718adf15211b8e96a44148af84136a30b9a7
MD5 bd7b65eba3195307af322a79e0ae4457
BLAKE2b-256 c34846c018e87b0f626a54b0924cefaefcb3c21e13803234362e07fad59eab3c

See more details on using hashes here.

Provenance

The following attestation bundles were made for rednoise-0.2.0-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on ReverseZoom2151/rednoise

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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