Skip to content

Commit

Permalink
Added initial PCM stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
JarrettR committed Oct 31, 2022
1 parent 7ad50b2 commit d5a1c72
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
70 changes: 70 additions & 0 deletions pcm/build.py
Original file line number Diff line number Diff line change
@@ -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)
33 changes: 33 additions & 0 deletions pcm/metadata_template.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
Binary file added pcm/resources/bitmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d5a1c72

Please sign in to comment.