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

Uploaded CPython 3.13Windows x86-64

pynari-1.4.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pynari-1.4.0-cp313-cp313-macosx_11_0_arm64.whl (8.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pynari-1.4.0-cp312-cp312-win_amd64.whl (16.8 MB view details)

Uploaded CPython 3.12Windows x86-64

pynari-1.4.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pynari-1.4.0-cp312-cp312-macosx_11_0_arm64.whl (8.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pynari-1.4.0-cp39-cp39-win_amd64.whl (16.8 MB view details)

Uploaded CPython 3.9Windows x86-64

pynari-1.4.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

File details

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

File metadata

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

File hashes

Hashes for pynari-1.4.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 84f46491033884902d3d261357fd6fda1cae2634b21e97bacf666366f1bf53b6
MD5 d67578939ce61f9850a9648334d153e6
BLAKE2b-256 f8028e6c5df40be383242a1b49dd5b221f4b1a88545b14cd780e13dca6879294

See more details on using hashes here.

File details

Details for the file pynari-1.4.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynari-1.4.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 02f29f5b35aeb6f1cff60338ac044bde911e251471d8aafa6d7fc0005a75f432
MD5 04fccc730151728211c22dacdfa6a89c
BLAKE2b-256 079870668d656e49b355cd177d78133eb6bdfc6789220b9fd20c373186a43bae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.4.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 97dc9a34897819971e68b59c340e4284b8ebac8fa55d47adf384cf6552daf6dc
MD5 6cfd765cccaac324f7deb0b8094747e6
BLAKE2b-256 95d1477ae4ade03d69077364ba0986c130f7dcd60bec4ced5868ad96260aa95b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pynari-1.4.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 78ffe5e68782e91b9f68e2e92cd884f9b355eff354727cac1d5e49a02717ed20
MD5 e986cc817af5e4acabcefc03ab5f44a3
BLAKE2b-256 c2f7c800e101ea885306b9cc5b8d38a283c7ea8e3d5e502a85cfe406708837d3

See more details on using hashes here.

File details

Details for the file pynari-1.4.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynari-1.4.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fda768739d8fca7726dd55991cc36f03788892d8c5c8f28f73e8d14f8cd14ff6
MD5 1b1db42d713f36cd97af98c066a8d36b
BLAKE2b-256 715f64c366b5df50fcf464ef26d1bfd4b3b87abefa4c0c2cb10e7a17f609b741

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.4.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4235590306a39d7db42836212876ea69efa296b2da9821dcddbda07a92993b69
MD5 38c413b5f09d068925b77b1edece050f
BLAKE2b-256 4b2581daacab5eabdfee628753b4fc14181da0dc01ade801b0585ce35406fd5c

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pynari-1.4.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 956118e7eec02c87014c34a26516609b0ba3229d7404481945ba975bb9a29a9d
MD5 86ebb95cab17f8490ad744890d96ec24
BLAKE2b-256 6af31349e86e268833251740cb385756e9c1ad76eb0d3abb72ca716ecef4c8fe

See more details on using hashes here.

File details

Details for the file pynari-1.4.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pynari-1.4.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ea1b477e771b56a23cb0257e8cd9c09d7ad83688080a4c2b6f19293e6814df16
MD5 69c9f5e966b20fa5e6e6cf87a7e0066c
BLAKE2b-256 506ecba596b85ac66172334a1f429d222e43728d9438eea32671da83cf025d36

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