improves build to also include the version into the bl_info

This commit is contained in:
Michel Fedde 2024-01-30 16:20:37 +01:00
parent 6a89168707
commit bc6734a349
3 changed files with 25 additions and 11 deletions

View file

@ -1 +1 @@
1.0.0+build.5 1.0.0+build.18

View file

@ -10,6 +10,7 @@ PROJECT_NAME = "Bake ID Mask"
CURRENT_PATH = os.path.dirname(os.path.realpath(__file__)) CURRENT_PATH = os.path.dirname(os.path.realpath(__file__))
SOURCE_PATH = os.path.join(CURRENT_PATH, "../src") SOURCE_PATH = os.path.join(CURRENT_PATH, "../src")
INIT_FILE_PATH = os.path.join(SOURCE_PATH, "__init__.py")
TARGET_PATH = os.path.join(CURRENT_PATH, '../dist') TARGET_PATH = os.path.join(CURRENT_PATH, '../dist')
if __name__ == "__main__": if __name__ == "__main__":
@ -22,6 +23,14 @@ if __name__ == "__main__":
versioning.save_version(nextVersion) versioning.save_version(nextVersion)
filename = os.path.join(TARGET_PATH, ZIP_FILE_NAME.format(version=nextVersion.__str__())) filename = os.path.join(TARGET_PATH, ZIP_FILE_NAME.format(version=nextVersion.__str__()))
original_init_content = ''
with open(INIT_FILE_PATH, 'r') as f:
original_init_content = f.read()
version_insert = original_init_content.replace('# !VERSION', '"version": ({}, {}, {}),'.format(nextVersion.major, nextVersion.minor, nextVersion.patch))
with open(INIT_FILE_PATH, 'w') as f:
f.write(version_insert)
with zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED) as zip: with zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED) as zip:
for (root, dirs, files) in os.walk(SOURCE_PATH): for (root, dirs, files) in os.walk(SOURCE_PATH):
if '__pycache__' in dirs: if '__pycache__' in dirs:
@ -38,3 +47,6 @@ if __name__ == "__main__":
os.path.join(root, file), os.path.join(root, file),
os.path.join(PROJECT_NAME, relativePath) os.path.join(PROJECT_NAME, relativePath)
) )
with open(INIT_FILE_PATH, 'w') as f:
f.write(original_init_content)

View file

@ -1,3 +1,12 @@
bl_info = {
"name": "Bake ID Mask",
"author": "iedSoftworks",
"description": "",
# !VERSION
"blender": (2, 80, 0),
"category": "Object"
}
import bpy import bpy
from . panels.panel_options import BakeToIDOptionsPanel from . panels.panel_options import BakeToIDOptionsPanel
@ -7,14 +16,6 @@ from . panels.panel import BakeToIDMapPanel
from . panels.panel_info import BakeToIDInfoPanel from . panels.panel_info import BakeToIDInfoPanel
from . properties.bake_to_id import BakeToIDProperties from . properties.bake_to_id import BakeToIDProperties
bl_info = {
"name": "Bake ID Mask",
"author": "iedSoftworks",
"description": "",
"blender": (2, 80, 0),
"category": "Object"
}
classes = ( classes = (
BakeToIDMapOperator, BakeToIDMapOperator,
BakeToIDMapPanel, BakeToIDMapPanel,
@ -24,13 +25,14 @@ classes = (
BakeToIDProperties, BakeToIDProperties,
) )
def register():
def register():
for cls in classes: for cls in classes:
bpy.utils.register_class(cls) bpy.utils.register_class(cls)
setattr(bpy.types.Scene, 'bake_to_id_props', bpy.props.PointerProperty(type=BakeToIDProperties)) setattr(bpy.types.Scene, 'bake_to_id_props', bpy.props.PointerProperty(type=BakeToIDProperties))
def unregister(): def unregister():
for cls in reversed(classes): for cls in reversed(classes):
bpy.utils.unregister_class(cls) bpy.utils.unregister_class(cls)