--- id: regopy version: "1.5.2" license: MIT license_treatment: permissive maintenance: active --- # regopy — Python interface for the OPA Rego Language and Runtime License: permissive · Maintenance: active · Downloads: 185.4K/mo ## 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 above — 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 pip install regopy uv add regopy 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_current - Install friction: medium - Maintenance: active - Downloads: 185.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags rego policy language python, open policy agent wrapper, policy evaluation engine, rego query execution, declarative policy rules, opa rego python interface, policy-as-code, opa, declarative-rules [View on SkillFed](https://skillfed.io/packages/regopy) · [View on PyPI](https://pypi.org/project/regopy/)