opa-golib-python-bindings 0.1.0__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (18) hide show
  1. opa_golib_python_bindings-0.1.2/PKG-INFO +73 -0
  2. opa_golib_python_bindings-0.1.2/pyproject.toml +55 -0
  3. opa_golib_python_bindings-0.1.0/PKG-INFO +0 -8
  4. opa_golib_python_bindings-0.1.0/pyproject.toml +0 -35
  5. {opa_golib_python_bindings-0.1.0 → opa_golib_python_bindings-0.1.2}/.gitignore +0 -0
  6. {opa_golib_python_bindings-0.1.0 → opa_golib_python_bindings-0.1.2}/LICENSE +0 -0
  7. {opa_golib_python_bindings-0.1.0 → opa_golib_python_bindings-0.1.2}/Makefile +0 -0
  8. {opa_golib_python_bindings-0.1.0 → opa_golib_python_bindings-0.1.2}/README.md +0 -0
  9. {opa_golib_python_bindings-0.1.0 → opa_golib_python_bindings-0.1.2}/go/bridge.go +0 -0
  10. {opa_golib_python_bindings-0.1.0 → opa_golib_python_bindings-0.1.2}/go/bridge_call.c +0 -0
  11. {opa_golib_python_bindings-0.1.0 → opa_golib_python_bindings-0.1.2}/go/builtins.go +0 -0
  12. {opa_golib_python_bindings-0.1.0 → opa_golib_python_bindings-0.1.2}/go/go.mod +0 -0
  13. {opa_golib_python_bindings-0.1.0 → opa_golib_python_bindings-0.1.2}/go/go.sum +0 -0
  14. {opa_golib_python_bindings-0.1.0 → opa_golib_python_bindings-0.1.2}/go/merge.go +0 -0
  15. {opa_golib_python_bindings-0.1.0 → opa_golib_python_bindings-0.1.2}/hatch_build.py +0 -0
  16. {opa_golib_python_bindings-0.1.0 → opa_golib_python_bindings-0.1.2}/src/opa_bindings/__init__.py +0 -0
  17. {opa_golib_python_bindings-0.1.0 → opa_golib_python_bindings-0.1.2}/src/opa_bindings/_native.py +0 -0
  18. {opa_golib_python_bindings-0.1.0 → opa_golib_python_bindings-0.1.2}/src/opa_bindings/engine.py +0 -0
