Fix kicad plugin infrastructure stuff
This commit is contained in:
parent
ce74278bf6
commit
f19e3f3d7a
4 changed files with 47 additions and 101 deletions
|
|
@ -5,7 +5,7 @@
|
||||||
"description": "Planar inductor supporting spiral coils, toroidal coils, and hybrids",
|
"description": "Planar inductor supporting spiral coils, toroidal coils, and hybrids",
|
||||||
"runtime": {
|
"runtime": {
|
||||||
"type": "python",
|
"type": "python",
|
||||||
"min_version": 3.13
|
"min_version": "3.13"
|
||||||
},
|
},
|
||||||
"actions": [
|
"actions": [
|
||||||
{
|
{
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
"description": "Generates planar spiral inductors, toroidal inductors, and hybrids thereof",
|
"description": "Generates planar spiral inductors, toroidal inductors, and hybrids thereof",
|
||||||
"show-button": true,
|
"show-button": true,
|
||||||
"scopes": ["pcb"],
|
"scopes": ["pcb"],
|
||||||
"entrypoint": "kicoil_plugin_action.py",
|
"entrypoint": "kicoil_action.py",
|
||||||
"icons-light": ["icon-light.png"],
|
"icons-light": ["icon-light.png"],
|
||||||
"icons-dark": ["icon-dark.png"]
|
"icons-dark": ["icon-dark.png"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,78 +18,6 @@
|
||||||
"issues": "https://codeberg.org/jaseg/kicoil/issues"
|
"issues": "https://codeberg.org/jaseg/kicoil/issues"
|
||||||
},
|
},
|
||||||
"versions": [
|
"versions": [
|
||||||
{
|
|
||||||
"version": "0.9.0",
|
|
||||||
"status": "stable",
|
|
||||||
"kicad_version": "9.00",
|
|
||||||
"download_sha256": "e0696023ef669b1d4efac3a5cb47abb859db32dca1e3f5efd55344daa848a2be",
|
|
||||||
"download_size": 70143,
|
|
||||||
"download_url": "https://git.jaseg.de/kimesh.git/plain/de.jaseg.kicoil-v0.9.0.zip?h=v0.9.0",
|
|
||||||
"install_size": 196790
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "0.9.0",
|
|
||||||
"status": "stable",
|
|
||||||
"kicad_version": "9.00",
|
|
||||||
"download_sha256": "280139c454396d0afaa71ac7bd35c6c09c3c602c3ad55e77b14b51f22df16818",
|
|
||||||
"download_size": 70143,
|
|
||||||
"download_url": "https://git.jaseg.de/kimesh.git/plain/de.jaseg.kicoil-v0.9.0.zip?h=v0.9.0",
|
|
||||||
"install_size": 196790
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "0.9.0",
|
|
||||||
"status": "stable",
|
|
||||||
"kicad_version": "9.00",
|
|
||||||
"download_sha256": "3cf67dff3226ca5f3eb2409f5230b4bb02f5266351621b9e97c80493cc48ae61",
|
|
||||||
"download_size": 69827,
|
|
||||||
"download_url": "https://git.jaseg.de/kimesh.git/plain/de.jaseg.kicoil-v0.9.0.zip?h=v0.9.0",
|
|
||||||
"install_size": 196790
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "0.9.0",
|
|
||||||
"status": "stable",
|
|
||||||
"kicad_version": "9.00",
|
|
||||||
"download_sha256": "ae1144223256c1f59fad76c27dbdfa3722a16df162b9c3d13cd4e840481626e7",
|
|
||||||
"download_size": 69103,
|
|
||||||
"download_url": "https://git.jaseg.de/kimesh.git/plain/de.jaseg.kicoil-v0.9.0.zip?h=v0.9.0",
|
|
||||||
"install_size": 195410
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "0.9.0",
|
|
||||||
"status": "stable",
|
|
||||||
"kicad_version": "9.00",
|
|
||||||
"download_sha256": "429d93b5850bd54a767b5a18fa841c8b17ed30823568d934706d67dca38e1eb1",
|
|
||||||
"download_size": 69108,
|
|
||||||
"download_url": "https://git.jaseg.de/kimesh.git/plain/de.jaseg.kicoil-v0.9.0.zip?h=v0.9.0",
|
|
||||||
"install_size": 195414
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "0.9.0",
|
|
||||||
"status": "stable",
|
|
||||||
"kicad_version": "9.00",
|
|
||||||
"download_sha256": "538f89db2c4beef1c344260634b0b6f07c0ba7cb3a81fd71a9a9af028a5c38fe",
|
|
||||||
"download_size": 69703,
|
|
||||||
"download_url": "https://git.jaseg.de/kimesh.git/plain/de.jaseg.kicoil-v0.9.0.zip?h=v0.9.0",
|
|
||||||
"install_size": 196520
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "0.9.0",
|
|
||||||
"status": "stable",
|
|
||||||
"kicad_version": "9.00",
|
|
||||||
"download_sha256": "55a3a05e5730713c3456b45e6c8bca5f66e407944d1a465949547a3d5a2b7007",
|
|
||||||
"download_size": 72082,
|
|
||||||
"download_url": "https://git.jaseg.de/kimesh.git/plain/de.jaseg.kicoil-v0.9.0.zip?h=v0.9.0",
|
|
||||||
"install_size": 202369
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "0.9.0",
|
|
||||||
"status": "stable",
|
|
||||||
"kicad_version": "9.00",
|
|
||||||
"download_sha256": "736bd91edabc24fa1f342e98e56fa03796363f7e8240adeaaa461bd130ab7c57",
|
|
||||||
"download_size": 72070,
|
|
||||||
"download_url": "https://git.jaseg.de/kimesh.git/plain/de.jaseg.kicoil-v0.9.0.zip?h=v0.9.0",
|
|
||||||
"install_size": 202424
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
"runtime": "ipc"
|
"runtime": "ipc"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
70
package.py
70
package.py
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import re
|
import re
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import tomllib
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import json
|
import json
|
||||||
|
|
@ -12,24 +13,11 @@ def tree_size(path):
|
||||||
return sum(entry.stat().st_size for entry in path.glob('**/*') if entry.is_file())
|
return sum(entry.stat().st_size for entry in path.glob('**/*') if entry.is_file())
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.option('--major', 'increment', flag_value='major')
|
|
||||||
@click.option('--minor', 'increment', flag_value='minor', default=True)
|
|
||||||
@click.option('--patch', 'increment', flag_value='patch', default=True)
|
|
||||||
@click.option('--dry-run', is_flag=True)
|
@click.option('--dry-run', is_flag=True)
|
||||||
@click.argument('version', required=False)
|
def do_release(dry_run):
|
||||||
def do_release(version, increment, dry_run):
|
with open('pyproject.toml', 'rb') as f:
|
||||||
if not version:
|
project_file = tomllib.load(f)
|
||||||
tag = subprocess.run('git describe --tags --abbrev=0 --match v*'.split(),
|
version = project_file['project']['version']
|
||||||
check=True, capture_output=True, text=True)
|
|
||||||
major, minor, patch = map(int, re.fullmatch(r'v([0-9]+)\.([0-9]+)\.([0-9]+)', tag.stdout.strip()).groups())
|
|
||||||
match increment:
|
|
||||||
case 'major':
|
|
||||||
major, minor, patch = (major+1, 0, 0)
|
|
||||||
case 'minor':
|
|
||||||
major, minor, patch = (major, minor+1, 0)
|
|
||||||
case 'patch':
|
|
||||||
major, minor, patch = (major, minor, patch+1)
|
|
||||||
version = f'{major}.{minor}.{patch}'
|
|
||||||
|
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
res = subprocess.run('git status --porcelain --untracked-files=no'.split(),
|
res = subprocess.run('git status --porcelain --untracked-files=no'.split(),
|
||||||
|
|
@ -47,12 +35,14 @@ def do_release(version, increment, dry_run):
|
||||||
|
|
||||||
plugin_sources = project_root / 'kicad-plugin'
|
plugin_sources = project_root / 'kicad-plugin'
|
||||||
pkg_dir = project_root / 'de.jaseg.kicoil'
|
pkg_dir = project_root / 'de.jaseg.kicoil'
|
||||||
|
plugin_dir = pkg_dir / 'plugins'
|
||||||
|
|
||||||
if pkg_dir.is_dir():
|
if pkg_dir.is_dir():
|
||||||
shutil.rmtree(pkg_dir)
|
shutil.rmtree(pkg_dir)
|
||||||
|
pkg_dir.mkdir()
|
||||||
|
|
||||||
shutil.copytree(plugin_sources, pkg_dir)
|
shutil.copytree(plugin_sources, plugin_dir)
|
||||||
shutil.copy(project_root / 'LICENSE', pkg_dir)
|
shutil.copy(project_root / 'LICENSE', plugin_dir)
|
||||||
|
|
||||||
meta_path = project_root / 'metadata.json'
|
meta_path = project_root / 'metadata.json'
|
||||||
print(f'Updating metadata file {meta_path}')
|
print(f'Updating metadata file {meta_path}')
|
||||||
|
|
@ -66,11 +56,39 @@ def do_release(version, increment, dry_run):
|
||||||
meta_file['versions'] = [ver_dict]
|
meta_file['versions'] = [ver_dict]
|
||||||
(pkg_dir / 'metadata.json').write_text(json.dumps(meta_file, indent=4))
|
(pkg_dir / 'metadata.json').write_text(json.dumps(meta_file, indent=4))
|
||||||
|
|
||||||
res = subprocess.run(['uv', 'export', '--no-hashes', '--format', 'requirements-txt'],
|
res = subprocess.run(['uv', 'export', '--no-hashes', '--no-emit-project', '--format', 'requirements.txt', '--group', 'gui'],
|
||||||
check=True, capture_output=True, text=True)
|
check=True, capture_output=True, text=True)
|
||||||
(pkg_dir / 'requirements.txt').write_text(res.stdout)
|
(plugin_dir / 'requirements.txt').write_text(res.stdout)
|
||||||
|
|
||||||
shutil.copytree(project_root / 'src' / 'kicoil', pkg_dir / 'kicoil')
|
(pkg_dir / 'resources').mkdir()
|
||||||
|
shutil.copy(plugin_sources / 'icon-light.png', pkg_dir / 'resources' / 'icon.png')
|
||||||
|
|
||||||
|
module_sources = project_root / 'src'
|
||||||
|
for root, dirs, files in module_sources.walk(top_down=True):
|
||||||
|
if root.name == '__pycache__':
|
||||||
|
continue
|
||||||
|
|
||||||
|
for path in dirs:
|
||||||
|
if path == '__pycache__':
|
||||||
|
continue
|
||||||
|
|
||||||
|
path = root / path
|
||||||
|
subdir = plugin_dir / path.relative_to(module_sources)
|
||||||
|
subdir.mkdir()
|
||||||
|
|
||||||
|
for path in files:
|
||||||
|
path = root / path
|
||||||
|
out_path = plugin_dir / path.relative_to(module_sources)
|
||||||
|
content = path.read_text()
|
||||||
|
if path.name == '__init__.py':
|
||||||
|
lines = content.splitlines()
|
||||||
|
lines_out = []
|
||||||
|
for line in lines:
|
||||||
|
if line.startswith('__version__ = version('):
|
||||||
|
line = f'__version__ = {version!r}'
|
||||||
|
lines_out.append(line)
|
||||||
|
content = '\n'.join(lines_out)
|
||||||
|
out_path.write_text(content)
|
||||||
|
|
||||||
zip_fn = Path(shutil.make_archive(f'{pkg_dir.name}-v{version}', 'zip', pkg_dir, '.'))
|
zip_fn = Path(shutil.make_archive(f'{pkg_dir.name}-v{version}', 'zip', pkg_dir, '.'))
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
|
|
@ -83,11 +101,11 @@ def do_release(version, increment, dry_run):
|
||||||
ver_dict['download_url'] = f'https://git.jaseg.de/kimesh.git/plain/{zip_fn.name}?h=v{version}'
|
ver_dict['download_url'] = f'https://git.jaseg.de/kimesh.git/plain/{zip_fn.name}?h=v{version}'
|
||||||
ver_dict['install_size'] = tree_size(pkg_dir)
|
ver_dict['install_size'] = tree_size(pkg_dir)
|
||||||
|
|
||||||
meta_file = json.loads(meta_path.read_text())
|
|
||||||
meta_file['versions'].append(ver_dict)
|
|
||||||
meta_path.write_text(json.dumps(meta_file, indent=4))
|
|
||||||
|
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
|
meta_file = json.loads(meta_path.read_text())
|
||||||
|
meta_file['versions'].append(ver_dict)
|
||||||
|
meta_path.write_text(json.dumps(meta_file, indent=4))
|
||||||
|
|
||||||
print(f'Adding updated metadata file {meta_path} to git index')
|
print(f'Adding updated metadata file {meta_path} to git index')
|
||||||
subprocess.run(['git', 'add', str(meta_path)], check=True, capture_output=True)
|
subprocess.run(['git', 'add', str(meta_path)], check=True, capture_output=True)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue