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.3.tar.gz (135.7 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.3-cp314-cp314-win_amd64.whl (273.7 kB view details)

Uploaded CPython 3.14Windows x86-64

pyrewire-1.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (251.0 kB view details)

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

pyrewire-1.0.3-cp314-cp314-macosx_11_0_arm64.whl (239.1 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pyrewire-1.0.3-cp313-cp313-win_amd64.whl (268.4 kB view details)

Uploaded CPython 3.13Windows x86-64

pyrewire-1.0.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (251.0 kB view details)

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

pyrewire-1.0.3-cp313-cp313-macosx_11_0_arm64.whl (239.1 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyrewire-1.0.3-cp312-cp312-win_amd64.whl (268.4 kB view details)

Uploaded CPython 3.12Windows x86-64

pyrewire-1.0.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (251.0 kB view details)

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

pyrewire-1.0.3-cp312-cp312-macosx_11_0_arm64.whl (239.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyrewire-1.0.3-cp311-cp311-win_amd64.whl (268.4 kB view details)

Uploaded CPython 3.11Windows x86-64

pyrewire-1.0.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (251.0 kB view details)

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

pyrewire-1.0.3-cp311-cp311-macosx_11_0_arm64.whl (239.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: pyrewire-1.0.3.tar.gz
  • Upload date:
  • Size: 135.7 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.3.tar.gz
Algorithm Hash digest
SHA256 3a7dfa868e2c5de225410f9362c6dc189725f154d621da91cc3f1bd77515a4fc
MD5 432ba58253cea0bcff4d91aae7b7daca
BLAKE2b-256 7bca609e09fcafa04411b2373e8db606e985f22532d0a99a40764f7383ea7b18

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.3.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.3-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: pyrewire-1.0.3-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 273.7 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.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 80dde6002ea4eacf33d6e8b7df3b917dbcabbb3fc5817f6104a3171dd0149783
MD5 ed7618b41cbbd0b3c4333cad12b9def4
BLAKE2b-256 1334cff2d949df7bc3f34825b24f1cb2f2327307a7ab5aa11029d29a62218f5b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.3-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.3-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.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d0d491f91686dfeb342a69fdd4d5385e7ce0bd5526ed7b95a3789ba0b50ac648
MD5 8964a5a16ba9ac77ddcdd5c66f19f4cb
BLAKE2b-256 792ee23af15637d5ca6f684068dacd162a9f2b9a5d59d62a1b985574ffbbebda

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.3-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.3-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyrewire-1.0.3-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a10298532f9e8f215130fff34c33380a04d0d1343bce6fad6d901969f2e2c985
MD5 ec5ec338f3299a887e9e1d1d6598154d
BLAKE2b-256 9c087c45b7588fef1efb29600c71bc6dd4a98bf81df82bc135b2c07f3489481b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.3-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.3-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pyrewire-1.0.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 268.4 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.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 9e13f4c3cdfb36c2030a357a078a48664123f383dc08bbc6e666e0cf95edf1a2
MD5 a09f4a0232de772c0a9d1cd299bb431e
BLAKE2b-256 0ed48cfb03ad3056ec823772056f66e99847d6a75a4c1f1d872f5574fb5eec91

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.3-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.3-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.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3c1b7e0b159d6ff6a4eed426b46e512718c8a0695c69c2f556314b7641781402
MD5 6fa02a02e22bba78b2c1d87a98985e9f
BLAKE2b-256 8a6f504d23185bd31e68ee97d04b6a698982894fb2e9af9f53502fe2d926b581

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.3-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.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyrewire-1.0.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 852687c81da5a8e42d706002f365a271c34305a0dda6a2fd4395a3d83de82ac7
MD5 691a6bf36a72975bc71e430eb9d44f66
BLAKE2b-256 908d2428e25ce049b56f008ef6614b0855e1611b57b9e26899b7fad194a98bf8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.3-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.3-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pyrewire-1.0.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 268.4 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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a97de44340887faf755b0b0f93ec8f1bf47d7bca5b06c233656642185a480ae5
MD5 fe53c8ca9c4d5db59c7f3966bf0e2823
BLAKE2b-256 212903bb964af1159f80ea57d728a31ab3c682e59dbfb5088544931170bcece0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.3-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.3-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.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bd2ecec466ab0eec9f1c3dc8f9b4d9e40156184277f91f17023458c170fc302a
MD5 e2cfbe289d8d9a78037f9fcb1a2bdab1
BLAKE2b-256 89a15c4fd95acf1d5f14bb89cb1592f378d19a98f1afb30330c9cebd7a5c8f43

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.3-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.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyrewire-1.0.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bbbb4fa9c943a88ea18741ba5704c138d6bb99c683530b51b50d1e79b5fc3882
MD5 03d7648cafde7e1909e8e867b175b02c
BLAKE2b-256 7c2e9598bab6c57e924fe8d9d5746036d795f97e55667a8b306d8801047b206a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.3-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.3-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pyrewire-1.0.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 268.4 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.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a327bae9e153c0fa18919e2798c0bf57576d5caa58fc13b1944505c77b947f6d
MD5 4b5df5d4ae391ad3b3c8ee331e35e3b7
BLAKE2b-256 68e49b2b598f98ddb828d39372cd92d0975553ee7bce30f823d1aa81744a9798

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.3-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.3-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.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6b3996e743ae9f39c3299fbf701a5a6c56a2744f98bce4ed321c2a991d754954
MD5 59c57d1d48ef7055287a4a21029ea366
BLAKE2b-256 0cf9081763030c7c5b2bb43658a1131d0ea62aa689be38307de458fd0a3e3a29

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.3-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.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyrewire-1.0.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 39f67216db9863dff7d5f37e351b499a648d2df28c317b3e26397b0e12f7eda2
MD5 25870a74c13bcb6d3550d46195f46ff8
BLAKE2b-256 f8781198f7b1aa34595a703defa390a155a96d7b6d7c17edc89e024ea4aab71f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.3-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