nodebpy 520.6.0__tar.gz → 520.8.0__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.
- {nodebpy-520.6.0 → nodebpy-520.8.0}/PKG-INFO +1 -1
- {nodebpy-520.6.0 → nodebpy-520.8.0}/pyproject.toml +1 -1
- nodebpy-520.8.0/src/nodebpy/assets/__init__.py +20 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/assets/__main__.py +16 -2
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/assets/_codegen.py +52 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/builder/node.py +4 -0
- nodebpy-520.6.0/src/nodebpy/assets/__init__.py +0 -17
- {nodebpy-520.6.0 → nodebpy-520.8.0}/README.md +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/__init__.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/builder/__init__.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/builder/_registry.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/builder/_utils.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/builder/accessor.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/builder/arrange.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/builder/asset.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/builder/items.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/builder/mixins.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/builder/socket.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/builder/tree.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/export/__init__.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/export/codegen.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/export/diagram.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/export/web_render.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/lib/nodearrange/__init__.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/lib/nodearrange/arrange/__init__.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/lib/nodearrange/arrange/graph.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/lib/nodearrange/arrange/ordering.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/lib/nodearrange/arrange/ranking.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/lib/nodearrange/arrange/realize.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/lib/nodearrange/arrange/stacking.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/lib/nodearrange/arrange/structs.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/lib/nodearrange/arrange/sugiyama.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/lib/nodearrange/arrange/x_coords.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/lib/nodearrange/arrange/y_coords.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/lib/nodearrange/config.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/lib/nodearrange/utils.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/__init__.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/_mixins.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/compositor/__init__.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/compositor/assets.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/compositor/color.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/compositor/converter.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/compositor/distort.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/compositor/filter.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/compositor/group.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/compositor/input.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/compositor/interface.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/compositor/manual.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/compositor/matte.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/compositor/output.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/compositor/vector.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/geometry/__init__.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/geometry/assets.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/geometry/attribute.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/geometry/color.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/geometry/converter.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/geometry/geometry.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/geometry/grid.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/geometry/group.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/geometry/groups.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/geometry/input.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/geometry/interface.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/geometry/manual.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/geometry/output.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/geometry/texture.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/geometry/utilities.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/geometry/vector.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/geometry/zone.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/shader/__init__.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/shader/assets.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/shader/color.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/shader/converter.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/shader/grid.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/shader/group.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/shader/input.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/shader/manual.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/shader/output.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/shader/script.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/shader/shader.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/shader/texture.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/nodes/shader/vector.py +0 -0
- {nodebpy-520.6.0 → nodebpy-520.8.0}/src/nodebpy/types.py +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Typed APIs for node-group assets.
|
|
2
|
+
|
|
3
|
+
``generate_asset_api`` builds typed :class:`~nodebpy.builder.AssetNodeGroup`
|
|
4
|
+
classes for the node groups in a ``.blend`` asset library into a single module;
|
|
5
|
+
``generate_asset_modules`` splits them into one module per tree type
|
|
6
|
+
(``geometry.py`` / ``shader.py`` / ``compositor.py``). The bundled-essentials
|
|
7
|
+
APIs generated for nodebpy itself live in ``nodebpy.nodes.{geometry,shader,
|
|
8
|
+
compositor}.assets`` and are re-exported alongside the built-in nodes.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from ..builder import AssetLibrary, BundledLibrary, PackageLibrary
|
|
12
|
+
from ._codegen import generate_asset_api, generate_asset_modules
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"generate_asset_api",
|
|
16
|
+
"generate_asset_modules",
|
|
17
|
+
"AssetLibrary",
|
|
18
|
+
"BundledLibrary",
|
|
19
|
+
"PackageLibrary",
|
|
20
|
+
]
|
|
@@ -14,7 +14,7 @@ import os
|
|
|
14
14
|
from pathlib import Path
|
|
15
15
|
|
|
16
16
|
from ..builder import BundledLibrary, PackageLibrary
|
|
17
|
-
from ._codegen import generate_asset_api
|
|
17
|
+
from ._codegen import generate_asset_api, generate_asset_modules
|
|
18
18
|
|
|
19
19
|
# Bundled libraries shipped with Blender, grouped by output module. Each library
|
|
20
20
|
# holds node groups of a single tree type.
|
|
@@ -70,7 +70,11 @@ def parse_args() -> argparse.Namespace:
|
|
|
70
70
|
"-o",
|
|
71
71
|
dest="output",
|
|
72
72
|
type=Path,
|
|
73
|
-
help=
|
|
73
|
+
help=(
|
|
74
|
+
"Where to write the generated module(s). A .py path writes a single "
|
|
75
|
+
"module; a directory writes one module per tree type "
|
|
76
|
+
"(geometry.py / shader.py / compositor.py)."
|
|
77
|
+
),
|
|
74
78
|
)
|
|
75
79
|
parser.add_argument(
|
|
76
80
|
"--nodebpy-pkg",
|
|
@@ -98,6 +102,16 @@ def main() -> None: # pragma: no cover - CLI wrapper
|
|
|
98
102
|
# directory (``__file__``), so express the .blend relative to the output
|
|
99
103
|
# module — not the CWD the command happened to run from.
|
|
100
104
|
blend = args.blend_file.resolve()
|
|
105
|
+
if output.suffix != ".py":
|
|
106
|
+
# Directory output: one module per tree type.
|
|
107
|
+
out_dir = output.resolve()
|
|
108
|
+
relative = Path(os.path.relpath(blend, out_dir)).as_posix()
|
|
109
|
+
generate_asset_modules(
|
|
110
|
+
[PackageLibrary(str(out_dir / "_anchor.py"), relative)],
|
|
111
|
+
output,
|
|
112
|
+
nodebpy_pkg=args.nodebpy_pkg,
|
|
113
|
+
)
|
|
114
|
+
return
|
|
101
115
|
relative = Path(os.path.relpath(blend, output.resolve().parent)).as_posix()
|
|
102
116
|
generate_asset_api(
|
|
103
117
|
[PackageLibrary(str(output), relative)],
|
|
@@ -50,6 +50,14 @@ _SOCKET_TYPES: dict[str, tuple[str, str]] = {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
|
|
53
|
+
# Tree type → module name used when splitting generated output per tree type.
|
|
54
|
+
_TREE_MODULES: dict[str, str] = {
|
|
55
|
+
"GeometryNodeTree": "geometry",
|
|
56
|
+
"ShaderNodeTree": "shader",
|
|
57
|
+
"CompositorNodeTree": "compositor",
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
53
61
|
def _socket_types(bl_socket_type: str) -> tuple[str, str]:
|
|
54
62
|
for key, value in _SOCKET_TYPES.items():
|
|
55
63
|
if key in bl_socket_type:
|
|
@@ -329,3 +337,47 @@ def generate_asset_api(
|
|
|
329
337
|
_render_module(classes, nodebpy_pkg=nodebpy_pkg), encoding="utf-8"
|
|
330
338
|
)
|
|
331
339
|
return [c.class_name for c in classes]
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
def generate_asset_modules(
|
|
343
|
+
libraries: AssetLibrary | Sequence[AssetLibrary],
|
|
344
|
+
output_dir: str | Path,
|
|
345
|
+
*,
|
|
346
|
+
names: set[str] | None = None,
|
|
347
|
+
nodebpy_pkg: str = "nodebpy",
|
|
348
|
+
) -> dict[str, list[str]]:
|
|
349
|
+
"""Generate typed asset classes for ``libraries``, split into one module per
|
|
350
|
+
tree type inside ``output_dir``.
|
|
351
|
+
|
|
352
|
+
Writes ``geometry.py``, ``shader.py`` and/or ``compositor.py`` — one module
|
|
353
|
+
for each tree type that has assets in the libraries (no file for the
|
|
354
|
+
others). Asset names repeat across editors (a geometry *and* a compositor
|
|
355
|
+
"Combine Spherical" both exist), so splitting keeps the generated class
|
|
356
|
+
names collision-free where a single :func:`generate_asset_api` module would
|
|
357
|
+
silently shadow one with the other.
|
|
358
|
+
|
|
359
|
+
Parameters are as for :func:`generate_asset_api`, except ``output_dir`` is
|
|
360
|
+
the directory to write the modules into (created if needed).
|
|
361
|
+
|
|
362
|
+
Returns a mapping of module name (``"geometry"`` / ``"shader"`` /
|
|
363
|
+
``"compositor"``) to the class names written to it.
|
|
364
|
+
"""
|
|
365
|
+
if isinstance(libraries, AssetLibrary):
|
|
366
|
+
libraries = [libraries]
|
|
367
|
+
|
|
368
|
+
classes: list[_AssetClass] = []
|
|
369
|
+
for library in libraries:
|
|
370
|
+
classes.extend(_introspect(library, names))
|
|
371
|
+
|
|
372
|
+
output_dir = Path(output_dir)
|
|
373
|
+
output_dir.mkdir(parents=True, exist_ok=True)
|
|
374
|
+
written: dict[str, list[str]] = {}
|
|
375
|
+
for tree_idname, module in _TREE_MODULES.items():
|
|
376
|
+
tree_classes = [c for c in classes if c.tree_idname == tree_idname]
|
|
377
|
+
if not tree_classes:
|
|
378
|
+
continue
|
|
379
|
+
(output_dir / f"{module}.py").write_text(
|
|
380
|
+
_render_module(tree_classes, nodebpy_pkg=nodebpy_pkg), encoding="utf-8"
|
|
381
|
+
)
|
|
382
|
+
written[module] = [c.class_name for c in tree_classes]
|
|
383
|
+
return written
|
|
@@ -387,6 +387,10 @@ class NodeGroupBuilder(BaseNode, ABC, Generic[_T]):
|
|
|
387
387
|
self._establish_links(**kwargs)
|
|
388
388
|
if named_links:
|
|
389
389
|
self._establish_named_links(named_links)
|
|
390
|
+
# Name the node after its tree (Blender deduplicates with a
|
|
391
|
+
# ``.001``-style suffix), matching how group assets added from the
|
|
392
|
+
# Add menu are named, instead of Blender's default ``Group``.
|
|
393
|
+
self.node.name = self.node_tree.name
|
|
390
394
|
|
|
391
395
|
@property
|
|
392
396
|
@abstractmethod
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"""Typed APIs for node-group assets.
|
|
2
|
-
|
|
3
|
-
``generate_asset_api`` builds typed :class:`~nodebpy.builder.AssetNodeGroup`
|
|
4
|
-
classes for the node groups in a ``.blend`` asset library. The bundled-essentials
|
|
5
|
-
APIs generated for nodebpy itself live alongside this module as
|
|
6
|
-
``nodebpy.assets.geometry`` / ``.shader`` / ``.compositor``.
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
from ..builder import AssetLibrary, BundledLibrary, PackageLibrary
|
|
10
|
-
from ._codegen import generate_asset_api
|
|
11
|
-
|
|
12
|
-
__all__ = [
|
|
13
|
-
"generate_asset_api",
|
|
14
|
-
"AssetLibrary",
|
|
15
|
-
"BundledLibrary",
|
|
16
|
-
"PackageLibrary",
|
|
17
|
-
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|