diff --git a/pcm/build.py b/pcm/build.py new file mode 100644 index 0000000..a5d3d4a --- /dev/null +++ b/pcm/build.py @@ -0,0 +1,70 @@ +# Thx Greg Davill +# https://github.com/gregdavill/KiBuzzard + + +import os +from os import path +import shutil + +src_path = path.join(path.dirname(__file__),'..','Stretch') + +metadata_template = path.join(path.dirname(__file__),'metadata_template.json') +resources_path = path.join(path.dirname(__file__),'resources') +#print(src_path) + +build_path = path.join('build') + +try: + shutil.rmtree(build_path) +except FileNotFoundError: + pass +os.mkdir(build_path) +os.mkdir(path.join(build_path,'plugin')) +os.chdir(build_path) + +shutil.copytree(src_path, path.join('plugin','plugins')) + +# clean out any __pycache__ or .pyc files (https://stackoverflow.com/a/41386937) +import pathlib +[p.unlink() for p in pathlib.Path('.').rglob('*.py[co]')] +[p.rmdir() for p in pathlib.Path('.').rglob('__pycache__')] + + +# copy metadata +shutil.copy(metadata_template, path.join('plugin','metadata.json')) +# copy icon +shutil.copytree(resources_path, path.join('plugin','resources')) + +# load up json script +from pathlib import Path +import json +with open(metadata_template) as f: + md = json.load(f) + + + +# zip all files +zip_file = 'Stretch-{0}-pcm.zip'.format(md['versions'][0]['version']) +shutil.make_archive(Path(zip_file).stem, 'zip', 'plugin') + + +zip_size = path.getsize(zip_file) + + +uncompressed_size = sum(f.stat().st_size for f in Path('plugin').glob('**/*') if f.is_file()) + +import hashlib +with open(zip_file, 'rb') as f: + zip_sha256 = hashlib.sha256(f.read()).hexdigest() + + + +md['versions'][0].update({ + 'install_size': uncompressed_size, + 'download_size': zip_size, + 'download_sha256': zip_sha256, + 'download_url': 'https://github.com/JarrettR/Stretch/releases/download/{0}/Stretch-{0}-pcm.zip'.format(md['versions'][0]['version']) +}) + +with open('metadata.json', 'w') as of: + json.dump(md, of, indent=2) diff --git a/pcm/metadata_template.json b/pcm/metadata_template.json new file mode 100644 index 0000000..8127512 --- /dev/null +++ b/pcm/metadata_template.json @@ -0,0 +1,33 @@ +{ + "$schema": "https://go.kicad.org/pcm/schemas/v1", + "name": "Stretch", + "description": "KiCad to SVG and then back again", + "description_full": "Seamless artistic workflow for KiCad and Inkscape.\n\nUsers can start by drawing a schematic and laying out a PCB, then bring it into Inkscape to arrange a thousand LEDs into a flower arrangement, then bring it back into KiCad to lay out traces, back into Inkscape to curve the traces, back into KiCad to change their microcontroller and few pin assignments, back into Inkscape to draw out some silkscreem patterns, back into KiCad to run DRC, and so on. The workflow is intended to be seamless and painless to go back and forth.", + "identifier": "com.github.jarrettr.stretch", + "type": "plugin", + "author": { "name": "Jarrett Rainier", + + "contact": { + "github": "https://github.com/JarrettR", + "web": "https://jrainimo.com" + } + }, + "maintainer": { + "name": "Jarrett Rainier", + "contact": { + "github": "https://github.com/JarrettR", + "web": "https://jrainimo.com" + } + }, + "license": "GPL-3.0", + "resources": { + "homepage": "https://github.com/JarrettR/Stretch" + }, + "versions": [ + { + "version": "1.0.0", + "status": "stable", + "kicad_version": "6.0" + } + ] +} \ No newline at end of file diff --git a/pcm/resources/bitmap.png b/pcm/resources/bitmap.png new file mode 100644 index 0000000..3613d08 Binary files /dev/null and b/pcm/resources/bitmap.png differ