Metadata-Version: 2.4
Name: pyvisa-rs
Version: 0.1.8
Requires-Dist: pyvisa>=1.13
Requires-Dist: libusb-package>=1.0.26.1
License-File: LICENSE
License-File: LICENSE-pyvisa-py
License-File: NOTICE
Summary: Rust-backed VISA backend for PyVISA, powered by rsvisa-rs.
Author: Alexander Hill
License-Expression: Apache-2.0
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Changelog, https://github.com/nominal-io/rsvisa-rs/blob/main/CHANGELOG.md
Project-URL: Homepage, https://nominal.io
Project-URL: Repository, https://github.com/nominal-io/rsvisa-rs

# pyvisa-rs

A PyVISA backend powered by [`rsvisa-rs`](https://github.com/nominal-io/rsvisa-rs), a Rust port of
pyvisa-py. Select it from PyVISA with the `@rs` library spec.

## Install

```bash
pip install pyvisa-rs
```

To build from a clone of this repo, with an activated virtualenv:

```bash
cd pyvisa-rs
maturin develop
```

This builds the Rust extension and installs the `pyvisa-rs` package
into the current environment. PyVISA discovers it automatically via its
`pyvisa_*` package scan.

## Usage

```python
import pyvisa

rm = pyvisa.ResourceManager("@rs")

print(rm.list_resources())

with rm.open_resource("TCPIP::192.168.1.10::INSTR") as instr:
    instr.timeout = 5000
    print(instr.query("*IDN?"))
```

That's it — once `"@rs"` is passed to `ResourceManager`, the rest of
the PyVISA API works exactly as it does against any other backend.

## Backends supported

The Rust backend mirrors pyvisa-py's transports:

- `TCPIP::...::INSTR` (VXI-11)
- `TCPIP::...::SOCKET`
- `TCPIP::...::HISLIP`
- `USB::...::INSTR` / `USB::...::RAW`
- `ASRL...::INSTR` (serial)

### USB

USB uses libusb, which pyvisa-rs gets from its
[`libusb-package`](https://pypi.org/project/libusb-package/) dependency
(the same libusb pyvisa-py's `usb-full` extra installs). Without that
package, a system libusb is used instead.

As with pyvisa-py, on Windows each USB instrument needs a generic WinUSB
driver, for example installed with [Zadig](https://zadig.akeo.ie/).
Instruments bound to a vendor USBTMC driver (NI-VISA, Keysight IO
Libraries) aren't reachable through libusb.

## Comparing against pyvisa-py

`examples/discovery.py` runs `list_resources()` through both backends
and diffs the results:

```bash
uv run --with pyvisa --with pyserial --with pyusb \
       --with libusb-package --with zeroconf --with pyvisa-py \
       examples/discovery.py
```

Pass `--reinstall-package pyvisa-rs` after editing Rust sources — uv's
wheel cache does not invalidate on Rust source changes.

## License

Licensed under the Apache License, Version 2.0. pyvisa-rs is built on a
port of [pyvisa-py](https://github.com/pyvisa/pyvisa-py) (MIT License);
see the `LICENSE`, `LICENSE-pyvisa-py` and `NOTICE` files shipped with
this package.

