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

Uploaded Python 3Windows x86-64

rednoise-0.1.2-py3-none-win32.whl (922.4 kB view details)

Uploaded Python 3Windows x86

rednoise-0.1.2-py3-none-manylinux_2_34_x86_64.whl (1.5 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ x86-64

rednoise-0.1.2-py3-none-macosx_11_0_arm64.whl (991.0 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: rednoise-0.1.2.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.1.2.tar.gz
Algorithm Hash digest
SHA256 acd571b7a60060d3c9bfd8d2001c044da1446a337d18a67b1f5821b2b9c116c8
MD5 14925ebccecc56e1734306cc2e7e5656
BLAKE2b-256 2c0ee473315eed577f23c453fde9af4b587b53ea6727dc7165414cc24548de3b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: rednoise-0.1.2-py3-none-win_amd64.whl
  • Upload date:
  • Size: 980.9 kB
  • 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.1.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 e9d99e1e8704c30b0a936545830fb58a5f957bcd6f492336116ff377f6887354
MD5 94bf163cdfc9b2ce8326065816870622
BLAKE2b-256 72a006d8cf1c9ed16ed69e42988e71a87773d2bac54c2193a7a324baf918cc8f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: rednoise-0.1.2-py3-none-win32.whl
  • Upload date:
  • Size: 922.4 kB
  • 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.1.2-py3-none-win32.whl
Algorithm Hash digest
SHA256 9ce5d60ecc4a5b98a092573f88d7962600206460707e60a5a018519401c21254
MD5 dd8f9d873661996c9ae19a6b98f371d5
BLAKE2b-256 f4e636ca603cf619e405de21c7552e2a7ed462309ee620db86f84141ae19c0ef

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rednoise-0.1.2-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 07f042ad9173559d5001ce48128c1ad26263d5c15f19514483e5d5745c50aa5b
MD5 aa10fa61c30d07fc4ddcef7d833dd088
BLAKE2b-256 55d440672fe796c1b9383fcb8ef5ed96a29ae4c6bb78d5dac665cec98ea7951d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rednoise-0.1.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fac35f3db65d1a1436b89e1846e2b5324bdd81c8dd44788a7cb972760d2bddb1
MD5 3b2e522bcf8551a73992849362499932
BLAKE2b-256 35652b1cd12a028d05684434362d25ab28657bd09f232fd9112cc2f20f7e4674

See more details on using hashes here.

Provenance

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