Metadata-Version: 2.5
Name: proteus2py
Version: 0.2.0
Summary: Script Proteus 8 from Python and AI assistants: headless ProSPICE simulation (SPICE decks, OP/AC/transient/DC/noise), Proteus's own graphs and screenshots, MCP server. Linux (sandboxed Wine).
Project-URL: Homepage, https://github.com/DontforgetAntaiku/proteus2py
Project-URL: Issues, https://github.com/DontforgetAntaiku/proteus2py/issues
Project-URL: Changelog, https://github.com/DontforgetAntaiku/proteus2py/blob/main/CHANGELOG.md
Author: DontforgetAntaiku
License-Expression: MIT
License-File: LICENSE
Keywords: circuit-simulation,education,electronics,isis,mcp,prospice,proteus,proteus-8,spice,wine
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Education
Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
Requires-Python: >=3.10
Requires-Dist: mcp>=2.3
Requires-Dist: pillow>=10
Provides-Extra: dev
Requires-Dist: matplotlib>=3.8; extra == 'dev'
Requires-Dist: numpy; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
Requires-Dist: mkdocs>=1.6; extra == 'docs'
Provides-Extra: fast
Requires-Dist: numpy; extra == 'fast'
Provides-Extra: plot
Requires-Dist: matplotlib>=3.8; extra == 'plot'
Description-Content-Type: text/markdown

<h1 align="center">proteus2py</h1>

<p align="center">
  <b>Script Proteus 8 from Python.</b><br>
  Simulate with Proteus's own engine, let Proteus itself draw the schematic, and export <b>Proteus's own numbers and pictures</b>.<br>
  Linux (sandboxed Wine) · Windows (experimental) · AI-ready (MCP)
</p>

<p align="center">
  <a href="https://github.com/DontforgetAntaiku/proteus2py/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/DontforgetAntaiku/proteus2py/actions/workflows/ci.yml/badge.svg"></a>
  <a href="https://dontforgetantaiku.github.io/proteus2py/"><img alt="docs" src="https://img.shields.io/badge/docs-GitHub%20Pages-blue"></a>
  <a href="https://pypi.org/project/proteus2py/"><img alt="PyPI" src="https://img.shields.io/pypi/v/proteus2py"></a>
  <img alt="Python" src="https://img.shields.io/badge/python-3.10%E2%80%933.13-blue">
  <a href="https://github.com/DontforgetAntaiku/proteus2py/blob/main/LICENSE"><img alt="MIT" src="https://img.shields.io/badge/license-MIT-green"></a>
</p>

<p align="center">
  <img src="https://raw.githubusercontent.com/DontforgetAntaiku/proteus2py/main/docs/assets/native_schematic.png" width="80%" alt="two-stage RC low-pass, placed and wired by Proteus under proteus2py's control">
</p>
<p align="center">
  <img src="https://raw.githubusercontent.com/DontforgetAntaiku/proteus2py/main/docs/assets/native_graph.png" width="80%" alt="Proteus's own transient graph of that circuit: input and both filter stages">
</p>

> **You need your own licensed Proteus 8 Professional** (on Linux: installed in a Wine prefix). proteus2py is an independent project, not affiliated
> with or endorsed by Labcenter Electronics, and ships no Proteus code, libraries or models: it drives the copy you already have.

---

## Why

Proteus is a capable simulator that many universities teach with, but it has **no scripting interface**: every lab means placing parts by hand,
reading values off graphs and pasting screenshots. proteus2py automates that **using Proteus itself**.

- 🔢 **Fast numbers.** Proteus's simulation engine (ProSPICE) is driven directly, about 2 s per run, no window: operating point, transient, AC,
  DC sweep (nested), noise and distortion.
- 🧾 **Results people accept.** When a result must come from Proteus, Proteus draws the schematic, simulates the graph and writes the data file
  itself. `evidence` packs it with screenshots and SHA-256 checksums.
- 📷 **Native pictures.** Schematics and graphs are captures of Proteus: its symbols, wires and graph windows. Nothing is re-plotted.
- 📚 **Your library.** 4000+ SPICE models and 37k device-library parts (BC547, 2N2222, 1N4007, TL072, LM324 ...).
- 🛡️ **Safe by design.** On Linux everything runs in a bubblewrap sandbox (no network, empty `$HOME`). Xvfb, Wine and Proteus exist only for the
  duration of one call.
