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

Uploaded CPython 3.13Windows x86-64

pynari-1.2.8-cp313-cp313-macosx_11_0_arm64.whl (8.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pynari-1.2.8-cp312-cp312-win_amd64.whl (15.9 MB view details)

Uploaded CPython 3.12Windows x86-64

pynari-1.2.8-cp312-cp312-macosx_11_0_arm64.whl (8.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pynari-1.2.8-cp39-cp39-win_amd64.whl (15.9 MB view details)

Uploaded CPython 3.9Windows x86-64

File details

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

File metadata

  • Download URL: pynari-1.2.8-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 15.9 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for pynari-1.2.8-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 656e76b08cbc5f4a4c681fb99266736c6fa7b06206ef868bd9cc978245126dae
MD5 4b65b463fec3d22c0a117ffc6d2e5cbf
BLAKE2b-256 3099aee45ebc5fbde61b224947fc8d6cc1994fa1a3a3b7d30f3f88aaadc1f88b

See more details on using hashes here.

File details

Details for the file pynari-1.2.8-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pynari-1.2.8-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ccb682fa95d02245c3679e5be926fd90e5ad2a8e58797415d1a6ab657da36d04
MD5 8bee43c1afb8c0f0e3ec7738b388c054
BLAKE2b-256 9b5dac19d14b8dbfb69b2cf23be97ce7bf78cdd4cdcd9fe990bc7687884f0939

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pynari-1.2.8-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 15.9 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for pynari-1.2.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 07ac9369eec32310e6dfd1420672036911adeb67d1f907ca305302ff597a570d
MD5 1f25e7cc0ae43b9cabe9643dead34c9d
BLAKE2b-256 f86ad109b528f3d340f77f561dd3f264e54c47282d36ce7213e4b2ef41acff1f

See more details on using hashes here.

File details

Details for the file pynari-1.2.8-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pynari-1.2.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a9f13a790c96ed7143b0cc048e37b6094c4af1cdf91bda8623f8f7570ccc1dbb
MD5 15e2b5909cc5f70a22b61d771702164b
BLAKE2b-256 12d91b32038dc7f2668983695df84134662b4a4f5695e32e0d8d22d53685f617

See more details on using hashes here.

File details

Details for the file pynari-1.2.8-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pynari-1.2.8-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 15.9 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for pynari-1.2.8-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5d0745807fd67c3fe53728cd3eebf7ebeac214cc2550c37aa2347b406d2adedd
MD5 c4cd394e4bce5c88a2b53a4c007517c0
BLAKE2b-256 f238d6193f7ff4413979ab71c1820d691685089094bee844a0005455d77a35b5

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