Skip to content

Commit

Permalink
sep scrip to dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ikappaki committed Nov 6, 2024
1 parent 04b4b5d commit 2b79cea
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
68 changes: 23 additions & 45 deletions scripts/bb_addon_create.py
Original file line number Diff line number Diff line change
@@ -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_<version>.py'.
# Replaces the bl_info.version above with the major.minor.patch
# <version> 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}")
21 changes: 21 additions & 0 deletions src/dev/nrepl_panel_addon.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 2b79cea

Please sign in to comment.