gruvin.me

techno ramblings and such

Month: April 2022

  • Fixing KiCAD Custom Plugin Error

    macOS

    As of this writing, when one attempts to run a custom Python3 plugin script for KiCad (v6) where the script file is not located at /Applications/KiCad/KiCad.app/Contents/SharedSupport/plugins python complains that it cannot find the KiCad libraries.

    Apple security boffins have made it all but impossible to set global env variables, so export PYTHONPATH="..." isn’t really an option, when running plugin scripts from within the KiCad GUI (Generate BOM for example.)

    I did get that working by wrapping the text in Command line running the generator: with sh -c 'export PYTHONPATH="/Applications/KiCad/KiCad.app/Contents/SharedSupport/plugins && [original command here] ' … but then I realized a …

    Better Way (probably)

    In your custom Python script, change this …

    import kicad_netlist_reader
    import kicad_utils
    import csv
    import sys

    … to this …

    import sys
    sys.path.append("/Applications/KiCad/KiCad.app/Contents/SharedSupport/plugins")
    import kicad_netlist_reader
    import kicad_utils
    import csv

  • macOS Delete All Local Snapshots

    Single line at shell prompt …

    $ for i in tmutil listlocalsnapshots / | egrep -o '\d{4}-\d{2}-\d{2}-\d+'; do sudo tmutil deletelocalsnapshots $i; done

    In a bash/zsh script …

    #!/bin/bash
    for i in tmutil listlocalsnapshots / | egrep -o '\d{4}-\d{2}-\d{2}-\d+'
    do
        sudo tmutil deletelocalsnapshots $i
    done