Release 0.1

This commit is contained in:
Stefan Cepko
2026-06-05 04:45:35 -04:00
parent b6d0eeffbb
commit 31e464f5cd
6 changed files with 289 additions and 54 deletions
+67
View File
@@ -0,0 +1,67 @@
import os
import re
import zipfile
def get_addon_version():
"""Reads pr3tz/__init__.py and extracts the bl_info version tuple."""
init_path = os.path.join("pr3tz", "__init__.py")
if not os.path.exists(init_path):
raise FileNotFoundError(f"Could not find {init_path}")
with open(init_path, "r", encoding="utf-8") as f:
content = f.read()
# Search for the "version": (x, y, z) pattern in bl_info
match = re.search(r'"version"\s*:\s*\(([^)]+)\)', content)
if not match:
raise ValueError("Could not parse version from bl_info in __init__.py")
version_str = match.group(1)
# Parse numbers, e.g. "2, 0, 0" -> ["2", "0", "0"] -> "2.0.0"
version_parts = [part.strip() for part in version_str.split(",")]
return ".".join(version_parts)
def package_addon():
"""Zips the pr3tz addon folder, excluding development artifacts."""
try:
version = get_addon_version()
except Exception as e:
print(f"Warning: Could not parse version: {e}. Defaulting to 'unknown'.")
version = "unknown"
release_dir = "releases"
if not os.path.exists(release_dir):
os.makedirs(release_dir)
print(f"Created output directory: {release_dir}/")
zip_filename = f"pr3tz_v{version}.zip"
zip_path = os.path.join(release_dir, zip_filename)
print(f"Packaging addon v{version} into {zip_path}...")
addon_dir = "pr3tz"
ignored_dirs = {"__pycache__", ".git"}
ignored_extensions = {".pyc", ".pyo", ".py.bak"}
added_count = 0
with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
for root, dirs, files in os.walk(addon_dir):
# Prune directories in-place to prevent walking into them
dirs[:] = [d for d in dirs if d not in ignored_dirs]
for file in files:
_, ext = os.path.splitext(file)
if ext in ignored_extensions:
continue
file_path = os.path.join(root, file)
# Ensure the path in the ZIP has "pr3tz/" as its root folder
arcname = os.path.relpath(file_path, os.path.dirname(addon_dir))
zipf.write(file_path, arcname)
print(f" Added: {arcname}")
added_count += 1
print(f"\nSuccess! Packaged {added_count} files into {zip_path}")
if __name__ == "__main__":
package_addon()