fix: fix various trivial issues

- update blender_manifest.toml to the latest version and fix the issues raised by blender when packaging.
- use blender do packaging work. remove redist.py because blender_manifest.toml has gitignore like filter feature when packaging.
- update document about installing, configurating, building plugin for blender 4.2.
- update a document image for blender 4.2.
This commit is contained in:
2024-07-19 15:25:38 +08:00
parent 209d212287
commit 427bad4f6b
7 changed files with 69 additions and 180 deletions

View File

@ -8,32 +8,25 @@ schema_version = "1.0.0"
id = "bbp_ng"
version = "4.0.0"
name = "Ballance Blender Plugin"
tagline = "The specialized add-on served for creating custom game map in Ballance game"
tagline = "The specialized add-on served for creating game map of Ballance"
maintainer = "yyc12345 <yyc12321@outlook.com>"
# Supported types: "add-on", "theme"
type = "add-on"
# Optional: add-ons can list which resources they will require:
# * "files" (for access of any filesystem operations)
# * "network" (for internet access)
# * "clipboard" (to read and/or write the system clipboard)
# * "camera" (to capture photos and videos)
# * "microphone" (to capture audio)
permissions = ["files"]
# Optional link to documentation, support, source files, etc
website = "https://github.com/yyc12345/BallanceBlenderHelper"
# Optional list defined by Blender and server, see:
# https://docs.blender.org/manual/en/dev/extensions/tags.html
# https://docs.blender.org/manual/en/dev/advanced/extensions/tags.html
tags = ["Object", "Mesh", "UV", "Import-Export"]
blender_version_min = "4.2.0"
# Optional: maximum supported Blender version
# # Optional: Blender version that the extension does not support, earlier versions are supported.
# # This can be omitted and defined later on the extensions platform if an issue is found.
# blender_version_max = "5.1.0"
# License conforming to https://spdx.org/licenses/ (use "SPDX: prefix)
# https://docs.blender.org/manual/en/dev/extensions/licenses.html
# https://docs.blender.org/manual/en/dev/advanced/extensions/licenses.html
license = [
"SPDX:GPL-3.0-or-later",
]
@ -43,13 +36,46 @@ license = [
# "1998 Company Name",
# ]
# Optional list of supported platforms. If ommitted, the extension will be available in all operating systems.
platforms = ["windows-amd64", "windows-x64", "linux-x86_64", "linux-x64"]
# Supported platforms: "windows-amd64", "macos-arm64", "linux-x86_64", "windows-arm64", "macos-x86_64"
# Optional list of supported platforms. If omitted, the extension will be available in all operating systems.
platforms = ["windows-x64", "linux-x64"]
# Supported platforms: "windows-x64", "macos-arm64", "linux-x64", "windows-arm64", "macos-x64"
# Optional: bundle 3rd party Python modules.
# https://docs.blender.org/manual/en/dev/extensions/python_wheels.html
# https://docs.blender.org/manual/en/dev/advanced/extensions/python_wheels.html
# wheels = [
# "./wheels/hexdump-3.3-py3-none-any.whl",
# "./wheels/jsmin-3.0.1-py3-none-any.whl"
# ]
# "./wheels/jsmin-3.0.1-py3-none-any.whl",
# ]
# Optional: add-ons can list which resources they will require:
# * files (for access of any filesystem operations)
# * network (for internet access)
# * clipboard (to read and/or write the system clipboard)
# * camera (to capture photos and videos)
# * microphone (to capture audio)
#
# If using network, remember to also check `bpy.app.online_access`
# https://docs.blender.org/manual/en/dev/advanced/extensions/addons.html#internet-access
#
# For each permission it is important to also specify the reason why it is required.
# Keep this a single short sentence without a period (.) at the end.
# For longer explanations use the documentation or detail page.
[permissions]
# network = "Need to sync motion-capture data to server"
files = "Import/export Virtools file from/to disk"
# clipboard = "Copy and paste bone transforms"
# Optional: build settings.
# https://docs.blender.org/manual/en/dev/advanced/extensions/command_line_arguments.html#command-line-args-extension-build
[build]
paths_exclude_pattern = [
"__pycache__/", # Python runtime cache
".style.yapf", # Python code style
"*.gitkeep", # Git directory keeper
".gitignore", # Git Ignore File
"*.md", # Useless document.
"/raw_jsons", # Raw JSONs.
"/raw_icons", # Raw Icons.
"/tools", # Assistant tools.
]

View File

@ -63,84 +63,3 @@ def common_file_migrator(
dst_file: str = relative_to_folder(src_file, from_folder, to_folder)
# call handler
fct_proc_file(src_file, dst_file)
def conditional_file_copy(
from_folder: str, to_folder: str,
only_copy: tuple[str, ...] | None = None,
ignore_copy: tuple[str, ...] | None = None,
recursively: bool = False) -> None:
"""
The enhanced file tree copy function used in redist script.
The name of file or folder will be checked by `only_copy` first,
it it decide this file or folder should be copied, we then check whether
it is in `ignore_copy`.
@param from_folder[in] The folder need to be redist.
@param to_folder[in] The folder will be placed redist files.
@param only_copy[in] An Unix style pathname pattern tuple to instruct which files or folders should be copied,
or None if we want to copy every files and folders.
@param ignore_copy[in] An Unix style pathname pattern tuple to instruct which files or folders should not be copied,
or None if we want to copy every files and folders.
@param recursively[in] Whether recursively copy sub-folders and their files.
"""
# build a helper functions
def is_need_copy(checked_filename: str) -> bool:
# if only_copy enabled, check it.
# if no only_copy, pass the check because file should be copied in default.
if only_copy is not None:
for only_copy_item in only_copy:
# matched, should copy it, break this for syntax
if fnmatch.fnmatch(checked_filename, only_copy_item):
break
else:
# no matched item, this entry should not be copied.
return False
if ignore_copy is not None:
# check whether given name is in ignore_copy
for ignore_copy_item in ignore_copy:
# matched, should not be copied
if fnmatch.fnmatch(checked_filename, only_copy_item):
return False
# no matched, copy it
return True
else:
# no ignore_copy, directly copy it
return True
# iterate from_folder folder
for root, dirs, files in os.walk(from_folder, topdown = True):
# create self
src_self: str = root
dst_self: str = relative_to_folder(src_self, from_folder, to_folder)
print(f'Creating: {src_self} -> {dst_self}')
os.makedirs(dst_self, exist_ok=True)
# iterate files
for name in files:
# get source file path
src_file: str = os.path.join(root, name)
# check whether copy it
if not is_need_copy(src_file):
continue
# build dst path and copy it
dst_file: str = relative_to_folder(src_file, from_folder, to_folder)
print(f'Copying: {src_file} -> {dst_file}')
shutil.copy(src_file, dst_file)
# iterate folders when recursively flag enabled
# if recursively:
# for name in dirs:
# # get source folder path
# src_folder: str = os.path.join(root, name)
# # build dst path and create it
# dst_folder: str = relative_to_folder(src_folder, from_folder, to_folder)
# print(f'Copying: {src_folder} -> {dst_folder}')
# os.makedirs(dst_folder, exist_ok=True)
# if we don't have recursively flag,
# we should exit at the end of first loop
if not recursively:
break

View File

@ -1,66 +0,0 @@
import os, argparse, shutil
import common
def create_redist(redist_folder: str) -> None:
# get plugin root folder and redist folder
root_folder: str = common.get_plugin_folder()
# we do not want to use script to recursively delete any folder
# because we are afraid of accident `rm -rf /*` disaster.
# but we still need a empty folder to copy file,
# so we check whether redist folder is existing and hope user manually clean it.
redist_folder = os.path.abspath(redist_folder)
if os.path.exists(redist_folder):
print(f'"{redist_folder}" is already existing. This may cause problem, please empty it first before running redist script.')
# make sure redist folder is existing.
os.makedirs(redist_folder, exist_ok=True)
# copy core python files
common.conditional_file_copy(
root_folder,
redist_folder,
('*.py', '*.toml', ),
None,
False
)
# copy jsons
common.conditional_file_copy(
os.path.join(root_folder, 'jsons'),
os.path.join(redist_folder, 'jsons'),
('*.json', ),
None,
False
)
# copy icons
common.conditional_file_copy(
os.path.join(root_folder, 'icons'),
os.path.join(redist_folder, 'icons'),
('*.png', ),
None,
True
)
# copy meshes
common.conditional_file_copy(
os.path.join(root_folder, 'meshes'),
os.path.join(redist_folder, 'meshes'),
('*.bin', ),
None,
False
)
# copy BMap library
common.conditional_file_copy(
os.path.join(root_folder, 'PyBMap'),
os.path.join(redist_folder, 'PyBMap'),
('*.py', '*.dll', '*.so', '*.dylib', '*.bin', '*.pdb', ),
None,
False
)
print('Done.')
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='BBP NG Redist Script')
parser.add_argument('-o', '--output', required=True, action='store', dest='output', help='The path to redist folder.')
args = parser.parse_args()
create_redist(args.output)