- 🤖 **AI-ready.** A built-in [MCP](https://modelcontextprotocol.io) server with 25 tools.

## Two ways to get a result

| | **Headless** | **Proteus-authored** |
|---|---|---|
| You give | a SPICE deck, a JSON circuit or an existing `.pdsprj` | parts, wires and graphs |
| Who computes | ProSPICE, Proteus's engine, run directly | Proteus, in its own window |
| You get | numbers in Python, CSV, measurements, plots | a `.pdsprj` Proteus saved, Proteus's `.dat` export, screenshots, checksums |
| Time | seconds | minutes |
| Use it for | design, sweeps, Monte Carlo, checking answers | the files you hand in |

## A 60-second tour

**Headless numbers**

```python
from proteus2py import sim, spice

deck = """RC low-pass
V1 in 0 AC 1
R1 in out 1k
C1 out 0 159.155n
.ac dec 100 10 100k
"""
r = sim.simulate(spice.parse(deck), "rc")      # Proteus's engine, no window
print(r.gain["v(out)"].f_high_3db)             # 1000.1 (Hz)
```

**Proteus-authored results**

```python
from proteus2py import native, server

native.build_native("rc_demo", parts=[         # coordinates are thou (1/1000 inch)
    {"id": "VIN", "kind": "generator", "device": "SINE", "x": 0, "y": 0, "name": "VIN", "amplitude": "1", "frequency": "1k"},
    {"id": "R1", "device": "RES", "x": 1500, "y": 0, "value": "1k"},
    {"id": "C1", "device": "CAP", "x": 3000, "y": -800, "value": "100n"},
    {"id": "GND", "kind": "terminal", "device": "GROUND", "x": 3000, "y": -1400},
    {"id": "OUT", "kind": "probe", "device": "VOLTAGE", "x": 4500, "y": -300},
], wires=[
    {"from": "VIN.0", "to": "R1.0"}, {"from": "R1.1", "to": "C1.0"},
    {"from": "C1.1", "to": "GND.0"}, {"from": "OUT.0", "to": "C1.0"},
], graphs=[
    {"type": "ANALOGUE", "x1": -500, "y1": -1900, "x2": 4500, "y2": -3400, "stop": "5m",
     "traces": [{"name": "Vin", "probes": ["VIN"]}, {"name": "Vout", "probes": ["OUT"]}]},
])                                             # Proteus places, wires, simulates and saves

report = server.evidence("rc_demo")            # Proteus simulates and exports
print(report.graphs[0].columns)                # ['TIME', 'Vin', 'Vout']
for f in report.files:
    print(f.kind, f.path, f.sha256)            # project, screenshot, graph data, graph view
```

## Install

You need **Python 3.10 or newer** and your own **Proteus 8 Professional**.

### Step 1 - install the Python package

```bash
python3 -m venv ~/proteus2py-env
source ~/proteus2py-env/bin/activate
pip install proteus2py                       # extras: "proteus2py[plot,fast]" for plots and faster harmonics
```

`build_native` also needs a small hook DLL, which ships in the package **from version 0.2.0**. With 0.1.0, or for development, build it from source
(needs `make` and the `i686-w64-mingw32-gcc` compiler; Debian/Ubuntu: `gcc-mingw-w64-i686`):

```bash
git clone https://github.com/DontforgetAntaiku/proteus2py && cd proteus2py
make -C native package && pip install .
```

### Step 2 - connect Proteus

<details open><summary><b>Linux</b> (Proteus runs in a sandbox: Wine + virtual display)</summary>

```bash
# 1. system packages: wine, bubblewrap, Xvfb, xdotool, ImageMagick
# 2. install Proteus 8 once into a Wine prefix, to the default folder, and activate your licence
WINEPREFIX=~/.wine-proteus wine /path/to/Proteus8Pro_setup.exe
# 3. create the sandbox copy (about 2 GB; links into your home folder are removed from the copy)
proteus2py setup ~/.wine-proteus
proteus2py doctor
```
</details>

<details><summary><b>Windows</b> (experimental)</summary>

Headless simulation runs the installed `PROSPICE.EXE` directly. Set `PROTEUS_DIR` if Proteus is not in `Program Files (x86)`.
The GUI driver **has not been tested on real Windows**, and `build_native` is Linux only.
More in the [Windows page](https://dontforgetantaiku.github.io/proteus2py/windows/).
</details>

Step-by-step guide and troubleshooting: [Getting started](https://dontforgetantaiku.github.io/proteus2py/getting-started/).

## What it can do

| Area | Features |
|---|---|
| **Circuits** | SPICE decks (`.model`, `.subckt`, `.param`) · strict JSON circuits · R C L V I D Q J M E G F H K S W B X, ideal op-amp, digital gates, pattern generators and DSIM primitives |
| **Analyses** | operating point · transient · AC · DC sweep (nested curve families) · noise · distortion · automatic retry on convergence trouble |
| **Measurements** | -3 dB bandwidth · THD and harmonics · rise time and overshoot · expressions of probes (`db(v(out)/v(in))`, input impedance) · parameter sweeps · Monte Carlo · plots |
| **Existing projects** | simulate a `.pdsprj` without opening Proteus (netlist read from the file) · or open it, run its graph and capture the netlist Proteus produces |
| **Schematics** | `build_native`: any library device, placed and wired by Proteus · values · sine generators · probes · terminals · instruments · graphs with traces · every step checked against Proteus's own object list |
| **Pictures and data** | schematic and graph screenshots · Proteus's full-size graph window · Export Graph Data (`.dat`) · evidence bundle with SHA-256 manifest |
| **AI** | MCP server with 25 tools ([tool reference](https://dontforgetantaiku.github.io/proteus2py/tools/)) |
| **Tooling** | `proteus2py setup / doctor / spice / mcp` · offline tests in CI · opt-in tests against real Proteus · MkDocs site |

## Use it from an AI assistant

**Claude Code:**

```bash
claude mcp add proteus -- uvx --from proteus2py proteus2py-mcp
```

**Claude Desktop and other MCP clients:**

```json
{ "mcpServers": { "proteus": { "command": "uvx", "args": ["--from", "proteus2py", "proteus2py-mcp"] } } }
```

`build_native` needs version 0.2.0 or a source install (see Step 1).

> "Build an RC low-pass with a 1 kHz corner in Proteus, run a transient graph and give me Proteus's data file and screenshots."

An example session: [transcript](https://dontforgetantaiku.github.io/proteus2py/transcript/).

## How it works

```
 your script / AI ─▶ sim · spice · native · evidence                     (Python)
                          │
          ┌───────────────┴────────────────────────┐
     headless                                 Proteus window
     SDF netlist ─▶ PROSPICE.EXE              Pick Devices, wire tool, graphs (mouse and keyboard)
     binary results ─▶ decoder                p2hook.dll inside PDS.EXE reads Proteus's live design back
          └───────────────┬────────────────────────┘
        Linux: bubblewrap + Wine + Xvfb   ·   Windows: native (experimental)
```

The file formats and the engine's behaviour were worked out by reverse engineering:
[ProSPICE notes](https://dontforgetantaiku.github.io/proteus2py/NOTES_prospice/) · [`.pdsprj` format](https://dontforgetantaiku.github.io/proteus2py/PDSPRJ/) ·
[Proteus-authored results](https://dontforgetantaiku.github.io/proteus2py/native/).

## Status and honesty

- **Linux/Wine** is the tested path, developed against one Proteus 8.11 install.
- Checked against theory: RC step response (0.03 %), RC -3 dB point (1000.09 Hz), resistor thermal noise (1e-4), BJT bias point and output
  characteristics, OP07 gain-11 amplifier (5.5002 V), ideal transformer ratio.
- The two-stage RC filter in the pictures gives 0.497 V at 1 kHz for 1 V in (formula: 0.505 V).
- **Microcontroller (VSM) models are not supported** in headless runs, nor is `.INCLUDE` of files from your computer.
- **`build_native` is young:** Linux only; relies on the memory layout of the 8.11 build; slow (minutes); only sine generators can be edited;
  parts cannot be rotated through the spec; overlapping parts and crossing wires are not checked.
- A graph that sits partly off screen gives no full-size graph picture. Keep graphs above y = -3400.
- `build_design`, the older file generator, knows only a handful of devices.

## Documentation

Full guide, analyses and tool reference: **<https://dontforgetantaiku.github.io/proteus2py/>** (sources in
[`docs/`](https://github.com/DontforgetAntaiku/proteus2py/tree/main/docs)).

## Contributing

Reports for other Proteus 8 versions, verified element mappings, measurement helpers and Windows test results are welcome, see
[CONTRIBUTING.md](https://github.com/DontforgetAntaiku/proteus2py/blob/main/CONTRIBUTING.md). Please **never** commit Proteus binaries,
licence data, decompiled code, library dumps or other people's designs.

## License

[MIT](https://github.com/DontforgetAntaiku/proteus2py/blob/main/LICENSE) © 2026 DontforgetAntaiku.

`proteus2py` is an independent project. Proteus and ISIS are trademarks of Labcenter Electronics Ltd.; this project is not affiliated with,
endorsed by or sponsored by Labcenter, and it does **not contain or distribute Proteus**.
