-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild_pcm_package.py
More file actions
51 lines (41 loc) · 1.61 KB
/
build_pcm_package.py
File metadata and controls
51 lines (41 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
Build KiCad PCM package for KiNotes.
Creates: dist/KiNotes-{version}-pcm.zip
"""
import os
import shutil
import zipfile
import json
from pathlib import Path
def build():
# Read version from metadata
with open("KiNotes/metadata.json") as f:
meta = json.load(f)
version = meta["versions"][0]["version"]
print(f"Building KiNotes PCM Package v{version}")
dist = Path("dist")
dist.mkdir(exist_ok=True)
zip_name = dist / f"KiNotes-{version}-pcm.zip"
with zipfile.ZipFile(zip_name, 'w', zipfile.ZIP_DEFLATED) as zf:
# Add plugins/ content (files directly under plugins/, NOT plugins/KiNotes/)
# KiCad PCM extracts to: .../plugins/com_pcbtools_kinotes/
# So our files go directly there, not in a KiNotes/ subfolder
src = Path("KiNotes")
for f in src.rglob("*"):
if f.is_file() and "__pycache__" not in str(f):
# Use relative path from KiNotes/ directly under plugins/
arcname = f"plugins/{f.relative_to(src)}"
zf.write(f, arcname)
print(f" + {arcname}")
# Add root metadata.json
zf.write("KiNotes/metadata.json", "metadata.json")
print(" + metadata.json (root)")
# Add resources/icon.png (64x64 for PCM)
icon = Path("KiNotes/resources/icons/icon.png")
if icon.exists():
zf.write(icon, "resources/icon.png")
print(" + resources/icon.png")
print(f"\n✅ Created: {zip_name}")
print(f" Size: {zip_name.stat().st_size / 1024:.1f} KB")
if __name__ == "__main__":
build()