volkano
Pure-Python Vulkan driver interface for compute — ctypes only, lazy registry-driven, zero compiled code in the wheel.
pip install volkano
import volkano as vk
app = vk.VkApplicationInfo(sType=vk.VK_STRUCTURE_TYPE_APPLICATION_INFO,
pApplicationName=b'demo',
apiVersion=vk.VK_API_VERSION_1_0)
info = vk.VkInstanceCreateInfo(sType=vk.VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
pApplicationInfo=app.ptr)
instance = vk.VkInstance()
result = vk.vkCreateInstance(info.ref, None, instance.ref)
assert result is vk.VK_SUCCESS
count = vk.uint32()
vk.vkEnumeratePhysicalDevices(instance, count.ref, None)
print(f'{count.value} physical device(s)')
vk.vkDestroyInstance(instance, None)
Four things in there are the whole calling convention:
.ptrfor a struct field,.reffor an argument.x.ptris a real typed pointer, which is what apApplicationInfoslot holds;x.refisbyref(x), which is what a command parameter wants. Using.refin a field raisesTypeError: expected Pointer[VkApplicationInfo] instance— the one mistake everybody makes first.- Commands return the enum member, so
result is vk.VK_SUCCESSholds and a failure prints asVkResult.VK_ERROR_INITIALIZATION_FAILEDrather than as-3. - Enumerants are their group's member:
vk.VK_SUCCESSisvk.VkResult.VK_SUCCESS, not a separateintthat compares equal. - Scalars are named as cbase names them —
vk.uint32,vk.float32— and carry.ref,.ptr,.valueand.size. vk.xml's C spellings (uint32_t) are translated to these, so there is exactly one name per type.
Scope of the first release
Compute is the target, and it works end to end: instances, physical device enumeration and properties, logical devices and queues, buffers and memory requirements, descriptor sets, pipelines, command pools and submission all resolve and dispatch.
Two areas do not, and both for the same reason — vk.xml declares
their types without defining them, leaving HINSTANCE, Display,
wl_display, HANDLE and the StdVideo* family to platform and video
headers volkano does not read:
- Window-system integration.
VkWin32SurfaceCreateInfoKHR,VkXlibSurfaceCreateInfoKHR,VkWaylandSurfaceCreateInfoKHRandvkCreateWin32SurfaceKHRare unreachable, so there is no way to make a surface to present to. The swapchain types themselves are fine — it is only the surface underneath them that is missing. - Win32 external memory, semaphore and fence interop, which needs
HANDLE. - Video encode and decode, which needs the separate
vulkan_videoregistry.
That is 109 of 9 074 entries. Touching one raises AttributeError naming
the type that is missing rather than failing obscurely, and hasattr
reports them absent — so a capability probe works, and nothing else in
the registry is affected.
Two ways to use it
The module. import volkano gives you the whole Vulkan surface as
module attributes, backed by one registry built on first access:
import volkano as vk
vk.vkCreateInstance(...)
An object. volkano.registry() builds an independent registry. It
reads no environment, keeps no global state, and never writes to your
source tree — so several can coexist:
import volkano
TAG = ('https://raw.githubusercontent.com/KhronosGroup/Vulkan-Docs'
'/refs/tags/v1.4.359/xml/vk.xml')
vk = volkano.registry(library=True) # Khronos main branch
vk = volkano.registry(TAG, library=True) # or any vk.xml, by URL
The first is the second applied to two environment variables. There is only one implementation.
Configuring the module
| Variable | Meaning |
|---|---|
VOLKANO_XML |
unset — the Khronos main branch (default) |
an http(s):// URL — that vk.xml, fetched once and cached |
|
a file:// URI or a path — that file, read in place |
|
VOLKANO_LIBRARY |
unset — autodetect the Vulkan loader |
| a path — use that loader | |
none — attach no loader at all (codegen, CI) |
A source is just a URI. There is no vocabulary to learn and no
version syntax to get right: pinning a release means naming the URL of
that release's vk.xml, which is the identifier GitHub already gives
you.
VOLKANO_XML=https://raw.githubusercontent.com/KhronosGroup/Vulkan-Docs/refs/tags/v1.4.359/xml/vk.xml
That generalises where a version number wouldn't. Khronos has used
three tag-naming families — v1.4.359, v1.0.33-core,
v1.0-core+wsi-20160216 — and plain vX.Y.Z only starts at v1.1.70,
so any scheme that rebuilds a tag from a version is wrong for 89 of the
382 published tags. It also moved vk.xml from src/spec/ to xml/
between v1.1.70 and v1.2.131. A URL sidesteps both, and reaches a fork,
a mirror or an internal artifact server for free — volkano knows one
Khronos URL (the default) and nothing else about the repository.
volkano.use('https://…/vk.xml') does the same thing from code, and
takes precedence over the environment. It has to run before the first
volkano.<name> access — that access is what builds the registry — and
raises if it doesn't, rather than being silently ignored. An
environment variable remains the only way to configure a volkano that
something else imported first.
Both variables are read on first use, not at import, and only by the
module facade — registry() takes arguments and nothing else.
Remote XML is fetched into %LOCALAPPDATA%\volkano\xml (or
~/.cache/volkano/xml) the first time it is needed and never
revalidated after that, so no import past the first does network
I/O. A URI carries no evidence of whether
what it names can move — a tag URL and a branch URL are the same shape
— so rather than guess, volkano refetches only when told to:
python -m volkano update
That refetches the configured source and rewrites the .pyi stub from
it. Everything else is first-use: the XML is taken from the cache if it
is there and fetched into it if it isn't, and the stub is brought level
with whatever was built.
Notes
- The loader is opened lazily — on the first command you call, not at build and not at lookup. The entire registry, commands included, resolves and introspects on a machine with no Vulkan driver installed; only dispatch needs one.
__init__.pyiis written on first use, and stamped with the hash and URI of the XML it came from. Later imports compare that one line and stop there — the walk that regenerating costs (~1 s, all 8 000-odd entries) is paid only when the stamp disagrees: a fresh install, a changed source, or an improved generator. An unwritable target is skipped rather than retried, and every failure is swallowed; a missing or stale stub costs autocomplete and nothing else.volkano.registry()never writes it. Only the module facade syncs the stub, so a registry you construct yourself — one per source, several at once — leaves your source tree alone.- Forcing is thread-safe — racing threads share one value per key, so ctypes class identity stays consistent.
Layout
volkano— the package itself is a lazy registry of Vulkan types, structs, enums, and command thunks. Built once on first attribute access.volkano.cbase— C-ABI substrate (Pointer,Array,Struct,Handle,Mixin).volkano.lazy— the memoising thunk kernel the registry is built on.volkano.xml_source— where the XML comes from: URI resolution, fetch, cache, provenance. Knows how to fetch bytes, nothing about Vulkan's schema.volkano.xml_parser— what the XML means: the vk.xml → thunk-graph walker. Knows the schema, nothing about caching.volkano.vulkan_stdlib— the factories the thunk graph calls, plusVkRegistry.volkano.stub—.pyigeneration and thepython -m volkano updatemaintenance CLI.
Designed as a stable substrate for higher-level libraries.
Metadata
Release files for volkano 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| volkano-0.1.0.tar.gz | 93.4 kB | Without provenance | Details for volkano-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| volkano-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for volkano-0.1.0-py3-none-any.whl |
Total release size: 161.1 kB
Release files / volkano-0.1.0.tar.gz
| Download URL | volkano-0.1.0.tar.gz |
|---|---|
| Size | 93.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c32e9f3090288f33fec620eb8c2c4ee5d0b340c2823c4a9530b7275420168875
|
|
BLAKE2b-256 checksum How to use checksums |
e5434097f48e5ecdd5e88e891e0d2588ff7802b3667126f3aa31a1504f98199c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.1
|
Release files / volkano-0.1.0-py3-none-any.whl
| Download URL | volkano-0.1.0-py3-none-any.whl |
|---|---|
| Size | 67.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ae38ce2b3c01f9cae6d00db252be746d35c3c433a01b47206dec8fd91b753dd
|
|
BLAKE2b-256 checksum How to use checksums |
df54c1f8514a30fc42129075d0ea3d5ab13c5a350b568f14a5b33aa4d24ca828
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.1
|
Security for volkano 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.