circuitgen 0.1.0__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 git-ishaan-kumar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,178 @@
1
+ Metadata-Version: 2.4
2
+ Name: circuitgen
3
+ Version: 0.1.0
4
+ Summary: A Python library and CLI for generating circuit schematics from text descriptions or netlists.
5
+ Author: Ishaan
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/git-ishaan-kumar/circuitgen
8
+ Keywords: circuit,schematic,electronics,circuit-diagram,netlist,svg,circuit-generator,python-library,cli
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Dynamic: license-file
15
+
16
+ # CircuitGen
17
+
18
+ A Python library and CLI for generating circuit schematics from text descriptions or netlists.
19
+
20
+ CircuitGen takes a circuit netlist, places components, routes wires, and exports clean SVG schematics. It includes AI translation that converts natural-language prompts into valid netlists using a chosen provider.
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ pip install circuitgen
26
+ ```
27
+
28
+ Or install from source:
29
+
30
+ ```bash
31
+ git clone https://github.com/git-ishaan-kumar/circuitgen.git
32
+ cd circuitgen
33
+ pip install -e .
34
+ ```
35
+
36
+ Requires Python 3.10 or higher. No external runtime dependencies.
37
+
38
+ ## Quickstart
39
+
40
+ ### 1. From a Netlist (Offline, No API Key)
41
+
42
+ ```python
43
+ from circuitgen import from_netlist
44
+
45
+ netlist = {
46
+ "components": [
47
+ {"id": "V1", "type": "battery", "value": "9V"},
48
+ {"id": "R1", "type": "resistor", "value": "330Ω"},
49
+ {"id": "D1", "type": "led", "value": "red"},
50
+ ],
51
+ "nets": [
52
+ {"name": "VCC", "pins": ["V1.p", "R1.a"]},
53
+ {"name": "MID", "pins": ["R1.b", "D1.a"]},
54
+ {"name": "GND", "pins": ["D1.b", "V1.n"]},
55
+ ],
56
+ }
57
+
58
+ # Render directly or save to a file
59
+ result = from_netlist(netlist, output="circuit.svg")
60
+ print(f"Saved schematic to {result.output_path}")
61
+
62
+ # Or access the SVG string directly in memory
63
+ svg_markup = result.svg
64
+ ```
65
+
66
+ ### 2. From Natural Language (AI)
67
+
68
+ Set your provider's API key in your environment first:
69
+
70
+ ```bash
71
+ export GEMINI_API_KEY="your-key-here"
72
+ # or for OpenAI: export OPENAI_API_KEY="your-key-here"
73
+ # or for Anthropic: export ANTHROPIC_API_KEY="your-key-here"
74
+ ```
75
+
76
+ Then generate:
77
+
78
+ ```python
79
+ from circuitgen import generate
80
+
81
+ result = generate(
82
+ "A 9V battery powering a red LED with a 330 ohm current limiting resistor",
83
+ provider="gemini",
84
+ output="ai_circuit.svg",
85
+ )
86
+
87
+ print(result.netlist)
88
+ print(result.output_path)
89
+ ```
90
+
91
+ Supported providers: `gemini`, `openai`, `anthropic`, `deepseek`, `groq`, `mistral`, `xai`, `openrouter`, `together`, `fireworks`, `cerebras`.
92
+
93
+ ### 3. Validation
94
+
95
+ Check if a netlist is valid without rendering:
96
+
97
+ ```python
98
+ from circuitgen import validate
99
+
100
+ check = validate(netlist)
101
+ if check.valid:
102
+ print("Netlist is valid!")
103
+ else:
104
+ print("Errors found:", check.errors)
105
+ ```
106
+
107
+ ### 4. Component Symbols
108
+
109
+ List built-in symbols:
110
+
111
+ ```python
112
+ from circuitgen import list_symbols
113
+
114
+ print(list_symbols())
115
+ ```
116
+
117
+ Built-in component types and standard pin names:
118
+
119
+ | Type | Description | Pin Names |
120
+ | --- | --- | --- |
121
+ | `resistor` | Two-terminal resistor | `a`, `b` |
122
+ | `capacitor` | Two-terminal capacitor | `a`, `b` |
123
+ | `inductor` | Two-terminal inductor | `a`, `b` |
124
+ | `diode` | Diode | `a` (anode), `b` (cathode) |
125
+ | `led` | LED | `a` (anode), `b` (cathode) |
126
+ | `switch` | SPST switch | `a`, `b` |
127
+ | `lamp` | Lamp | `a`, `b` |
128
+ | `fuse` | Fuse | `a`, `b` |
129
+ | `battery` | DC battery | `p` (positive), `n` (negative) |
130
+ | `dc_source` | DC power source | `p`, `n` |
131
+ | `ac_source` | AC power source | `p`, `n` |
132
+ | `current_source` | Current source | `p`, `n` |
133
+ | `npn` | NPN BJT | `B` (base), `C` (collector), `E` (emitter) |
134
+ | `pnp` | PNP BJT | `B` (base), `C` (collector), `E` (emitter) |
135
+ | `nmos` | N-channel MOSFET | `G` (gate), `D` (drain), `S` (source) |
136
+ | `pmos` | P-channel MOSFET | `G` (gate), `D` (drain), `S` (source) |
137
+ | `opamp` | Operational amplifier | `IN+`, `IN-`, `OUT`, `V+`, `V-` |
138
+ | `ne555` | 555 timer IC | `GND`, `TRIG`, `OUT`, `RESET`, `CTRL`, `THRES`, `DISCH`, `VCC` |
139
+ | `arduino_uno` | Arduino Uno board | `D0`–`D13`, `A0`–`A5`, `3V3`, `5V`, `VIN`, `GND`, `RESET` |
140
+
141
+ #### Custom Components
142
+
143
+ You can define custom ICs or breakout boards by providing an explicit `pins` list:
144
+
145
+ ```python
146
+ {
147
+ "id": "U1",
148
+ "type": "custom_ic",
149
+ "value": "SensorModule",
150
+ "pins": ["VCC", "GND", "SDA", "SCL"]
151
+ }
152
+ ```
153
+
154
+ *Note: Custom pin lists define logical connection points for the schematic, not physical pin layouts of a specific chip package.*
155
+
156
+ ## Electrical Rule Checking (CLI)
157
+
158
+ Run conservative electrical checks (floating pins, polarity issues) on a netlist:
159
+
160
+ ```bash
161
+ python -m circuitgen.erc path/to/netlist.json
162
+ ```
163
+
164
+ Or output JSON:
165
+
166
+ ```bash
167
+ python -m circuitgen.erc path/to/netlist.json --json
168
+ ```
169
+
170
+ ## Notes & Limitations
171
+
172
+ - CircuitGen is a schematic renderer, not a circuit simulator (like SPICE) or PCB layout tool (like KiCad).
173
+ - Wire routing is orthogonal (Manhattan) and deterministic.
174
+ - Manual netlist workflows are 100% offline and do not require network access or API keys.
175
+
176
+ ## License
177
+
178
+ MIT
@@ -0,0 +1,163 @@
1
+ # CircuitGen
2
+
3
+ A Python library and CLI for generating circuit schematics from text descriptions or netlists.
4
+
5
+ CircuitGen takes a circuit netlist, places components, routes wires, and exports clean SVG schematics. It includes AI translation that converts natural-language prompts into valid netlists using a chosen provider.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install circuitgen
11
+ ```
12
+
13
+ Or install from source:
14
+
15
+ ```bash
16
+ git clone https://github.com/git-ishaan-kumar/circuitgen.git
17
+ cd circuitgen
18
+ pip install -e .
19
+ ```
20
+
21
+ Requires Python 3.10 or higher. No external runtime dependencies.
22
+
23
+ ## Quickstart
24
+
25
+ ### 1. From a Netlist (Offline, No API Key)
26
+
27
+ ```python
28
+ from circuitgen import from_netlist
29
+
30
+ netlist = {
31
+ "components": [
32
+ {"id": "V1", "type": "battery", "value": "9V"},
33
+ {"id": "R1", "type": "resistor", "value": "330Ω"},
34
+ {"id": "D1", "type": "led", "value": "red"},
35
+ ],
36
+ "nets": [
37
+ {"name": "VCC", "pins": ["V1.p", "R1.a"]},
38
+ {"name": "MID", "pins": ["R1.b", "D1.a"]},
39
+ {"name": "GND", "pins": ["D1.b", "V1.n"]},
40
+ ],
41
+ }
42
+
43
+ # Render directly or save to a file
44
+ result = from_netlist(netlist, output="circuit.svg")
45
+ print(f"Saved schematic to {result.output_path}")
46
+
47
+ # Or access the SVG string directly in memory
48
+ svg_markup = result.svg
49
+ ```
50
+
51
+ ### 2. From Natural Language (AI)
52
+
53
+ Set your provider's API key in your environment first:
54
+
55
+ ```bash
56
+ export GEMINI_API_KEY="your-key-here"
57
+ # or for OpenAI: export OPENAI_API_KEY="your-key-here"
58
+ # or for Anthropic: export ANTHROPIC_API_KEY="your-key-here"
59
+ ```
60
+
61
+ Then generate:
62
+
63
+ ```python
64
+ from circuitgen import generate
65
+
66
+ result = generate(
67
+ "A 9V battery powering a red LED with a 330 ohm current limiting resistor",
68
+ provider="gemini",
69
+ output="ai_circuit.svg",
70
+ )
71
+
72
+ print(result.netlist)
73
+ print(result.output_path)
74
+ ```
75
+
76
+ Supported providers: `gemini`, `openai`, `anthropic`, `deepseek`, `groq`, `mistral`, `xai`, `openrouter`, `together`, `fireworks`, `cerebras`.
77
+
78
+ ### 3. Validation
79
+
80
+ Check if a netlist is valid without rendering:
81
+
82
+ ```python
83
+ from circuitgen import validate
84
+
85
+ check = validate(netlist)
86
+ if check.valid:
87
+ print("Netlist is valid!")
88
+ else:
89
+ print("Errors found:", check.errors)
90
+ ```
91
+
92
+ ### 4. Component Symbols
93
+
94
+ List built-in symbols:
95
+
96
+ ```python
97
+ from circuitgen import list_symbols
98
+
99
+ print(list_symbols())
100
+ ```
101
+
102
+ Built-in component types and standard pin names:
103
+
104
+ | Type | Description | Pin Names |
105
+ | --- | --- | --- |
106
+ | `resistor` | Two-terminal resistor | `a`, `b` |
107
+ | `capacitor` | Two-terminal capacitor | `a`, `b` |
108
+ | `inductor` | Two-terminal inductor | `a`, `b` |
109
+ | `diode` | Diode | `a` (anode), `b` (cathode) |
110
+ | `led` | LED | `a` (anode), `b` (cathode) |
111
+ | `switch` | SPST switch | `a`, `b` |
112
+ | `lamp` | Lamp | `a`, `b` |
113
+ | `fuse` | Fuse | `a`, `b` |
114
+ | `battery` | DC battery | `p` (positive), `n` (negative) |
115
+ | `dc_source` | DC power source | `p`, `n` |
116
+ | `ac_source` | AC power source | `p`, `n` |
117
+ | `current_source` | Current source | `p`, `n` |
118
+ | `npn` | NPN BJT | `B` (base), `C` (collector), `E` (emitter) |
119
+ | `pnp` | PNP BJT | `B` (base), `C` (collector), `E` (emitter) |
120
+ | `nmos` | N-channel MOSFET | `G` (gate), `D` (drain), `S` (source) |
121
+ | `pmos` | P-channel MOSFET | `G` (gate), `D` (drain), `S` (source) |
122
+ | `opamp` | Operational amplifier | `IN+`, `IN-`, `OUT`, `V+`, `V-` |
123
+ | `ne555` | 555 timer IC | `GND`, `TRIG`, `OUT`, `RESET`, `CTRL`, `THRES`, `DISCH`, `VCC` |
124
+ | `arduino_uno` | Arduino Uno board | `D0`–`D13`, `A0`–`A5`, `3V3`, `5V`, `VIN`, `GND`, `RESET` |
125
+
126
+ #### Custom Components
127
+
128
+ You can define custom ICs or breakout boards by providing an explicit `pins` list:
129
+
130
+ ```python
131
+ {
132
+ "id": "U1",
133
+ "type": "custom_ic",
134
+ "value": "SensorModule",
135
+ "pins": ["VCC", "GND", "SDA", "SCL"]
136
+ }
137
+ ```
138
+
139
+ *Note: Custom pin lists define logical connection points for the schematic, not physical pin layouts of a specific chip package.*
140
+
141
+ ## Electrical Rule Checking (CLI)
142
+
143
+ Run conservative electrical checks (floating pins, polarity issues) on a netlist:
144
+
145
+ ```bash
146
+ python -m circuitgen.erc path/to/netlist.json
147
+ ```
148
+
149
+ Or output JSON:
150
+
151
+ ```bash
152
+ python -m circuitgen.erc path/to/netlist.json --json
153
+ ```
154
+
155
+ ## Notes & Limitations
156
+
157
+ - CircuitGen is a schematic renderer, not a circuit simulator (like SPICE) or PCB layout tool (like KiCad).
158
+ - Wire routing is orthogonal (Manhattan) and deterministic.
159
+ - Manual netlist workflows are 100% offline and do not require network access or API keys.
160
+
161
+ ## License
162
+
163
+ MIT
@@ -0,0 +1,42 @@
1
+ # BUILD SYSTEM
2
+
3
+ [build-system]
4
+ requires = ["setuptools>=61.0"]
5
+ build-backend = "setuptools.build_meta"
6
+
7
+ # PROJECT CONFIGURATION
8
+
9
+ [project]
10
+ name = "circuitgen"
11
+ version = "0.1.0"
12
+ description = "A Python library and CLI for generating circuit schematics from text descriptions or netlists."
13
+ readme = "README.md"
14
+ requires-python = ">=3.10"
15
+ license = "MIT"
16
+ authors = [
17
+ {name = "Ishaan"}
18
+ ]
19
+ keywords = [
20
+ "circuit",
21
+ "schematic",
22
+ "electronics",
23
+ "circuit-diagram",
24
+ "netlist",
25
+ "svg",
26
+ "circuit-generator",
27
+ "python-library",
28
+ "cli",
29
+ ]
30
+ classifiers = [
31
+ "Programming Language :: Python :: 3",
32
+ "Operating System :: OS Independent",
33
+ ]
34
+ dependencies = []
35
+
36
+ [project.urls]
37
+ Homepage = "https://github.com/git-ishaan-kumar/circuitgen"
38
+
39
+ # PACKAGE DISCOVERY
40
+
41
+ [tool.setuptools.packages.find]
42
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,31 @@
1
+ # PACKAGE METADATA
2
+
3
+ __version__ = "0.1.0"
4
+
5
+
6
+ # PUBLIC API
7
+
8
+ from .api import (
9
+ CircuitResult,
10
+ ValidationResult,
11
+ from_netlist,
12
+ generate,
13
+ list_providers,
14
+ list_symbols,
15
+ render,
16
+ validate,
17
+ )
18
+ from .engine import CircuitError, CircuitModel
19
+
20
+ __all__ = [
21
+ "CircuitResult",
22
+ "ValidationResult",
23
+ "from_netlist",
24
+ "generate",
25
+ "list_providers",
26
+ "list_symbols",
27
+ "render",
28
+ "validate",
29
+ "CircuitError",
30
+ "CircuitModel",
31
+ ]