Skip to main content

Python wrapper for wirelog - declarative dataflow analysis

Project description

PyreWire

CI Docs

The ci workflow runs the full lint gate (black, isort, flake8, mypy) and the test matrix; docs builds and publishes the documentation site.

A Python wrapper for wirelog - a declarative dataflow analysis engine.

Overview

PyreWire provides a Pythonic interface to wirelog, enabling you to write datalog programs and perform analysis programmatically from Python.

Installation

pip install pyrewire

Requirements: CPython 3.11, 3.12, 3.13, or 3.14.

See the support matrix for v1.0 wheel targets and source-install requirements, including supported OS/architecture combinations and libwirelog handling. The API stability policy defines the v1.0 stable public import boundary and deprecation policy.

Quick Start

PyreWire programs are written in wirelog's datalog dialect and driven through one of the high-level surfaces below.

One-shot evaluation with BatchProgram

Use BatchProgram to parse a program, optimize it, and compute the full IDB closure in a single pass:

from pyrewire import BatchProgram

# A tiny reachability program: two edges plus a transitive-closure rule.
src = """
.decl edge(x: int32, y: int32)
.decl reach(x: int32, y: int32)
edge(1, 2). edge(2, 3).
reach(X, Y) :- edge(X, Y).
reach(X, Z) :- reach(X, Y), edge(Y, Z).
"""

with BatchProgram.from_string(src) as program:
    program.optimize()
    result = program.evaluate()
    try:
        print(result.cardinality("reach"))   # 3
        print(result.relation("reach"))      # [(1, 2), (2, 3), (1, 3)]
    finally:
        result.close()

Incremental work with EasySession

EasySession interns strings automatically and lets you insert / remove facts, then either snapshot a relation's full contents or step the engine for incremental deltas. A session commits to a single mode the first time you query it, so use a fresh session per mode:

from pyrewire import EasySession

SRC = """
.decl friend(a: symbol, b: symbol)
.decl mutual(a: symbol, b: symbol)
mutual(A, B) :- friend(A, B), friend(B, A).
"""

# snapshot(): read a relation's full IDB contents.
with EasySession(SRC) as s:
    s.insert("friend", ["alice", "bob"])
    s.insert("friend", ["bob", "alice"])
    print(s.snapshot("mutual"))   # [('alice', 'bob'), ('bob', 'alice')]

# step(): drive one fixpoint step and read the incremental deltas.
with EasySession(SRC) as s:
    s.insert("friend", ["alice", "bob"])
    s.insert("friend", ["bob", "alice"])
    for relation, row, diff in s.step():
        print(relation, row, diff)   # e.g. mutual ('alice', 'bob') 1

For caller-owned programs, backend selection, and NumPy zero-copy inserts, see Session; for asyncio integration see AsyncEasySession, AsyncSession, and AsyncBatchProgram. The Quickstart walks through each surface.

Features

  • Pythonic API over wirelog's declarative dataflow engine
  • Batch closure (BatchProgram) and incremental sessions (EasySession, Session)
  • NumPy zero-copy batched inserts on the advanced Session API
  • asyncio wrappers that satisfy wirelog's single-threaded call invariant

Development

Setup

git clone https://github.com/semantic-reasoning/PyreWire
cd PyreWire
pip install -e ".[dev]"

Running Tests

pytest

Code Quality

black .
isort .
flake8 .
mypy .

Community & Contributing

We appreciate your interest in contributing to PyreWire!

License

PyreWire (Python Wrapper): dual-licensed under either of

at your option.

wirelog (Core Engine): LGPL-3.0 / Commercial Dual License

