This repository has been archived by the owner on Dec 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add KiCad global footprint paths for non-linux platforms
- Loading branch information
1 parent
ca06d40
commit 20241b8
Showing
3 changed files
with
42 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import os | ||
import sys | ||
from pathlib import Path | ||
|
||
KICAD_VERSION = "8.0" | ||
|
||
# footprint library paths | ||
# ref: https://docs.kicad.org/8.0/en/kicad/kicad.html#config-file-location | ||
match sys.platform: | ||
case "win32": | ||
appdata = os.getenv("APPDATA") | ||
if appdata is not None: | ||
GLOBAL_FP_LIB_PATH = ( | ||
Path(appdata) / "kicad" / KICAD_VERSION / "fp-lib-table" | ||
) | ||
else: | ||
raise EnvironmentError("APPDATA environment variable not set") | ||
# TODO: verify on a windows machine | ||
GLOBAL_FP_DIR_PATH = Path(appdata) / "kicad" / KICAD_VERSION / "footprints" | ||
case "linux": | ||
GLOBAL_FP_LIB_PATH = ( | ||
Path("~/.config/kicad").expanduser() / KICAD_VERSION / "fp-lib-table" | ||
) | ||
GLOBAL_FP_DIR_PATH = Path("/usr/share/kicad/footprints") | ||
case "darwin": | ||
GLOBAL_FP_LIB_PATH = ( | ||
Path("~/Library/Preferences/kicad").expanduser() | ||
/ KICAD_VERSION | ||
/ "fp-lib-table" | ||
) | ||
GLOBAL_FP_DIR_PATH = Path( | ||
"/Applications/KiCad/KiCad.app/Contents/SharedSupport/symbols" | ||
) | ||
case _: | ||
raise EnvironmentError(f"Unsupported platform: {sys.platform}") | ||
|
||
if not GLOBAL_FP_LIB_PATH.exists(): | ||
raise FileNotFoundError(f"Footprint library path not found: {GLOBAL_FP_LIB_PATH}") | ||
if not GLOBAL_FP_DIR_PATH.exists(): | ||
raise FileNotFoundError(f"Footprint directory path not found: {GLOBAL_FP_DIR_PATH}") |