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

Uploaded CPython 3.13Windows x86-64

pynari-1.2.9-cp313-cp313-manylinux_2_34_x86_64.whl (16.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

pynari-1.2.9-cp312-cp312-manylinux_2_34_x86_64.whl (16.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

File details

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

File metadata

  • Download URL: pynari-1.2.9-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.2.9-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 cdfe7cfef5f3c6e37f3d4ae612855df90bd78eb3cdfb27ffc33502d2fcfc7f43
MD5 6803232bf59f0c7ad4241a58e510ba61
BLAKE2b-256 cd10ffeb93bbc3249b55b2e9699df93e8df3aac2532d85a1d801d941a3c97534

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.2.9-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 31873ce2dec9ecb419de9688f6d0456c6868b7eb7a141cd5ef5ad02322520e8f
MD5 af902bb3240e7373b404cab5b7fb3873
BLAKE2b-256 3be5b0e82cbfcf0b0728ec1879c4ef1199814fa6ea1b7a3d7af429132093fc49

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.2.9-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0c4b016799148da1b5800f69f69c28d794f7c404e025c497f4652870c563bb01
MD5 fc966b7122fd66162f156e58b47a3bfb
BLAKE2b-256 95801b2e1a06879ab58fc482b63112cb71115f4a4d79635a6c29be4a740a537f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pynari-1.2.9-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.2.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 dba43962616e15b4653125b9887a92e9d16d5ff430bb3ddcab0eedd780d79962
MD5 8dc139884a76ac4332be8855b971522e
BLAKE2b-256 3b0cb15c231021caf06761cc92311d43b9e23f695e2099dec37851eedfb87e59

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.2.9-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 bd2711ddb1dc009f79cd304e4e10659144dbf6f830c2bdd7e34cf462cbe9237f
MD5 7233268d3501f6622aacf154b6ebcdf2
BLAKE2b-256 8d22f70710a9ba74fb58eff4ba463d50d1eff4b1b3ce3306017cc16b4b775b71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.2.9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b3b08b06f97fe8ca76b4a186eee5d8d216f4c5b9dd5917d551ac6883448b32a2
MD5 04d12aa6d4215cfa607561df35229714
BLAKE2b-256 9e6851a2611b15dc8a145cd393a83a8a05afddce8664dbff5e1ef7e5f3cb21b6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pynari-1.2.9-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.2.9-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 2df6f263f0df5fc4d70ae698af05a0860b981500afaf9301eb3d75fa0940194f
MD5 239436f6a73e1fb0ced660f870199f2f
BLAKE2b-256 4799447c198eaa03eccf30f659297fe2b10cc2f7cf70cbdd001081180098f5da

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