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.1.tar.gz (131.9 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.1-cp314-cp314-win_amd64.whl (270.1 kB view details)

Uploaded CPython 3.14Windows x86-64

pyrewire-1.0.1-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.1-cp314-cp314-macosx_11_0_arm64.whl (235.6 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.13Windows x86-64

pyrewire-1.0.1-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.1-cp313-cp313-macosx_11_0_arm64.whl (235.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

pyrewire-1.0.1-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.1-cp312-cp312-macosx_11_0_arm64.whl (235.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

pyrewire-1.0.1-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.1-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.1.tar.gz.

File metadata

  • Download URL: pyrewire-1.0.1.tar.gz
  • Upload date:
  • Size: 131.9 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.1.tar.gz
Algorithm Hash digest
SHA256 35d7bcdbf4a5c1970c89b5ae72778a3bf02edf5330cdd764a658752460a73cbb
MD5 a2d6b77d42373a5743213c1d593953a0
BLAKE2b-256 871461f6225823294ed0bf0abd22dce049b4f3d0c589b512d77f21a71ea8f753

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyrewire-1.0.1-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.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 c4c1018e430505dc8b860395c7dc1cc9853a263942c152e74a376087eca46a02
MD5 b7359c5c5ca92ca30b02137546833713
BLAKE2b-256 aed1f1d440dd9a5d63568473439a5825f1960e4f9a2a9ea48a9098353f169d1e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.1-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.1-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.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 157ec1ab31fd9fc7c7871353a657f7e070f13651534a4c380a2c2a036a2076ec
MD5 904e27d34497b4fec0075eeb3dbdbb0b
BLAKE2b-256 d17ff0a4a135c4fd123d17b1880f60c8f204c3ee7eac5e924560a4529ee5c694

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyrewire-1.0.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e32095a64586684a2e7423f1224a698c7b8d3c0f577e60b7a6ef1cb4af528dc4
MD5 e3ba2c048541d7cfc56059ca0333275b
BLAKE2b-256 a7cbcd7e17ce73aa6628e04c8d3bfec23547e11a35de6026334e1deeaf5557d7

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyrewire-1.0.1-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.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 5fc78e5394c6a557e50efe5bec98fc5a764b7c8d151b9105b9aae871a5012ef2
MD5 82e11743c78d75b9d0ffbe0f1c1cc229
BLAKE2b-256 c105c2ad1a5388557d6da6296567112d8931d6eed129ff787f64ff93a0c7e391

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.1-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.1-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.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f184fae6d066b5f7a45022bef4199f712b47f037c9849d3ec74e7eccb44e8692
MD5 633a67c4482906acd811d37269e8cef1
BLAKE2b-256 1aafd09471fb32a4a17ded4b49afeda2feb56539f0b75afbafecb6bdbdc9737b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyrewire-1.0.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 37131479ed1d4f1baaecd67d8d68a599fd8fcc9bcee9aa2f9e281293a7ade7cd
MD5 c630b9eff69e5a98e7bc329839199db5
BLAKE2b-256 46c7930bd26e2dd3350fe860ce0f79b64dd05d6310741ed5b08294e2670bf263

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyrewire-1.0.1-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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0d1ac33dcc25174fc70219719721caa6aee1fe491e93f76fef738f1594a906cf
MD5 527a127c4436db2f0d9e56a743168c15
BLAKE2b-256 6cfc75fbc15d49fa6b3fcdae4b27230fdd0a734d7bb3709090a58eda17c4493f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.1-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.1-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.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cc967215a107b0b9bbcaffb685ebdab3b8084978e8f071ff4c9cb7796ddf98b6
MD5 bc3704d860e312ceb802e98964633f44
BLAKE2b-256 822a8333dd15c771ddf0ce3b1d2c5efa3f4e7dfd81ce8a4eec357d329a558c93

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyrewire-1.0.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 39065a0206b79539a1dc78347e0719a14606c260bf9f188f41b6c50f2f0030f3
MD5 009471355c973bc3238e2bbc5f9e5cd2
BLAKE2b-256 3196c50c220198558cdbc68e12eaffb11c88c751a73e193a95a2028914804895

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyrewire-1.0.1-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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e32adc54cc0598a8cd56e14ede3c7e0b930b1bd571632478fefb12845fd0c74d
MD5 9cfaa8e40de25ea16cf00eedd74fe24d
BLAKE2b-256 5ac0f87f80c75c0b4762609c6ee15df7f1ad3bf6ed4f89c362c901950cfaa081

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.1-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.1-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.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8eb02a7b11b99751e03c30b6ab76120d9b194a678d3df9440ac71ce308dce495
MD5 1b98c92e9f750f7c7e34acb0218553e1
BLAKE2b-256 0bbf90387e6e62aabb7c91bb1b9d83835bbc7d95aa865fbc55bb1f59560fe143

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyrewire-1.0.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 215a4462fed2bbe94dec00ca2dc5771970bb62b1eb0aef44c6af0163b540ba7f
MD5 8a87cff1320a47037b87d815fb05f1b6
BLAKE2b-256 b026aed20902ba122ebaa5526d5f58de85f840323573e954c4863024998b69cb

See more details on using hashes here.

Provenance

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