devbisme / skidl

SKiDL is a module that extends Python with the ability to design electronic circuits.
https://devbisme.github.io/skidl/
MIT License
1.06k stars 120 forks source link

Fix KiCAD8 var names #209

Closed jakeogh closed 7 months ago

jakeogh commented 7 months ago

While trying to run a the README example for kicad8 (#179) I noticed the var names in kicad8/lib.py were wrong. It's still complaining about KICAD8_SYMBOL_DIR env var missing, is that user error?

$ cat test.py
#!/usr/bin/env python3

import os
import sys
from skidl import KICAD8
from skidl import set_default_tool
from skidl import lib_search_paths
from skidl import footprint_search_paths
from skidl import TEMPLATE
from skidl import Part
from skidl import Net
from skidl import generate_netlist
from skidl import generate_pcb

os.environ["KICAD8_SYMBOL_DIR"] = "/usr/share/kicad/symbols/"
set_default_tool(KICAD8)

lib_search_paths[KICAD8].append('/usr/share/kicad/symbols')
footprint_search_paths[KICAD8].append('/usr/share/kicad/footprints')
print(f"{footprint_search_paths=}", file=sys.stderr)

# Create part templates.
q = Part("Device", "Q_PNP_CBE", dest=TEMPLATE)
r = Part("Device", "R", dest=TEMPLATE)

# Create nets.
gnd, vcc = Net("GND"), Net("VCC")
a, b, a_and_b = Net("A"), Net("B"), Net("A_AND_B")

# Instantiate parts.
gndt = Part("power", "GND")             # Ground terminal.
vcct = Part("power", "VCC")             # Power terminal.
q1, q2 = q(2)                           # Two transistors.
r1, r2, r3, r4, r5 = r(5, value="10K")  # Five 10K resistors.

# Make connections between parts.
# ptlint:
a & r1 & q1["B C"] & r4 & q2["B C"] & a_and_b & r5 & gnd
b & r2 & q1["B"]
q1["C"] & r3 & gnd
vcc += q1["E"], q2["E"], vcct
gnd += gndt

generate_netlist()

$ ./test.py
WARNING: KICAD_SYMBOL_DIR environment variable is missing, so the default KiCad symbol libraries won't be searched. @ [/home/cfg/cad/skidl/bug_179/<frozen importlib._bootstrap_external>:940=>/home/cfg/cad/skidl/bug_179/<frozen importlib._bootstrap>:241]
WARNING: KICAD7_SYMBOL_DIR environment variable is missing, so the default KiCad symbol libraries won't be searched. @ [/home/cfg/cad/skidl/bug_179/<frozen importlib._bootstrap_external>:940=>/home/cfg/cad/skidl/bug_179/<frozen importlib._bootstrap>:241]
WARNING: KICAD8_SYMBOL_DIR environment variable is missing, so the default KiCad symbol libraries won't be searched. @ [/home/cfg/cad/skidl/bug_179/<frozen importlib._bootstrap_external>:940=>/home/cfg/cad/skidl/bug_179/<frozen importlib._bootstrap>:241]
WARNING: KICAD6_SYMBOL_DIR environment variable is missing, so the default KiCad symbol libraries won't be searched. @ [/home/cfg/cad/skidl/bug_179/<frozen importlib._bootstrap_external>:940=>/home/cfg/cad/skidl/bug_179/<frozen importlib._bootstrap>:241]
footprint_search_paths={'kicad': ['/home/user/.config/kicad'], 'kicad7': ['/home/user/.config/kicad'], 'kicad8': ['/home/user/.config/kicad', '/usr/share/kicad/footprints'], 'skidl': ['/home/user/.config/kicad'], 'kicad6': ['/home/user/.config/kicad'], 'spice': ['/home/user/.config/kicad']}
WARNING: Could not load KiCad schematic library "Device", falling back to backup library. @ [/home/cfg/cad/skidl/bug_179/example_from_readme_bug_179.py:23]
WARNING: Could not load KiCad schematic library "Device", falling back to backup library. @ [/home/cfg/cad/skidl/bug_179/example_from_readme_bug_179.py:24]
WARNING: Could not load KiCad schematic library "power", falling back to backup library. @ [/home/cfg/cad/skidl/bug_179/example_from_readme_bug_179.py:31]
WARNING: Could not load KiCad schematic library "power", falling back to backup library. @ [/home/cfg/cad/skidl/bug_179/example_from_readme_bug_179.py:32]
INFO: No errors or warnings found while generating netlist.
devbisme commented 7 months ago

Thanks! I incorporated your fixes into the development branch.