Note: PyreWire links to the wirelog core engine. Use of the core engine is subject to its respective license terms.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrewire-1.0.0.tar.gz (131.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyrewire-1.0.0-cp314-cp314-win_amd64.whl (270.1 kB view details)

Uploaded CPython 3.14Windows x86-64

pyrewire-1.0.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (247.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pyrewire-1.0.0-cp314-cp314-macosx_11_0_arm64.whl (235.6 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pyrewire-1.0.0-cp313-cp313-win_amd64.whl (264.8 kB view details)

Uploaded CPython 3.13Windows x86-64

pyrewire-1.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (247.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pyrewire-1.0.0-cp313-cp313-macosx_11_0_arm64.whl (235.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyrewire-1.0.0-cp312-cp312-win_amd64.whl (264.8 kB view details)

Uploaded CPython 3.12Windows x86-64

pyrewire-1.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (247.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pyrewire-1.0.0-cp312-cp312-macosx_11_0_arm64.whl (235.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyrewire-1.0.0-cp311-cp311-win_amd64.whl (264.8 kB view details)

Uploaded CPython 3.11Windows x86-64

pyrewire-1.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (247.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pyrewire-1.0.0-cp311-cp311-macosx_11_0_arm64.whl (235.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file pyrewire-1.0.0.tar.gz.

File metadata

  • Download URL: pyrewire-1.0.0.tar.gz
  • Upload date:
  • Size: 131.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyrewire-1.0.0.tar.gz
Algorithm Hash digest
SHA256 36fa182b2747fb793463bc9c21fa9ee9251975c5b286b2d6361445c1a152874c
MD5 0564f1424c62c2b7749dc84a21b33a3d
BLAKE2b-256 095345a053a7deb03c358f1e2860269c1ac74da0d66173c7a7dc6df305aa9f0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.0.tar.gz:

Publisher: release.yml on semantic-reasoning/PyreWire

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrewire-1.0.0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: pyrewire-1.0.0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 270.1 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyrewire-1.0.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 08480a7e9f171955794b9bcd27641856bf8295142a124e5023da7a9f87480fca
MD5 1fa388609ecc9a061b1036bf0315b2bf
BLAKE2b-256 2e818364a194b37f2189707606c2b634ca8a2a8822bd4d6104c0777c4618f516

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.0-cp314-cp314-win_amd64.whl:

Publisher: release.yml on semantic-reasoning/PyreWire

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrewire-1.0.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyrewire-1.0.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b4229661b29ac195ba6bd74598af8a14973b9abc1e4e11f4d42f32efeb35a609
MD5 be6403b7346a1ba55e74deab111edf22
BLAKE2b-256 a1cb6e633f621f6b4e8182d8e14cf45a25333fe86a8a47c15a0a84a8676b06d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on semantic-reasoning/PyreWire

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrewire-1.0.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyrewire-1.0.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4f205835589d21668e8f07b73ae29c023cf0af416294c31515fbec5edc22a2d6
MD5 e0a547224dc7f74edd059d6584764690
BLAKE2b-256 cefe24f8d2d6e86d667846cef040f7dee9264a9c3af83708e188c18ae4a8fe2f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.0-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: release.yml on semantic-reasoning/PyreWire

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrewire-1.0.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pyrewire-1.0.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 264.8 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyrewire-1.0.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 1c4baa31883010386aba681f59b1d76b7e8ba025870a60c75f1ca5953ede02c0
MD5 13a3aa3fbe7de1b458d2737f5ba99a20
BLAKE2b-256 b8632a346843c436a100851aca97c8de93dc0c174ec35febbc250a86ec2d883a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.0-cp313-cp313-win_amd64.whl:

Publisher: release.yml on semantic-reasoning/PyreWire

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrewire-1.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyrewire-1.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 28b794fd038dc03cd9960d0897819536bf8fbb317f883d2299b386b82b5b96dd
MD5 0479f037786f9dbe4c221a1a0530758a
BLAKE2b-256 c87403f3f62a9bb7bf7e6537e8a08f9dee49cfd1990d38201c623a70ebc92db7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on semantic-reasoning/PyreWire

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrewire-1.0.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyrewire-1.0.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bb54d23804083cc232d8398e74c149f82b1542204df2eab6452fa7cdffc3feb8
MD5 90b8a88d49c59d3272cd2de7c97d65b8
BLAKE2b-256 d4ee61eb3c9e12cd394f7a63da177d931a776e29d48c507ab036ad84586058eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on semantic-reasoning/PyreWire

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrewire-1.0.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pyrewire-1.0.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 264.8 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyrewire-1.0.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8023cec90ad67c8aed37d538573cc01d3fde0799034ffceba96a2c070fef15dc
MD5 e3811e583eac447e75c0b845aeedd743
BLAKE2b-256 27e67fee45a7a2280b9ec43844893427e041a0d401f4a0901b7d1034fc503390

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.0-cp312-cp312-win_amd64.whl:

Publisher: release.yml on semantic-reasoning/PyreWire

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrewire-1.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyrewire-1.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a766a78dc67e048d851230174f73dcb1985a7c91a1317e078fdddb8e418ab698
MD5 5f8de8e33a94902002fc766107dc21da
BLAKE2b-256 003fd7aa207dfa498899da4a2d9600eef05334a8d285f7897cb9267568fd97c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on semantic-reasoning/PyreWire

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrewire-1.0.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyrewire-1.0.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 38e74bb66174ab31060d8a5371f1c16eac2572746104aa81de957b70bf9465d0
MD5 0b1f90641d053fcc6ba0f7a643127678
BLAKE2b-256 8536685f204c85f61999ede8a08de50eafa69ce4d77bd907827b682e21aaaf03

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on semantic-reasoning/PyreWire

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrewire-1.0.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pyrewire-1.0.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 264.8 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyrewire-1.0.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c9a41abb658140d7cd5badb2b2d75e21be63902eabd592d2403a8fb8e378d21f
MD5 5c4ac57d11de3f572b3fcd3385b18a16
BLAKE2b-256 c961b032ce460d24dce8ac132579bd8c0583abb4303ae0e91345927f76321243

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.0-cp311-cp311-win_amd64.whl:

Publisher: release.yml on semantic-reasoning/PyreWire

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrewire-1.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyrewire-1.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4ea4c20f435a94d68ad215a3e91fa70fc23325b009d73e62b280f15572bd846a
MD5 880990ae144711566c792d4b489fe89a
BLAKE2b-256 ed842dfbdcb66077b0e09435c28608bd2e265db31e3164967413401eff041a73

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on semantic-reasoning/PyreWire

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrewire-1.0.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyrewire-1.0.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7ec07fd5c62778b7e154aee61f66fef543b6e018abd965b3b13346766b8a6d03
MD5 ae867c5b5f17bb544011321536ec9850
BLAKE2b-256 159810f78919ceb5f8d0a6abd63063b9233c6e431a46dec54efd03f6a70c1489

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on semantic-reasoning/PyreWire

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page