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.2.tar.gz (135.5 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.2-cp314-cp314-win_amd64.whl (273.2 kB view details)

Uploaded CPython 3.14Windows x86-64

pyrewire-1.0.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (250.7 kB view details)

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

pyrewire-1.0.2-cp314-cp314-macosx_11_0_arm64.whl (238.7 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pyrewire-1.0.2-cp313-cp313-win_amd64.whl (267.9 kB view details)

Uploaded CPython 3.13Windows x86-64

pyrewire-1.0.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (250.7 kB view details)

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

pyrewire-1.0.2-cp313-cp313-macosx_11_0_arm64.whl (238.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyrewire-1.0.2-cp312-cp312-win_amd64.whl (267.9 kB view details)

Uploaded CPython 3.12Windows x86-64

pyrewire-1.0.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (250.7 kB view details)

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

pyrewire-1.0.2-cp312-cp312-macosx_11_0_arm64.whl (238.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyrewire-1.0.2-cp311-cp311-win_amd64.whl (267.9 kB view details)

Uploaded CPython 3.11Windows x86-64

pyrewire-1.0.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (250.7 kB view details)

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

pyrewire-1.0.2-cp311-cp311-macosx_11_0_arm64.whl (238.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: pyrewire-1.0.2.tar.gz
  • Upload date:
  • Size: 135.5 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.2.tar.gz
Algorithm Hash digest
SHA256 fb541507f8feb7ee0c114afcb5860ac75cc777eaf82734260a5de508cd5dfcf6
MD5 bb4713c42fd4d5e6400b023ab719ebed
BLAKE2b-256 634641f1b303c40031217fc3a8f2dc20331820751928e0dff66a91971ec27f4c

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyrewire-1.0.2-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 273.2 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.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 e6a715d459f752cd2b0c22c54254e0095ddabd9c6c9af6819a479e91aa491b1f
MD5 4dc4604faf0c85cbb4dbbde3a3a331aa
BLAKE2b-256 50f76ec01f2cf5ad60f863fa5a4cf2bd4823be226896a6a33f9a0284607395ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.2-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.2-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.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 94523d7b657cf431fd935071abe3e826839ae6bd8730150628256b690c84cd26
MD5 247df8f957052926a6954b4242135859
BLAKE2b-256 35954980361925c9de9cf0b268d6e525603cccecaa7c48e3efd48aaa01cfbdc2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyrewire-1.0.2-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 702a4b774bc0bf332d2ea8fab75deaf4fd91ca7acf906fc89418f4bc6d38e3ab
MD5 7a5c2bfc9fdbefd6139fe26a8c069ce0
BLAKE2b-256 6ff8d06c1e033250344bfe46d23acf4cb1c5bde9a04d5c79714cdb3ec60414ef

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyrewire-1.0.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 267.9 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.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 b8fa6479aab8e69757111bb5fed846b888d101aabd1d99cb56673f0ca631973d
MD5 5b4638ddf4a838c3890f6a31164f6f0c
BLAKE2b-256 2cb25c46eb9e3c5caefe6a2f3240df433e390700fe23b768fda85d58cb42f4a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.2-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.2-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.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a95217e818386fbeb13a5c47980e71f1f617b223735405071fbf1bb0461a5b53
MD5 376f646325193c898c2c6b0648aba118
BLAKE2b-256 59b72744daa4ba3c48bbed220dac0c03161bec5517d81329bf42b974a9377f51

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyrewire-1.0.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 01d92ec12d18fd6bcd91a17555e2155f36e98ef9f9272201b9e54c6d2d2c211c
MD5 a73360dd411e40fedf351c9ba1183e26
BLAKE2b-256 2a2aefa145d598ee0a0998a52abdf3a41f7ad0f3706d63bceda908fb7513207f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyrewire-1.0.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 267.9 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.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 267fbe610c00e2cf82ac48379b8de6cae14d6a8ea3998a525263664ec51ab9a6
MD5 5b8ab736780d171c9b7a0224ea38a40b
BLAKE2b-256 00c2ad88406b563680e692149f469623f4104d15238035766d39d61f5e032600

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.2-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.2-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.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f986fb329d5e513f7de3a75012c52fbee06c8e536153c5c418bfce580732fe81
MD5 906512a45f99c6f0c8860a5c37056795
BLAKE2b-256 5b27a76b259ccf0f7702ab7d64b90834b6e1e9bb7fe45f540bc843f97c4ac75b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyrewire-1.0.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 951bb677bc72a6fb74aeacfaab46595c509566321a38c35603defa4c51945cb1
MD5 f768f632487e30abe4d9cf106ff48f81
BLAKE2b-256 3f2cd957ea3c9c2a9d66fa29293c8300b00ac5d149b387fb7889f0d9f73668c9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyrewire-1.0.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 267.9 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.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 bb3a00c4ee82ed69208d650b2649911eda96aca99ccebcc6c4d6a0a2ac0e4339
MD5 f5dce09ebfc223bd6f52a77db735c88b
BLAKE2b-256 68d3b14d7356e15acd53f0395f7b1015caacf2f45dbb7d4652016b395237bc13

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrewire-1.0.2-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.2-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.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 369302871adb3f9cbbb2ae9652dfe6539d6d2d6fdd8d1f8016f0e60f341b7596
MD5 86692830cac223273e2df7aa778ccf1b
BLAKE2b-256 fad4e4eae9f07eaa1c468f7a54229db5b02de82955ae13b7142722cecc6767f1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyrewire-1.0.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2c61857fc1bfcee6662bb89262725923cc30a857cccaa177b1a5b9393e64f2fe
MD5 a638c20c0cd3ac89e80f50870ee61cac
BLAKE2b-256 ea6f759a3146ea679fd3071d1767b83955ca5901e7f667f452aa7d9bcdd2380b

See more details on using hashes here.

Provenance

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