From 2b79ceab9583be0de23d71d7b8941c09a588f4d3 Mon Sep 17 00:00:00 2001 From: ikappaki Date: Wed, 6 Nov 2024 21:49:38 +0000 Subject: [PATCH] sep scrip to dev --- .github/workflows/release.yaml | 2 +- scripts/bb_addon_create.py | 68 ++++++++++++---------------------- src/dev/nrepl_panel_addon.py | 21 +++++++++++ 3 files changed, 45 insertions(+), 46 deletions(-) create mode 100644 src/dev/nrepl_panel_addon.py diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index eb165ed..d20f5e4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -30,7 +30,7 @@ jobs: python -m pip install --upgrade pip pip install poetry - name: Build package - run: poetry build && poetry install && poetry run python scripts/bb_addon_create.py + run: poetry build && python scripts/bb_addon_create.py - name: Upload release artifacts run: gh release upload ${{ github.event.release.tag_name }} dist/*.{tar.gz,whl} dist/nrepl_panel_addon*.py env: diff --git a/scripts/bb_addon_create.py b/scripts/bb_addon_create.py index da1d743..95187a9 100644 --- a/scripts/bb_addon_create.py +++ b/scripts/bb_addon_create.py @@ -1,47 +1,25 @@ -from basilisp_blender import control_panel_create -bl_info = { - "name" : "Basilisp Blender Add On", - "author" : "ikappaki", - "version" : (0, 99, 99), - "blender" : (3, 60, 0), - "category": "Development", -} -_DESTROY_FN = None -def register(): - global _DESTROY_FN - print(f"nREPL Control Panel creating...") - _DESTROY_FN = control_panel_create() - print(f"nREPL Control Panel creating... done") +# This script should be invoked from the project root directory. +# +# Copies the nrepl_panel_addon.py file to dist adding the version +# number as retrieved from `poetry version`. +import re +import subprocess -def unregister(): - global _DESTROY_FN - print("nREPL Control Panel destroying...") - _DESTROY_FN() - _DESTROY_FN = None - print("nREPL Control Panel destroying... done") +src_path = "src/dev/nrepl_panel_addon.py" +version_mark = "(0, 99, 99)" -if __name__ == '__main__': - # This script should be invoked from the project root directory. - # - # Copies the contents of this file up to, but not including, the - # __main__ section to 'dist/nrepl_panel_addon_.py'. - # Replaces the bl_info.version above with the major.minor.patch - # numbers as reported by `poetry version`. - re = __import__("re") - subprocess = __import__("subprocess") - result = subprocess.run(["poetry", "version"], capture_output=True, text=True) - _, version = result.stdout.split(" ") - major, minor, patch = version.split(".") - patch_int = int(re.match(r'^\d+', patch).group()) - filename_dist = f'dist/nrepl_panel_addon_{version.strip().replace(".", "_")}.py' - version_mark = "(0, 99, 99)" - with open(__file__, 'r') as src: - with open(filename_dist, 'w', newline="\n") as dst: - dst.write(f"# Autogenerated from {__file__}\n") - for line in src.readlines(): - if line.strip().startswith("if __name__ == '__main__':"): - break - if version_mark in line: - line = line.replace(version_mark, f"({major}, {minor}, {patch_int})") - dst.write(line) - print(f":bb_addon_create.py :created {filename_dist}") +result = subprocess.run(["poetry", "version"], capture_output=True, text=True) +_, version = result.stdout.split(" ") +major, minor, patch = version.split(".") +patch_int = int(re.match(r'^\d+', patch).group()) + +dist_path = f'dist/nrepl_panel_addon_{version.strip().replace(".", "_")}.py' + +with open(src_path, 'r') as src: + with open(dist_path, 'w', newline="\n") as dst: + dst.write(f"# Autogenerated from {src_path}\n") + for line in src.readlines(): + if version_mark in line: + line = line.replace(version_mark, f"({major}, {minor}, {patch_int})") + dst.write(line) +print(f":bb_addon_create.py :created {dist_path}") diff --git a/src/dev/nrepl_panel_addon.py b/src/dev/nrepl_panel_addon.py new file mode 100644 index 0000000..9e84ba3 --- /dev/null +++ b/src/dev/nrepl_panel_addon.py @@ -0,0 +1,21 @@ +from basilisp_blender import control_panel_create +bl_info = { + "name" : "Basilisp Blender Add On", + "author" : "ikappaki", + "version" : (0, 99, 99), + "blender" : (3, 60, 0), + "category": "Development", +} +_DESTROY_FN = None +def register(): + global _DESTROY_FN + print(f"nREPL Control Panel creating...") + _DESTROY_FN = control_panel_create() + print(f"nREPL Control Panel creating... done") + +def unregister(): + global _DESTROY_FN + print("nREPL Control Panel destroying...") + _DESTROY_FN() + _DESTROY_FN = None + print("nREPL Control Panel destroying... done")