@@ -0,0 +1,73 @@
1
+ Metadata-Version: 2.5
2
+ Name: opa-golib-python-bindings
3
+ Version: 0.1.2
4
+ Summary: Python bindings for the OPA (Open Policy Agent) Rego engine via a Go c-shared library
5
+ Project-URL: Homepage, https://github.com/phi1010/opa-golib-python-bindings
6
+ Project-URL: Repository, https://github.com/phi1010/opa-golib-python-bindings
7
+ Project-URL: Issues, https://github.com/phi1010/opa-golib-python-bindings/issues
8
+ Author: Phillip Kuhrt
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: authorization,opa,open-policy-agent,policy,rego
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: MacOS
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Programming Language :: Go
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Security
20
+ Classifier: Topic :: Software Development :: Libraries
21
+ Requires-Python: >=3.14
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest; extra == 'dev'
24
+ Description-Content-Type: text/markdown
25
+
26
+ # opa-golib-python-bindings
27
+
28
+ Python bindings for the [OPA](https://www.openpolicyagent.org/) Rego engine, embedding
29
+ `github.com/open-policy-agent/opa/v1/rego` via a Go c-shared library and a stdlib-only
30
+ ctypes wrapper.
31
+
32
+ ## Build
33
+
34
+ Requires Go >= 1.26 and Python >= 3.14.
35
+
36
+ ```sh
37
+ make build # builds src/opa_bindings/libopabridge.so
38
+ make test # builds + runs pytest
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ ```python
44
+ from opa_bindings import OpaEngine
45
+
46
+ users = {"alice": {"role": "admin"}}
47
+
48
+ with OpaEngine() as engine:
49
+ engine.add_policy("authz.rego", """
50
+ package authz
51
+
52
+ allow if lookup_user(input.user).role == "admin"
53
+ """)
54
+ engine.add_data({"admin": ["alice"]}, path="roles") # deep-merged; conflicts raise
55
+ engine.register_function("lookup_user", lambda name: users.get(name))
56
+
57
+ engine.eval_document("authz.allow", {"user": "alice"}) # -> True
58
+ engine.eval_query("x = data.roles.admin[_]") # -> [{"x": "alice"}]
59
+ ```
60
+
61
+ Notes:
62
+
63
+ - `add_data` deep-merges objects; identical values coexist, conflicting values raise
64
+ `OpaError(code="merge_conflict")` naming the conflicting path.
65
+ - `register_function` infers arity from the callable's signature. A `*args` function is
66
+ variadic and is called from Rego with a single array argument: `many(["a", "b"])`
67
+ (OPA does not support variadic builtins with return values).
68
+ - Builtin arguments and return values are JSON-compatible objects. A callback exception
69
+ becomes an evaluation error; returning is fine.
70
+ - An undefined document raises `OpaUndefinedError`.
71
+ - Rego `print(...)` output is captured per evaluation: set `engine.print_handler`
72
+ to a `callable(message, location)` to receive it (default: written to stderr);
73
+ `engine.last_prints` holds the `(message, location)` pairs of the last eval.
@@ -0,0 +1,55 @@
1
+ [project]
2
+ name = "opa-golib-python-bindings"
3
+ version = "0.1.2"
4
+ description = "Python bindings for the OPA (Open Policy Agent) Rego engine via a Go c-shared library"
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ authors = [{ name = "Phillip Kuhrt" }]
8
+ keywords = ["opa", "open-policy-agent", "rego", "policy", "authorization"]
9
+ classifiers = [
10
+ "Development Status :: 3 - Alpha",
11
+ "Intended Audience :: Developers",
12
+ "Operating System :: POSIX :: Linux",
13
+ "Operating System :: MacOS",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.14",
16
+ "Programming Language :: Go",
17
+ "Topic :: Security",
18
+ "Topic :: Software Development :: Libraries",
19
+ ]
20
+ requires-python = ">=3.14"
21
+ dependencies = []
22
+
23
+ [project.urls]
24
+ Homepage = "https://github.com/phi1010/opa-golib-python-bindings"
25
+ Repository = "https://github.com/phi1010/opa-golib-python-bindings"
26
+ Issues = "https://github.com/phi1010/opa-golib-python-bindings/issues"
27
+
28
+ [project.optional-dependencies]
29
+ dev = ["pytest"]
30
+
31
+ [build-system]
32
+ requires = ["hatchling"]
33
+ build-backend = "hatchling.build"
34
+
35
+ [tool.hatch.build.targets.wheel]
36
+ packages = ["src/opa_bindings"]
37
+ artifacts = ["src/opa_bindings/libopabridge.so"]
38
+
39
+ [tool.hatch.build.targets.wheel.hooks.custom]
40
+ path = "hatch_build.py"
41
+
42
+ [tool.hatch.build.targets.sdist]
43
+ include = [
44
+ "src/opa_bindings",
45
+ "go/*.go",
46
+ "go/*.c",
47
+ "go/go.mod",
48
+ "go/go.sum",
49
+ "Makefile",
50
+ "hatch_build.py",
51
+ "README.md",
52
+ ]
53
+
54
+ [tool.pytest.ini_options]
55
+ pythonpath = ["src"]
@@ -1,8 +0,0 @@
1
- Metadata-Version: 2.5
2
- Name: opa-golib-python-bindings
3
- Version: 0.1.0
4
- Summary: Python bindings for the OPA (Open Policy Agent) Rego engine via a Go c-shared library
5
- License-File: LICENSE
6
- Requires-Python: >=3.14
7
- Provides-Extra: dev
8
- Requires-Dist: pytest; extra == 'dev'
@@ -1,35 +0,0 @@
1
- [project]
2
- name = "opa-golib-python-bindings"
3
- version = "0.1.0"
4
- description = "Python bindings for the OPA (Open Policy Agent) Rego engine via a Go c-shared library"
5
- requires-python = ">=3.14"
6
- dependencies = []
7
-
8
- [project.optional-dependencies]
9
- dev = ["pytest"]
10
-
11
- [build-system]
12
- requires = ["hatchling"]
13
- build-backend = "hatchling.build"
14
-
15
- [tool.hatch.build.targets.wheel]
16
- packages = ["src/opa_bindings"]
17
- artifacts = ["src/opa_bindings/libopabridge.so"]
18
-
19
- [tool.hatch.build.targets.wheel.hooks.custom]
20
- path = "hatch_build.py"
21
-
22
- [tool.hatch.build.targets.sdist]
23
- include = [
24
- "src/opa_bindings",
25
- "go/*.go",
26
- "go/*.c",
27
- "go/go.mod",
28
- "go/go.sum",
29
- "Makefile",
30
- "hatch_build.py",
31
- "README.md",
32
- ]
33
-
34
- [tool.pytest.ini_options]
35
- pythonpath = ["src"]