Skip to main content

Python bindings for ANARI

Project description

pynari - Python Bindings for ANARI

This project provides a python interface for the Khronos ANARI rendering API. This implementation currently requires a CUDA capable GPU (support for other backends will be added at a later time).

Usage - Quickstart

Assuming you already know how the ANARI API works (and that you have pip-installed this package) you can use ANARI in python as follows: First, import this package

import pynari as anari

(for all the steps below we assume you imported pynari as anari; this is not required, but please take this in mind for the examples below).

Once the package has been imported you can then create a ANARI "device" using

device = anari.newDevice('default')

(the 'default' will later allow for selecting between different back-ends, but this current implementation is hard-coded to the 'barney' backend, see https://github.com/ingowald/barney).

You can then create various ANARI actor objects through creator-methods on that device, such as, for example

world = device.newWorld()
mesh  = device.newGeometry('triangle')
array = device.newArray(anari.FLOAT32_VEC3,vertex)

etc.

Large arrays (such as vertex or index arrays for a triangle mesh) are expected to be populated using numpy, and wrapped in the ANARI 'array' type:

import numpy as np
...
vertex = np.array(...,dtype=np.float32)
mesh.setParameter('vertex.position',anari.ARRAY,
                  device.newArray(anari.FLOAT32_VEC3,vertex));
index  = np.array(...,dtype=np.uint32)
mesh.setParameter('primitive.index',anari.ARRAY,
                  device.newArray(anari.UINT32_VEC3,index));

The ANARI API, and how it is exposed in pynari

For a full description of what ANARI Objects are, what kind of objects exist, and how they work, please refer to the ANARI API Spec at https://registry.khronos.org/ANARI/specs/1.0/ANARI-1.0.html .

Since the official ANARI API is a plain C API we could not implement this literally, but had to make certain changes to make ti more "pythonic". Basically, these rules were applied (we will assume that the pynari module was imported under the alias as anari):

  • If there is a C constant/enum of name ANARI_XYZ, it is exposed as anari.XYZ. Example: the C enum of ANARI_FLOAT32 is anari.FLOAT32 in pynari.

  • If there is a C API function of anariFunctionXyz(ANARIDevice device, ...) it will be exposed as device.functionXyz(...). Note that in order to remain as close to the C-style API as possible we use CAML-case for function names, not python-casing. I.e., pynari uses device.functionXyz(...), not device.function_xyz(...).

Examples

For a list of several samples, please visit the pynari github repo https://github.com/ingowald/pynari

For any issues, please use the github pynari issue tracker.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

pynari-1.0.39-cp313-cp313-manylinux_2_34_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

pynari-1.0.39-cp312-cp312-manylinux_2_34_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

pynari-1.0.39-cp311-cp311-manylinux_2_34_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

pynari-1.0.39-cp310-cp310-manylinux_2_34_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

pynari-1.0.39-cp39-cp39-manylinux_2_34_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

pynari-1.0.39-cp38-cp38-manylinux_2_34_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

File details

Details for the file pynari-1.0.39-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pynari-1.0.39-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 71304e73903eed2a11a93d795b4d7a185457bd5e6451f6829eed0b7b43f67d67
MD5 26021a476a84b780c099df600ebd18a2
BLAKE2b-256 0c4b9471ca1c7a6034379ac3c839c369349350a477a71160282e7557d40ad0da

See more details on using hashes here.

File details

Details for the file pynari-1.0.39-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pynari-1.0.39-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 9d1b10967ff1e2e6a077cbbbfcc362a459a766e4c988d8b7a19cd65d708cbfeb
MD5 8698b367ab73763f10053a8a14298ec2
BLAKE2b-256 86c25f30d6cf8ac1f34b6c83e90370624accbd491a03ca0be8a5730dba1ef570

See more details on using hashes here.

File details

Details for the file pynari-1.0.39-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pynari-1.0.39-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 918f3531d78ba05c0f69dd0dc77df89d7990dd779bea8ae895b0f02527fba3aa
MD5 3682a039ffde6b4682427db9d4b97c64
BLAKE2b-256 04945ca843ed676ff88394c9ab4999c79dc4f58535d41691bd2c721a93301b73

See more details on using hashes here.

File details

Details for the file pynari-1.0.39-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pynari-1.0.39-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c2f47a5fc663d94a3fe5a83311c82f70e8e577e619e82178ffaa5ab2e4d6419d
MD5 1fb904ff5e8d6abad8c5359d147a56c1
BLAKE2b-256 c1563424a4bab7be55932194121d8eb5f43ca25ee677ec02f5212b9d19052af8

See more details on using hashes here.

File details

Details for the file pynari-1.0.39-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pynari-1.0.39-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c445ea1503a94728bfb0d51bee3c36e74bdfd74c602b0ad26b4f6cda6215b52b
MD5 aba0897e22c1a760911800feaf596463
BLAKE2b-256 b6a109968372fb35c213fd0a9e75ccf4531733950d0d2a611a221cbda40727b9

See more details on using hashes here.

File details

Details for the file pynari-1.0.39-cp38-cp38-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pynari-1.0.39-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 80e7b3d2d531add241db2fd12e5ed43a7821b24a310ae781de3ff1a06204f744
MD5 8e6c342a106e3e1a966b291419c2c85d
BLAKE2b-256 ce7b56ce4f338319f2d6fb9654d0a2071995b949e1e18e098ed2df3766741196

See more details on using hashes here.

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