{"id":13787921,"url":"https://github.com/a2d24/python-opa-wasm","last_synced_at":"2025-09-18T07:07:34.814Z","repository":{"id":44221097,"uuid":"392236303","full_name":"a2d24/python-opa-wasm","owner":"a2d24","description":"Open Policy Agent WebAssembly SDK for Python","archived":false,"fork":false,"pushed_at":"2023-06-25T10:49:47.000Z","size":145,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-22T05:19:09.807Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/a2d24.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-03T07:54:15.000Z","updated_at":"2024-03-30T17:01:28.000Z","dependencies_parsed_at":"2022-09-26T17:30:26.314Z","dependency_job_id":null,"html_url":"https://github.com/a2d24/python-opa-wasm","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a2d24%2Fpython-opa-wasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a2d24%2Fpython-opa-wasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a2d24%2Fpython-opa-wasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a2d24%2Fpython-opa-wasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a2d24","download_url":"https://codeload.github.com/a2d24/python-opa-wasm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253662558,"owners_count":21944095,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T21:00:33.328Z","updated_at":"2025-09-18T07:07:29.708Z","avatar_url":"https://github.com/a2d24.png","language":"Python","funding_links":[],"categories":["WebAssembly (Wasm)"],"sub_categories":["Containers","Typescript"],"readme":"# Open Policy Agent WebAssembly SDK for Python\n\nThis is the source for the\n[opa-wasm](https://pypi.org/project/opa-wasm/)\nPython module which is an SDK for using WebAssembly (wasm) compiled \n[Open Policy Agent](https://www.openpolicyagent.org/) Rego policies using [wasmer-python](https://github.com/wasmerio/wasmer-python).\n\n# Getting Started\n## Install the module\n\nYou may choose to use either the `cranelift` or `llvm` compiler package as follows: \n\n```\npip install opa-wasm[cranelift]\n```\nor\n```\npip install opa-wasm[llvm]\n```\n\nIf you are using zsh, consider adding double-quote around the package name such as `\"opa-wasm[cranelift]\"` or `\"opa-wasm[llvm]\"` .\n\n\nFor builds that target AWS Lambda as an execution environment, it is recommended to use cranelift. This avoids \nthe need to bundle additional binary dependencies as part of the lambda package.\n\nSee the [wasmer-python](https://github.com/wasmerio/wasmer-python) docs for more information\n\n## Usage\n\nThere are only a couple of steps required to start evaluating the policy.\n\n\n```python\n# Import the module\nfrom opa_wasm import OPAPolicy\n\n# Load a policy by specifying its file path\npolicy = OPAPolicy('./policy.wasm')\n\n# Optional: Set policy data\npolicy.set_data({\"company_name\": \"ACME\"})\n\n# Evaluate the policy\ninput = {\"user\": \"alice\"}\nresult = policy.evaluate(input)\n```\n\n## Writing the policy\n\nSee [https://www.openpolicyagent.org/docs/latest/how-do-i-write-policies/](https://www.openpolicyagent.org/docs/latest/how-do-i-write-policies/)\n\n## Compiling the policy\n\nEither use the [Compile REST API](https://www.openpolicyagent.org/docs/latest/rest-api/#compile-api) or `opa build` CLI tool.\n\nFor example, with OPA v0.20.5+:\n\n```bash\nopa build -t wasm -e 'example/allow' example.rego\n```\nWhich compiles the `example.rego` policy file with the result set to\n`data.example.allow`. The result will be an OPA bundle with the `policy.wasm`\nbinary included. \n\nSee `opa build --help` for more details.\n\n## Credits\n\nThis project was inspired by the equivalent NPM Module [@open-policy-agent/opa-wasm](https://github.com/open-policy-agent/npm-opa-wasm)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa2d24%2Fpython-opa-wasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa2d24%2Fpython-opa-wasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa2d24%2Fpython-opa-wasm/lists"}