skillfed

regopy

Python interface for the OPA Rego Language and Runtime

regopy v1.5.2 185.4K downloads/30d#10,011 on PyPI47
Permissive license MIT Active released

What it is and what it does

regopy is a Python wrapper around rego-cpp, Microsoft's open-source C++ implementation of the Rego language from the Open Policy Agent project. Rego is a declarative query language designed for policy evaluation and data querying. The package lets you instantiate a Rego interpreter in Python, load policy modules, set input and data contexts, and execute queries that return structured results with variable bindings.

You can use regopy to embed policy-as-code evaluation into Python applications—defining rules in Rego syntax, then querying them from Python with dynamic input and data. The wrapper provides idiomatic Python interfaces: you load modules as strings, set input and data via dictionaries, and receive results as JSON-like objects. It also supports building and executing pre-compiled Rego bundles, useful for performance-sensitive deployments.

Use it for:

  • Embed policy evaluation in Python microservices to enforce authorization rules or compliance checks without external API calls.
  • Build configuration validation tools that use declarative Rego rules to check infrastructure or application settings.
  • Implement access control logic in Python applications by writing Rego policies and querying them with user/resource context.
  • Integrate OPA-compatible policies into Python data pipelines for dynamic filtering or transformation rules.
  • Prototype and test Rego policies in a Python environment before deploying them to a full OPA instance.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

regopy wraps the Open Policy Agent's Rego language compiler and runtime, letting you write and execute Rego policy queries directly from Python code.

Yes, if you need to run Rego policies from Python. The package is actively maintained, has no known vulnerabilities, uses a permissive MIT license, and provides prebuilt wheels for common platforms. Medium install friction is typical for compiled packages and not a barrier. Start with it if you're already using or planning to adopt Rego for policy evaluation.

Install

regopy on PyPI

pip

pip install regopy

uv

uv add regopy

poetry

poetry add regopy

Installing regopy

Before you install

Medium install friction due to compiled wheels; however, prebuilt binaries are available for common platforms (macOS, Linux, Windows) across Python 3.10–3.12, and the package is actively maintained with a recent release.

License in practice

MIT license is permissive; you can use regopy in commercial and proprietary projects with minimal restrictions.

Quickstart

from regopy import Interpreter
rego = Interpreter()
result = rego.query("x=5;y=x + (2 - 4 * 0.25) * -3 + 7.4;2 * 5")
print(result)

Requires Python 3.10 or later; prebuilt wheels are available for macOS (arm64, x86_64), Linux (aarch64, x86_64), and Windows (x86_64).

Verify before relying

  • Whether the C++ runtime dependency (rego-cpp) is bundled in wheels or requires separate installation.
  • Performance characteristics when executing complex policies or large datasets.
  • Exact scope of custom built-in function support beyond the documented standard Rego built-ins.

Package facts

License MIT (permissive)
Python support supports the current Python release (<4,>=3.10)
Install friction medium — platform-specific wheel
Runtime dependencies none
Maintenance actively maintained — 39 days since the last release
Last repo commit
First released
Downloads 185,354/month — #10,011 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: regopy-1.5.2-cp310-cp310-macosx_15_0_arm64.whl; regopy-1.5.2-cp310-cp310-macosx_15_0_x86_64.whl; regopy-1.5.2-cp310-cp310-manylinux_2_34_aarch64.whl; regopy-1.5.2-cp310-cp310-manylinux_2_34_x86_64.whl; regopy-1.5.2-cp310-cp310-musllinux_1_2_aarch64.whl; regopy-1.5.2-cp310-cp310-musllinux_1_2_x86_64.whl; regopy-1.5.2-cp310-cp310-win_amd64.whl; regopy-1.5.2-cp311-cp311-macosx_15_0_arm64.whl; regopy-1.5.2-cp311-cp311-macosx_15_0_x86_64.whl; regopy-1.5.2-cp311-cp311-manylinux_2_34_aarch64.whl; regopy-1.5.2-cp311-cp311-manylinux_2_34_x86_64.whl; regopy-1.5.2-cp311-cp311-musllinux_1_2_aarch64.whl; regopy-1.5.2-cp311-cp311-musllinux_1_2_x86_64.whl; regopy-1.5.2-cp311-cp311-win_amd64.whl; regopy-1.5.2-cp312-cp312-macosx_15_0_arm64.whl; regopy-1.5.2-cp312-cp312-macosx_15_0_x86_64.whl; regopy-1.5.2-cp312-cp312-manylinux_2_34_aarch64.whl; regopy-1.5.2-cp312-cp312-manylinux_2_34_x86_64.whl; regopy-1.5.2-cp312-cp312-musllinux_1_2_aarch64.whl; regopy-1.5.2-cp312-cp312-musllinux_1_2_x86_64.whl

Programming Language :: Python :: 3

Tags

rego policy language pythonopen policy agent wrapperpolicy evaluation enginerego query executiondeclarative policy rulesopa rego python interface
policy-as-codeopadeclarative-rules

More Software Development packages