opa-golib-python-bindings
Python bindings for the OPA Rego engine, embedding
github.com/open-policy-agent/opa/v1/rego via a Go c-shared library and a stdlib-only
ctypes wrapper.
Build
Requires Go >= 1.26 and Python >= 3.14.
make build # builds src/opa_bindings/libopabridge.so
make test # builds + runs pytest
Usage
from opa_bindings import OpaEngine
users = {"alice": {"role": "admin"}}
with OpaEngine() as engine:
engine.add_policy("authz.rego", """
package authz
allow if lookup_user(input.user).role == "admin"
""")
engine.add_data({"admin": ["alice"]}, path="roles") # deep-merged; conflicts raise
engine.register_function("lookup_user", lambda name: users.get(name))
engine.eval_document("authz.allow", {"user": "alice"}) # -> True
engine.eval_query("x = data.roles.admin[_]") # -> [{"x": "alice"}]
Notes:
add_datadeep-merges objects; identical values coexist, conflicting values raiseOpaError(code="merge_conflict")naming the conflicting path.register_functioninfers arity from the callable's signature. A*argsfunction is variadic and is called from Rego with a single array argument:many(["a", "b"])(OPA does not support variadic builtins with return values).- Builtin arguments and return values are JSON-compatible objects. A callback exception becomes an evaluation error; returning is fine.
- An undefined document raises
OpaUndefinedError. - Rego
print(...)output is captured per evaluation: setengine.print_handlerto acallable(message, location)to receive it (default: written to stderr);engine.last_printsholds the(message, location)pairs of the last eval.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opa_golib_python_bindings-0.1.2.tar.gz.
File metadata
- Download URL: opa_golib_python_bindings-0.1.2.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31c049c057bc9b935223ceb7ade8c38fc88235be8429c861a436799ac45d411d
|
|
| MD5 |
29b1742798a21a553860dac40ee805a1
|
|
| BLAKE2b-256 |
2b0f440e074d079ef3dcb3bf28f341a8fada9388f85ba795364cd9d778e8bb47
|
Provenance
The following attestation bundles were made for opa_golib_python_bindings-0.1.2.tar.gz:
Publisher:
publish.yml on phi1010/opa-golib-python-bindings
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opa_golib_python_bindings-0.1.2.tar.gz -
Subject digest:
31c049c057bc9b935223ceb7ade8c38fc88235be8429c861a436799ac45d411d - Sigstore transparency entry: 2587608000
- Sigstore integration time:
-
Permalink:
phi1010/opa-golib-python-bindings@0c0b1d47698f95408cef4e78d21215b8698dd6d6 -
Branch / Tag:
refs/tags/release/v0.1.2-opa1.19.1 - Owner: https://github.com/phi1010
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0c0b1d47698f95408cef4e78d21215b8698dd6d6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file opa_golib_python_bindings-0.1.2-py3-none-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: opa_golib_python_bindings-0.1.2-py3-none-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 14.7 MB
- Tags: Python 3, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e37f627df2d9949dc544a6ddad22c913e00749657c2575024e44f9f74e624cd7
|
|
| MD5 |
caf090ffaf2b5c38235b3c9c9f0e8ffe
|
|
| BLAKE2b-256 |
4b16c06081ce74f8cfafa324d9777475c40f35c639221a5e4843191d138296c5
|
Provenance
The following attestation bundles were made for opa_golib_python_bindings-0.1.2-py3-none-manylinux_2_34_x86_64.whl:
Publisher:
publish.yml on phi1010/opa-golib-python-bindings
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opa_golib_python_bindings-0.1.2-py3-none-manylinux_2_34_x86_64.whl -
Subject digest:
e37f627df2d9949dc544a6ddad22c913e00749657c2575024e44f9f74e624cd7 - Sigstore transparency entry: 2587608208
- Sigstore integration time:
-
Permalink:
phi1010/opa-golib-python-bindings@0c0b1d47698f95408cef4e78d21215b8698dd6d6 -
Branch / Tag:
refs/tags/release/v0.1.2-opa1.19.1 - Owner: https://github.com/phi1010
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0c0b1d47698f95408cef4e78d21215b8698dd6d6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file opa_golib_python_bindings-0.1.2-py3-none-manylinux_2_34_aarch64.whl.
File metadata
- Download URL: opa_golib_python_bindings-0.1.2-py3-none-manylinux_2_34_aarch64.whl
- Upload date:
- Size: 13.3 MB
- Tags: Python 3, manylinux: glibc 2.34+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2c725d8541fefffe3f6cc6044ddc5a0bee4452f7e6ada943bd78d270a753805
|
|
| MD5 |
29bb918c6c369df4759a6f7e3bfc93e3
|
|
| BLAKE2b-256 |
f256347566916cb4f9bbf6fe72dbba774244f0dbe0cb01df6ccda7b21e5f8184
|
Provenance
The following attestation bundles were made for opa_golib_python_bindings-0.1.2-py3-none-manylinux_2_34_aarch64.whl:
Publisher:
publish.yml on phi1010/opa-golib-python-bindings
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opa_golib_python_bindings-0.1.2-py3-none-manylinux_2_34_aarch64.whl -
Subject digest:
f2c725d8541fefffe3f6cc6044ddc5a0bee4452f7e6ada943bd78d270a753805 - Sigstore transparency entry: 2587608678
- Sigstore integration time:
-
Permalink:
phi1010/opa-golib-python-bindings@0c0b1d47698f95408cef4e78d21215b8698dd6d6 -
Branch / Tag:
refs/tags/release/v0.1.2-opa1.19.1 - Owner: https://github.com/phi1010
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0c0b1d47698f95408cef4e78d21215b8698dd6d6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file opa_golib_python_bindings-0.1.2-py3-none-macosx_11_0_x86_64.whl.
File metadata
- Download URL: opa_golib_python_bindings-0.1.2-py3-none-macosx_11_0_x86_64.whl
- Upload date:
- Size: 8.3 MB
- Tags: Python 3, macOS 11.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
987e2838a9231dbf32423ab31613070ebc9970acd3925ae320191539acdb82ce
|
|
| MD5 |
4ddb1f593d1ab559c8ad78c30d5466b2
|
|
| BLAKE2b-256 |
a67e9f99187a5c20492674ae61a174985416123af9aeecc5cc17ffcc56749639
|
Provenance
The following attestation bundles were made for opa_golib_python_bindings-0.1.2-py3-none-macosx_11_0_x86_64.whl:
Publisher:
publish.yml on phi1010/opa-golib-python-bindings
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opa_golib_python_bindings-0.1.2-py3-none-macosx_11_0_x86_64.whl -
Subject digest:
987e2838a9231dbf32423ab31613070ebc9970acd3925ae320191539acdb82ce - Sigstore transparency entry: 2587608880
- Sigstore integration time:
-
Permalink:
phi1010/opa-golib-python-bindings@0c0b1d47698f95408cef4e78d21215b8698dd6d6 -
Branch / Tag:
refs/tags/release/v0.1.2-opa1.19.1 - Owner: https://github.com/phi1010
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0c0b1d47698f95408cef4e78d21215b8698dd6d6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file opa_golib_python_bindings-0.1.2-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: opa_golib_python_bindings-0.1.2-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 7.6 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9034a38bc1dfa8eb9fa07885eb03c4f74e08a7b422dadcea70d038f1baca9eb
|
|
| MD5 |
1d5a884d968a182b3064fb955eba9691
|
|
| BLAKE2b-256 |
cdeb66e6430a663d18049bb3d4a6a8385a965effb488cba8d03701ad8c0b0816
|
Provenance
The following attestation bundles were made for opa_golib_python_bindings-0.1.2-py3-none-macosx_11_0_arm64.whl:
Publisher:
publish.yml on phi1010/opa-golib-python-bindings
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opa_golib_python_bindings-0.1.2-py3-none-macosx_11_0_arm64.whl -
Subject digest:
f9034a38bc1dfa8eb9fa07885eb03c4f74e08a7b422dadcea70d038f1baca9eb - Sigstore transparency entry: 2587608477
- Sigstore integration time:
-
Permalink:
phi1010/opa-golib-python-bindings@0c0b1d47698f95408cef4e78d21215b8698dd6d6 -
Branch / Tag:
refs/tags/release/v0.1.2-opa1.19.1 - Owner: https://github.com/phi1010
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0c0b1d47698f95408cef4e78d21215b8698dd6d6 -
Trigger Event:
release
-
Statement type: