kicad-sch-api 0.2.0__py3-none-any.whl → 0.2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of kicad-sch-api might be problematic. Click here for more details.
- kicad_sch_api/__init__.py +6 -2
- kicad_sch_api/cli.py +67 -62
- kicad_sch_api/core/component_bounds.py +477 -0
- kicad_sch_api/core/components.py +22 -10
- kicad_sch_api/core/config.py +127 -0
- kicad_sch_api/core/formatter.py +190 -24
- kicad_sch_api/core/geometry.py +111 -0
- kicad_sch_api/core/ic_manager.py +43 -37
- kicad_sch_api/core/junctions.py +17 -22
- kicad_sch_api/core/manhattan_routing.py +430 -0
- kicad_sch_api/core/parser.py +587 -197
- kicad_sch_api/core/pin_utils.py +149 -0
- kicad_sch_api/core/schematic.py +683 -207
- kicad_sch_api/core/simple_manhattan.py +228 -0
- kicad_sch_api/core/types.py +44 -4
- kicad_sch_api/core/wire_routing.py +380 -0
- kicad_sch_api/core/wires.py +29 -25
- kicad_sch_api/discovery/__init__.py +1 -1
- kicad_sch_api/discovery/search_index.py +142 -107
- kicad_sch_api/library/cache.py +70 -62
- {kicad_sch_api-0.2.0.dist-info → kicad_sch_api-0.2.2.dist-info}/METADATA +212 -40
- kicad_sch_api-0.2.2.dist-info/RECORD +31 -0
- kicad_sch_api-0.2.0.dist-info/RECORD +0 -24
- {kicad_sch_api-0.2.0.dist-info → kicad_sch_api-0.2.2.dist-info}/WHEEL +0 -0
- {kicad_sch_api-0.2.0.dist-info → kicad_sch_api-0.2.2.dist-info}/entry_points.txt +0 -0
- {kicad_sch_api-0.2.0.dist-info → kicad_sch_api-0.2.2.dist-info}/licenses/LICENSE +0 -0
- {kicad_sch_api-0.2.0.dist-info → kicad_sch_api-0.2.2.dist-info}/top_level.txt +0 -0
kicad_sch_api/__init__.py
CHANGED
|
@@ -42,11 +42,12 @@ Advanced Usage:
|
|
|
42
42
|
print(f"Found {len(issues)} validation issues")
|
|
43
43
|
"""
|
|
44
44
|
|
|
45
|
-
__version__ = "0.0
|
|
45
|
+
__version__ = "0.3.0"
|
|
46
46
|
__author__ = "Circuit-Synth"
|
|
47
47
|
__email__ = "info@circuit-synth.com"
|
|
48
48
|
|
|
49
49
|
from .core.components import Component, ComponentCollection
|
|
50
|
+
from .core.config import KiCADConfig, config
|
|
50
51
|
|
|
51
52
|
# Core imports for public API
|
|
52
53
|
from .core.schematic import Schematic
|
|
@@ -54,7 +55,7 @@ from .library.cache import SymbolLibraryCache, get_symbol_cache
|
|
|
54
55
|
from .utils.validation import ValidationError, ValidationIssue
|
|
55
56
|
|
|
56
57
|
# Version info
|
|
57
|
-
VERSION_INFO = (0,
|
|
58
|
+
VERSION_INFO = (0, 3, 0)
|
|
58
59
|
|
|
59
60
|
# Public API
|
|
60
61
|
__all__ = [
|
|
@@ -64,6 +65,9 @@ __all__ = [
|
|
|
64
65
|
"ComponentCollection",
|
|
65
66
|
"SymbolLibraryCache",
|
|
66
67
|
"get_symbol_cache",
|
|
68
|
+
# Configuration
|
|
69
|
+
"KiCADConfig",
|
|
70
|
+
"config",
|
|
67
71
|
# Exceptions
|
|
68
72
|
"ValidationError",
|
|
69
73
|
"ValidationIssue",
|
kicad_sch_api/cli.py
CHANGED
|
@@ -5,45 +5,43 @@ KiCAD Schematic API - Command Line Interface
|
|
|
5
5
|
Provides helpful commands for testing and usage of the library.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
import sys
|
|
9
|
-
import subprocess
|
|
10
8
|
import argparse
|
|
9
|
+
import subprocess
|
|
10
|
+
import sys
|
|
11
11
|
from pathlib import Path
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def test_installation() -> bool:
|
|
15
15
|
"""Test that the library is working correctly."""
|
|
16
16
|
print("🧪 Testing KiCAD Schematic API Library...")
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
try:
|
|
19
19
|
# Test basic import
|
|
20
20
|
import kicad_sch_api
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
version = getattr(kicad_sch_api, "__version__", "unknown")
|
|
22
23
|
print(f"✅ Library imports successfully: v{version}")
|
|
23
|
-
|
|
24
|
+
|
|
24
25
|
# Test core functionality
|
|
25
26
|
import kicad_sch_api as ksa
|
|
27
|
+
|
|
26
28
|
sch = ksa.create_schematic("test")
|
|
27
29
|
print("✅ Can create schematic")
|
|
28
|
-
|
|
30
|
+
|
|
29
31
|
# Test component addition
|
|
30
|
-
sch.components.add(
|
|
31
|
-
lib_id="Device:R",
|
|
32
|
-
reference="R1",
|
|
33
|
-
value="10k",
|
|
34
|
-
position=(100, 100)
|
|
35
|
-
)
|
|
32
|
+
sch.components.add(lib_id="Device:R", reference="R1", value="10k", position=(100, 100))
|
|
36
33
|
print("✅ Can add components")
|
|
37
|
-
|
|
34
|
+
|
|
38
35
|
# Test library access
|
|
39
36
|
from kicad_sch_api.library.cache import get_symbol_cache
|
|
37
|
+
|
|
40
38
|
cache = get_symbol_cache()
|
|
41
39
|
stats = cache.get_performance_stats()
|
|
42
40
|
print(f"✅ Symbol cache available: {stats['total_symbols_cached']} symbols")
|
|
43
|
-
|
|
41
|
+
|
|
44
42
|
print("🎉 All tests passed!")
|
|
45
43
|
return True
|
|
46
|
-
|
|
44
|
+
|
|
47
45
|
except Exception as e:
|
|
48
46
|
print(f"❌ Test failed: {e}")
|
|
49
47
|
return False
|
|
@@ -53,52 +51,58 @@ def show_status() -> bool:
|
|
|
53
51
|
"""Show current installation status."""
|
|
54
52
|
print("📊 KiCAD Schematic API Library Status")
|
|
55
53
|
print("=" * 40)
|
|
56
|
-
|
|
54
|
+
|
|
57
55
|
# Check installation
|
|
58
56
|
try:
|
|
59
57
|
import kicad_sch_api
|
|
60
|
-
|
|
58
|
+
|
|
59
|
+
version = getattr(kicad_sch_api, "__version__", "unknown")
|
|
61
60
|
print(f"✅ Library installed: v{version}")
|
|
62
61
|
except ImportError:
|
|
63
62
|
print("❌ Library not installed")
|
|
64
63
|
return False
|
|
65
|
-
|
|
64
|
+
|
|
66
65
|
# Check KiCAD libraries
|
|
67
66
|
try:
|
|
68
67
|
from kicad_sch_api.library.cache import get_symbol_cache
|
|
68
|
+
|
|
69
69
|
cache = get_symbol_cache()
|
|
70
70
|
stats = cache.get_performance_stats()
|
|
71
|
-
print(
|
|
71
|
+
print(
|
|
72
|
+
f"✅ KiCAD libraries: {len(cache._lib_stats)} libraries, {stats['total_symbols_cached']} symbols"
|
|
73
|
+
)
|
|
72
74
|
except Exception as e:
|
|
73
75
|
print(f"⚠️ KiCAD library access: {e}")
|
|
74
|
-
|
|
76
|
+
|
|
75
77
|
return True
|
|
76
78
|
|
|
77
79
|
|
|
78
80
|
def create_demo() -> bool:
|
|
79
81
|
"""Create a demo schematic to test functionality."""
|
|
80
82
|
print("🎨 Creating demo schematic...")
|
|
81
|
-
|
|
83
|
+
|
|
82
84
|
try:
|
|
83
85
|
import kicad_sch_api as ksa
|
|
84
|
-
|
|
86
|
+
|
|
85
87
|
# Create demo schematic
|
|
86
88
|
sch = ksa.create_schematic("Demo_Circuit")
|
|
87
|
-
|
|
89
|
+
|
|
88
90
|
# Add components
|
|
89
|
-
resistor = sch.components.add(
|
|
90
|
-
capacitor = sch.components.add(
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
resistor = sch.components.add("Device:R", reference="R1", value="10k", position=(100, 100))
|
|
92
|
+
capacitor = sch.components.add(
|
|
93
|
+
"Device:C", reference="C1", value="100nF", position=(150, 100)
|
|
94
|
+
)
|
|
95
|
+
led = sch.components.add("Device:LED", reference="D1", value="LED", position=(200, 100))
|
|
96
|
+
|
|
93
97
|
# Save schematic
|
|
94
98
|
sch.save("demo_circuit.kicad_sch")
|
|
95
|
-
|
|
99
|
+
|
|
96
100
|
print("✅ Demo schematic created: demo_circuit.kicad_sch")
|
|
97
101
|
print("📁 Contains: resistor, capacitor, and LED")
|
|
98
102
|
print("🔗 Try opening in KiCAD: kicad demo_circuit.kicad_sch")
|
|
99
|
-
|
|
103
|
+
|
|
100
104
|
return True
|
|
101
|
-
|
|
105
|
+
|
|
102
106
|
except Exception as e:
|
|
103
107
|
print(f"❌ Demo creation failed: {e}")
|
|
104
108
|
return False
|
|
@@ -107,9 +111,10 @@ def create_demo() -> bool:
|
|
|
107
111
|
def init_cache() -> bool:
|
|
108
112
|
"""Initialize the component discovery cache."""
|
|
109
113
|
print("🔄 Initializing component discovery cache...")
|
|
110
|
-
|
|
114
|
+
|
|
111
115
|
try:
|
|
112
116
|
from kicad_sch_api.discovery.search_index import ensure_index_built
|
|
117
|
+
|
|
113
118
|
component_count = ensure_index_built()
|
|
114
119
|
print(f"✅ Component cache initialized: {component_count} components indexed")
|
|
115
120
|
return True
|
|
@@ -121,11 +126,10 @@ def init_cache() -> bool:
|
|
|
121
126
|
def check_kicad() -> bool:
|
|
122
127
|
"""Check KiCAD installation and library access."""
|
|
123
128
|
print("🔍 Checking KiCAD installation...")
|
|
124
|
-
|
|
129
|
+
|
|
125
130
|
try:
|
|
126
131
|
# Check if KiCAD command is available
|
|
127
|
-
result = subprocess.run([
|
|
128
|
-
capture_output=True, timeout=10)
|
|
132
|
+
result = subprocess.run(["kicad", "--version"], capture_output=True, timeout=10)
|
|
129
133
|
if result.returncode == 0:
|
|
130
134
|
version_output = result.stdout.decode().strip()
|
|
131
135
|
print(f"✅ KiCAD found: {version_output}")
|
|
@@ -134,16 +138,17 @@ def check_kicad() -> bool:
|
|
|
134
138
|
except (subprocess.TimeoutExpired, FileNotFoundError):
|
|
135
139
|
print("❌ KiCAD command not found in PATH")
|
|
136
140
|
print(" Please ensure KiCAD is installed and accessible")
|
|
137
|
-
|
|
141
|
+
|
|
138
142
|
# Check library directories
|
|
139
143
|
try:
|
|
140
144
|
from kicad_sch_api.library.cache import get_symbol_cache
|
|
145
|
+
|
|
141
146
|
cache = get_symbol_cache()
|
|
142
|
-
|
|
147
|
+
|
|
143
148
|
print("📚 KiCAD Library Status:")
|
|
144
149
|
for lib_name, lib_stats in cache._lib_stats.items():
|
|
145
150
|
print(f" • {lib_name}: {lib_stats.symbol_count} symbols")
|
|
146
|
-
|
|
151
|
+
|
|
147
152
|
return True
|
|
148
153
|
except Exception as e:
|
|
149
154
|
print(f"❌ Library access failed: {e}")
|
|
@@ -176,25 +181,25 @@ Examples:
|
|
|
176
181
|
kicad-sch-api --test # Test library installation
|
|
177
182
|
kicad-sch-api --demo # Create demo schematic
|
|
178
183
|
kicad-sch-api --status # Show library status
|
|
179
|
-
"""
|
|
184
|
+
""",
|
|
180
185
|
)
|
|
181
|
-
|
|
186
|
+
|
|
182
187
|
# Main options
|
|
183
|
-
parser.add_argument(
|
|
184
|
-
|
|
185
|
-
parser.add_argument(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
parser.add_argument(
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
188
|
+
parser.add_argument("--test", action="store_true", help="Test that the library is working")
|
|
189
|
+
parser.add_argument("--status", action="store_true", help="Show library installation status")
|
|
190
|
+
parser.add_argument("--demo", action="store_true", help="Create a demo schematic")
|
|
191
|
+
parser.add_argument(
|
|
192
|
+
"--init-cache", action="store_true", help="Initialize component discovery cache"
|
|
193
|
+
)
|
|
194
|
+
parser.add_argument(
|
|
195
|
+
"--check-kicad", action="store_true", help="Check KiCAD installation and libraries"
|
|
196
|
+
)
|
|
197
|
+
parser.add_argument(
|
|
198
|
+
"--mcp-info", action="store_true", help="Show MCP server integration information"
|
|
199
|
+
)
|
|
200
|
+
|
|
196
201
|
args = parser.parse_args()
|
|
197
|
-
|
|
202
|
+
|
|
198
203
|
# If no arguments provided, show help
|
|
199
204
|
if not any(vars(args).values()):
|
|
200
205
|
print("🚀 KiCAD Schematic API - Command Line Interface")
|
|
@@ -213,30 +218,30 @@ Examples:
|
|
|
213
218
|
print("🆘 For all options:")
|
|
214
219
|
print(" kicad-sch-api --help")
|
|
215
220
|
return
|
|
216
|
-
|
|
221
|
+
|
|
217
222
|
# Execute requested actions
|
|
218
223
|
success = True
|
|
219
|
-
|
|
224
|
+
|
|
220
225
|
if args.test:
|
|
221
226
|
success &= test_installation()
|
|
222
|
-
|
|
227
|
+
|
|
223
228
|
if args.status:
|
|
224
229
|
success &= show_status()
|
|
225
|
-
|
|
230
|
+
|
|
226
231
|
if args.demo:
|
|
227
232
|
success &= create_demo()
|
|
228
|
-
|
|
233
|
+
|
|
229
234
|
if args.init_cache:
|
|
230
235
|
success &= init_cache()
|
|
231
|
-
|
|
236
|
+
|
|
232
237
|
if args.check_kicad:
|
|
233
238
|
success &= check_kicad()
|
|
234
|
-
|
|
239
|
+
|
|
235
240
|
if args.mcp_info:
|
|
236
241
|
show_mcp_info()
|
|
237
|
-
|
|
242
|
+
|
|
238
243
|
sys.exit(0 if success else 1)
|
|
239
244
|
|
|
240
245
|
|
|
241
246
|
if __name__ == "__main__":
|
|
242
|
-
main()
|
|
247
|
+
main()
|