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.1.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.1-py3-none-win_amd64.whl (1.2 MB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

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

Uploaded Python 3manylinux: glibc 2.34+ x86-64

rednoise-0.2.1-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.1.tar.gz.

File metadata

  • Download URL: rednoise-0.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 8c26ea03f2fbb6dd6f99026a162f33cfcbbfe1023df82b719fe4c4801559aa6c
MD5 6dd8751908dde562fd927905c135689a
BLAKE2b-256 29431ff3e5e3f7a775ac4e4acab205015006dd787785506e9fcd03be6b9752b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for rednoise-0.2.1.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.1-py3-none-win_amd64.whl.

File metadata

  • Download URL: rednoise-0.2.1-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.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 93cdd25dd406f853ff7e49e799c8762c8d903e5cc223b6b3a3d00d6bbea5b45c
MD5 a1c29e4f8406750d31c53e87dba05e6b
BLAKE2b-256 c3761c46c0983009cca2b8da982da26e1063be00e64f44a0f1e1cf59c70953e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for rednoise-0.2.1-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.1-py3-none-win32.whl.

File metadata

  • Download URL: rednoise-0.2.1-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.1-py3-none-win32.whl
Algorithm Hash digest
SHA256 2f62946aea9c3fef6fbcd6a18391cebf340d4986997fc26150703f727f51bd8d
MD5 449e41b6e2cd0bc26043f5775b57fddf
BLAKE2b-256 1a2c5464a2fcb545d9dd6075f8fb73d90adff9e2eb6fb109f622250b8f8bfe6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for rednoise-0.2.1-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.1-py3-none-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for rednoise-0.2.1-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 872c81d7b496001adad8c696f84daf821e59d3ee803d4be4da1533d514c5cda4
MD5 e7d8bf69d1923afcf43cff596a3baaad
BLAKE2b-256 5d2c361df494c3ad5939b33c83e355abf502cc4bb34e29ee06d0e1bf3f024253

See more details on using hashes here.

Provenance

The following attestation bundles were made for rednoise-0.2.1-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.1-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rednoise-0.2.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4457bcddd0d075747859ab426ea7ddb0016f6c89ff95df8a9ab2e17418c93d25
MD5 17ca9924b2d9c1ee58bd3c4772397f8d
BLAKE2b-256 90d752d84242b3171b2f2a0b26ae54aacb8a509242878663b59b6e1aa7196539

See more details on using hashes here.

Provenance

The following attestation bundles were made for rednoise-0.2.1-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