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.36-cp313-cp313-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.13Windows x86-64

pynari-1.0.36-cp313-cp313-manylinux_2_34_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

pynari-1.0.36-cp312-cp312-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.12Windows x86-64

pynari-1.0.36-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.36-cp311-cp311-manylinux_2_34_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

pynari-1.0.36-cp310-cp310-manylinux_2_34_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

pynari-1.0.36-cp39-cp39-manylinux_2_34_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

pynari-1.0.36-cp38-cp38-manylinux_2_34_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

File details

Details for the file pynari-1.0.36-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pynari-1.0.36-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.5 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.0

File hashes

Hashes for pynari-1.0.36-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 cd0b126aeb34da10e7d04e30ea91f1485cf98b3f601cbcd949ca1a83658dc4e1
MD5 410ceb75f3a4fa67b346b1e3bb14852b
BLAKE2b-256 b03b3fc192e8d6ce0f5442e674fc9514c21177b64e9caaabe88d365da9ae70b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.0.36-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 1881a9e38546939e49b6882a5818ec8782a2fd6d33ad88637cba7a736f0ff43d
MD5 c3a6dd1888100fa1aceaef7179367ca3
BLAKE2b-256 0fa3cc5ff387185b452153aa683c2f219411c6cd36befefbb9acc9e43f10cfba

See more details on using hashes here.

File details

Details for the file pynari-1.0.36-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pynari-1.0.36-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.5 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.0

File hashes

Hashes for pynari-1.0.36-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5433b5e18e6159c60cd604c426b06e3c1d1a57400fc6aa9689015cff94256acf
MD5 5eb3b789b9a544b5128ac1ed0c1096b9
BLAKE2b-256 4917d36e83dfa5d3800d68fab1afb2f9f3f000a79b17dfdd94ff8b1d8c00acba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.0.36-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 43196e94ea6ee82519bcdcedd1eb03309ad64eafd56c2389f18da819171e746f
MD5 37e172e719092e9f77ffd0d0aaad46f4
BLAKE2b-256 db40008489c572846a324952e0801c426903e13c917e2172804618c74aa641df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.0.36-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 62718057949e59237e217874df936634c7cc00815106122ff41145d21aa8444a
MD5 784989b23652920fa22896a285e27530
BLAKE2b-256 4177d353c003929724e33776b69be00e2ceae131989347496dc0c16c341044f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.0.36-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c1b609fdb2a8c77ad223dc24cae17df0e9f2dcf5ed1610c97f492b2dd85bf3d6
MD5 225d8879052ff8532ad2ac8e5bb15db7
BLAKE2b-256 49ecccb59abd982309e1faa098ca504189c9be59249e6dc22e6ce385db8feb80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.0.36-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 355d72c1ea28222eb5e565c02c23a234c29a5cd4f999e40f9ff091e0b965905e
MD5 e8fcc360b4b5e5e46f67cd5b6f12050e
BLAKE2b-256 23b25e0f086fa1ba4539fc9612f0fce3faa5e4d1b893c53187a27d046908a092

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.0.36-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 05e67eb7e880a18c3d771e5307f265bda36acb8558f1bd0ededf2de932d465ad
MD5 d50a0255e1ff474ddfcc083aa384c1bc
BLAKE2b-256 17178bf65cfa008b8dcaf4834ece2d0e09061a759a5f4f639413875800dad18d

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