vulkan-object 1.4.319__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,18 @@
1
+ Copyright 2015-2025 The Khronos Group Inc.
2
+
3
+ Files in this repository fall under one of these licenses:
4
+
5
+ - `Apache-2.0`
6
+ - `MIT`
7
+
8
+ Note: With the exception of `parse_dependency.py` the files using `MIT` license
9
+ also fall under `Apache-2.0`. Example:
10
+
11
+ ```
12
+ SPDX-License-Identifier: Apache-2.0 OR MIT
13
+ ```
14
+
15
+ Full license text of these licenses is available at:
16
+
17
+ * Apache-2.0: https://opensource.org/licenses/Apache-2.0
18
+ * MIT: https://opensource.org/licenses/MIT
@@ -0,0 +1,3 @@
1
+ # This line finds vk.xml within your package's source directory
2
+ # and ensures it gets included in the distribution.
3
+ include src/vulkan_object/vk.xml
@@ -0,0 +1,49 @@
1
+ Metadata-Version: 2.4
2
+ Name: vulkan-object
3
+ Version: 1.4.319
4
+ Summary: An easy-to-use Python wrapper for the Vulkan API registry.
5
+ Author-email: Spencer Fricke <spencer@lunarg.com>
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Operating System :: OS Independent
8
+ Requires-Python: >=3.7
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Dynamic: license-file
12
+
13
+ # Vulkan Object Python Package
14
+
15
+ Parsing the [`vk.xml`](https://github.com/KhronosGroup/Vulkan-Headers/blob/main/registry/vk.xml) in Vulkan is easy, processing it is hard!
16
+
17
+ It is very easy for people to mess up trying to process the `vk.xml` file, so we created `VulkanObject`
18
+
19
+ `VulkanObject` is just a python dataclass that is defined in [Vulkan-Headers/registry/vulkan_object.py](https://github.com/KhronosGroup/Vulkan-Headers/blob/main/registry/vulkan_object.py). It uses the [reg.py](https://github.com/KhronosGroup/Vulkan-Headers/blob/main/registry/reg.py) framework that the Vulkan Spec is generated with in order to populate the `VulkanObject` data structure.
20
+
21
+ This python package makes it **super easy** to get going.
22
+
23
+ ```bash
24
+ pip install vulkan-object
25
+ ```
26
+
27
+ ```python
28
+ from vulkan_object import get_vulkan_object, VulkanObject
29
+
30
+ vk = get_vulkan_object()
31
+
32
+ print(f'There are now {len([x for x in vk.extensions.values()])} extensions in Vulkan')
33
+
34
+ print(f'Built with the {vk.headerVersion} headers')
35
+ ```
36
+
37
+ ## Updating this repo
38
+
39
+ run `python update.py /path/to/Vulkan-Headers` and it will do everything to sync this package up with the new headers
40
+
41
+ ## Testing locally
42
+
43
+ To test, grab the repo and go `pip install -e .` in the root directory and will simulate grabbing it from `pip`
44
+
45
+ ## What is this package/repo actually?
46
+
47
+ The Vulkan-Headers contain a bunch of scripts in the `Vulkan-Headers/registry/` directory that repos can use to help generate code.
48
+
49
+ The main issue is the delivery mechanism for python projects. This package/repo just grabs the Vulkan-Headers scripts (**not** the C header files themselves!) and make it easier to integrate with projects.
@@ -0,0 +1,37 @@
1
+ # Vulkan Object Python Package
2
+
3
+ Parsing the [`vk.xml`](https://github.com/KhronosGroup/Vulkan-Headers/blob/main/registry/vk.xml) in Vulkan is easy, processing it is hard!
4
+
5
+ It is very easy for people to mess up trying to process the `vk.xml` file, so we created `VulkanObject`
6
+
7
+ `VulkanObject` is just a python dataclass that is defined in [Vulkan-Headers/registry/vulkan_object.py](https://github.com/KhronosGroup/Vulkan-Headers/blob/main/registry/vulkan_object.py). It uses the [reg.py](https://github.com/KhronosGroup/Vulkan-Headers/blob/main/registry/reg.py) framework that the Vulkan Spec is generated with in order to populate the `VulkanObject` data structure.
8
+
9
+ This python package makes it **super easy** to get going.
10
+
11
+ ```bash
12
+ pip install vulkan-object
13
+ ```
14
+
15
+ ```python
16
+ from vulkan_object import get_vulkan_object, VulkanObject
17
+
18
+ vk = get_vulkan_object()
19
+
20
+ print(f'There are now {len([x for x in vk.extensions.values()])} extensions in Vulkan')
21
+
22
+ print(f'Built with the {vk.headerVersion} headers')
23
+ ```
24
+
25
+ ## Updating this repo
26
+
27
+ run `python update.py /path/to/Vulkan-Headers` and it will do everything to sync this package up with the new headers
28
+
29
+ ## Testing locally
30
+
31
+ To test, grab the repo and go `pip install -e .` in the root directory and will simulate grabbing it from `pip`
32
+
33
+ ## What is this package/repo actually?
34
+
35
+ The Vulkan-Headers contain a bunch of scripts in the `Vulkan-Headers/registry/` directory that repos can use to help generate code.
36
+
37
+ The main issue is the delivery mechanism for python projects. This package/repo just grabs the Vulkan-Headers scripts (**not** the C header files themselves!) and make it easier to integrate with projects.
@@ -0,0 +1,25 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "vulkan-object"
7
+ version = "1.4.319"
8
+ authors = [
9
+ { name="Spencer Fricke", email="spencer@lunarg.com" },
10
+ ]
11
+ description = "An easy-to-use Python wrapper for the Vulkan API registry."
12
+ readme = "README.md"
13
+ requires-python = ">=3.7"
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "Operating System :: OS Independent",
17
+ ]
18
+
19
+ [tool.setuptools.packages.find]
20
+ where = ["src"]
21
+
22
+ [tool.setuptools]
23
+ # This flag is crucial! It tells setuptools to look at MANIFEST.in
24
+ # and include non-Python files like vk.xml in the final package.
25
+ include-package-data = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,81 @@
1
+ import functools
2
+ import importlib.resources
3
+ import tempfile
4
+ import os
5
+ from xml.etree import ElementTree
6
+ from typing import Any
7
+
8
+ # Use relative imports to access sibling modules
9
+ from .reg import Registry
10
+ from .base_generator import BaseGenerator, BaseGeneratorOptions, SetOutputDirectory, SetOutputFileName, SetTargetApiName, SetMergedApiNames
11
+ from .vulkan_object import VulkanObject
12
+
13
+ # Define the public API for your package
14
+ __all__ = [
15
+ 'get_vulkan_object',
16
+ 'VulkanObject' # Exposing the class is good for type-hinting
17
+ ]
18
+
19
+ # Create the simplified, cached public function
20
+ @functools.lru_cache(maxsize=1)
21
+ def get_vulkan_object(alternative_xml: str = None) -> VulkanObject:
22
+ """
23
+ Parses the bundled Vulkan registry (vk.xml) and returns the populated
24
+ VulkanObject.
25
+
26
+ This function encapsulates all the setup logic. The result is cached,
27
+ so subsequent calls are instantaneous.
28
+
29
+ Args:
30
+ api_name: The API name to parse from the registry, defaults to 'vulkan'.
31
+ alternative_xml: Supply a full path to a different vk.xml (used for testing future extensions)
32
+
33
+ Returns:
34
+ An initialized VulkanObject instance providing access to the
35
+ Vulkan API registry data.
36
+ """
37
+ # This dummy generator class is required by the reg.py interface.
38
+ # We don't need it to do anything, as we just want the parsed data object.
39
+ class _InternalGenerator(BaseGenerator):
40
+ def __init__(self, *args, **kwargs):
41
+ super().__init__(*args, **kwargs)
42
+
43
+ def generate(self):
44
+ # This method is called by reg.apiGen() but we don't need to
45
+ # generate any files, so we just pass. The real goal is to
46
+ # populate self.vk (the VulkanObject).
47
+ pass
48
+
49
+ # The original script required setting an output directory, even if
50
+ # it's not used. We'll use a temporary one that cleans itself up.
51
+ with tempfile.TemporaryDirectory() as output_dir:
52
+ SetOutputDirectory(output_dir)
53
+ SetOutputFileName("unused.txt")
54
+ # TODO - Make a get_vulkan_sc_object() or pass this in as a parameter
55
+ SetTargetApiName('vulkan')
56
+ SetMergedApiNames(None)
57
+
58
+ # Initialize the generator and the registry machinery
59
+ generator = _InternalGenerator()
60
+ base_options = BaseGeneratorOptions()
61
+ reg = Registry(generator, base_options)
62
+
63
+ if alternative_xml:
64
+ if not os.path.isfile(alternative_xml):
65
+ raise FileNotFoundError(f"The provided alternative XML file does not exist or is not a file: {alternative_xml}")
66
+ tree = ElementTree.parse(alternative_xml)
67
+ reg.loadElementTree(tree)
68
+ else:
69
+ # Reliably find and parse vk.xml
70
+ try:
71
+ with importlib.resources.path('vulkan_object', 'vk.xml') as xml_path:
72
+ tree = ElementTree.parse(xml_path)
73
+ reg.loadElementTree(tree)
74
+ except FileNotFoundError:
75
+ raise RuntimeError("Could not find the bundled vk.xml - something has gone wrong with packaging.")
76
+
77
+ # This invokes reg.py and will populate _InternalGenerator
78
+ reg.apiGen()
79
+
80
+ return generator.vk
81
+
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env python3 -i
2
+ #
3
+ # Copyright 2021-2025 The Khronos Group Inc.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ # Generic alias for working group-specific API conventions interface.
7
+
8
+ # This import should be changed at the repository / working group level to
9
+ # specify the correct API's conventions.
10
+
11
+
12
+ import os
13
+
14
+ defaultAPI = 'vulkan'
15
+
16
+ VulkanAPI = os.getenv('VULKAN_API', default=defaultAPI)
17
+
18
+ if VulkanAPI == 'vulkansc':
19
+ from .vkconventions import VulkanSCConventions as APIConventions
20
+ else:
21
+ from .vkconventions import VulkanConventions as APIConventions