Skip to content

Commit 31e44bc

Browse files
committed
feat: create manifest, fix typo
1 parent f966929 commit 31e44bc

File tree

6 files changed

+59
-3
lines changed

6 files changed

+59
-3
lines changed

compositor/operator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ def execute(self, context):
241241
self._create_register_func()
242242
self._create_unregister_func()
243243
self._create_main_func()
244+
if bpy.app.version >= (4, 2, 0):
245+
self._create_manifest()
244246
else:
245247
context.window_manager.clipboard = self._file.getvalue()
246248

geometry/operator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ def execute(self, context):
211211
self._create_register_func()
212212
self._create_unregister_func()
213213
self._create_main_func()
214+
if bpy.app.version >= (4, 2, 0):
215+
self._create_manifest()
214216
else:
215217
context.window_manager.clipboard = self._file.getvalue()
216218
self._file.close()

ntp_operator.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def _setup_options(self, options: NTPOptions) -> bool:
132132
self._author_name = options.author_name
133133
self._version = options.version
134134
self._location = options.location
135+
self._license = options.license
135136
self._category = options.category
136137
self._custom_category = options.custom_category
137138
if options.menu_id in dir(bpy.types):
@@ -176,11 +177,12 @@ def _create_header(self, name: str) -> None:
176177
"""
177178

178179
self._write("bl_info = {", "")
180+
self._name = name
179181
if self._name_override and self._name_override != "":
180-
name = self._name_override
181-
self._write(f"\t\"name\" : {str_to_py_str(name)},", "")
182+
self._name = self._name_override
183+
self._write(f"\t\"name\" : {str_to_py_str(self._name)},", "")
182184
if self._description and self._description != "":
183-
self.write(f"\t\"description\" : {str_to_py_str(self._description)}," "")
185+
self._write(f"\t\"description\" : {str_to_py_str(self._description)}," "")
184186
self._write(f"\t\"author\" : {str_to_py_str(self._author_name)},", "")
185187
self._write(f"\t\"version\" : {vec3_to_py_str(self._version)},", "")
186188
self._write(f"\t\"blender\" : {bpy.app.version},", "")
@@ -204,6 +206,7 @@ def _init_operator(self, idname: str, label: str) -> None:
204206
idname (str): name for the operator
205207
label (str): appearence inside Blender
206208
"""
209+
self._idname = idname
207210
self._write(f"class {self._class_name}(bpy.types.Operator):", "")
208211
self._write(f"\tbl_idname = \"node.{idname}\"", "")
209212
self._write(f"\tbl_label = {str_to_py_str(label)}", "")
@@ -1375,6 +1378,25 @@ def _create_main_func(self) -> None:
13751378
self._write("if __name__ == \"__main__\":", "")
13761379
self._write("register()", "\t")
13771380

1381+
if bpy.app.version >= (4, 2, 0):
1382+
def _create_manifest(self) -> None:
1383+
manifest = open(f"{self._addon_dir}/blender_manifest.toml", "w")
1384+
manifest.write("schema_version = \"1.0.0\"\n\n")
1385+
manifest.write(f"id = {str_to_py_str(self._idname)}\n")
1386+
1387+
manifest.write(f"version = {version_to_manifest_str(self._version)}\n")
1388+
manifest.write(f"name = {str_to_py_str(self._name)}\n")
1389+
manifest.write(f"tagline = {str_to_py_str(self._description)}\n")
1390+
manifest.write(f"maintainer = {str_to_py_str(self._author_name)}\n")
1391+
manifest.write("type = \"add-on\"\n")
1392+
manifest.write(f"blender_version_min = {version_to_manifest_str(bpy.app.version)}\n")
1393+
if self._license != 'OTHER':
1394+
manifest.write(f"license = [{str_to_py_str(self._license)}]\n")
1395+
else:
1396+
self.report({'WARNING'}, "No license selected. Please add a license to the manifest file")
1397+
1398+
manifest.close()
1399+
13781400
def _zip_addon(self) -> None:
13791401
"""
13801402
Zips up the addon and removes the directory

options.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class NTPOptions(bpy.types.PropertyGroup):
3535
description="Generate necessary import statements",
3636
default = True
3737
)
38+
3839
# Addon properties
3940
dir_path : bpy.props.StringProperty(
4041
name = "Save Location",
@@ -75,6 +76,26 @@ class NTPOptions(bpy.types.PropertyGroup):
7576
"hovering over the desired menu",
7677
default="NODE_MT_add"
7778
)
79+
license: bpy.props.EnumProperty(
80+
name="License",
81+
items = [
82+
('SPDX:GPL-2.0-or-later', "GNU General Public License v2.0 or later", ""),
83+
('SPDX:GPL-3.0-or-later', "GNU General Public License v3.0 or later", ""),
84+
('SPDX:LGPL-2.1-or-later', "GNU Lesser General Public License v2.1 or later", ""),
85+
('SPDX:LGPL-3.0-or-later', "GNU Lesser General Public License v3.0 or later", ""),
86+
('SPDX:BSD-1-Clause', "BSD 1-Clause \"Simplified\" License", ""),
87+
('SPDX:BSD-2-Clause', "BSD 2-Clause \"Simplified\" License", ""),
88+
('SPDX:BSD-3-Clause', "BSD 3-Clause “New” or “Revised” License", ""),
89+
('SPDX:BSL-1.0', "Boost Software License 1.0", ""),
90+
('SPDX:MIT', "MIT License", ""),
91+
('SPDX:MIT-0', "MIT No Attribution", ""),
92+
('SPDX:MPL-2.0', "Mozilla Public License 2.0", ""),
93+
('SPDX:Pixar', "Pixar License", ""),
94+
('SPDX:Zlib', "Zlib License", ""),
95+
('OTHER', "Other", "")
96+
],
97+
default = 'OTHER'
98+
)
7899
category: bpy.props.EnumProperty(
79100
name = "Category",
80101
items = [
@@ -117,6 +138,7 @@ class NTPOptions(bpy.types.PropertyGroup):
117138
description="Custom category",
118139
default = ""
119140
)
141+
120142
class NTPOptionsPanel(bpy.types.Panel):
121143
bl_label = "Options"
122144
bl_idname = "NODE_PT_ntp_options"
@@ -149,10 +171,13 @@ def draw(self, context):
149171
elif ntp_options.mode == 'ADDON':
150172
addon_options = [
151173
"dir_path",
174+
"name_override",
175+
"description",
152176
"author_name",
153177
"version",
154178
"location",
155179
"menu_id",
180+
"license",
156181
"category"
157182
]
158183
option_list += addon_options

shader/operator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ def execute(self, context):
176176
self._create_register_func()
177177
self._create_unregister_func()
178178
self._create_main_func()
179+
if bpy.app.version >= (4, 2, 0):
180+
self._create_manifest()
179181
else:
180182
context.window_manager.clipboard = self._file.getvalue()
181183

utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ def vec3_to_py_str(vec3) -> str:
8888
"""
8989
return f"({vec3[0]}, {vec3[1]}, {vec3[2]})"
9090

91+
def version_to_manifest_str(version) -> str:
92+
return f"\"{version[0]}.{version[1]}.{version[2]}\""
93+
9194
def vec4_to_py_str(vec4) -> str:
9295
"""
9396
Converts a 4D vector to a string usable by the add-on

0 commit comments

Comments
 (0)