cel-python
Pure Python implementation of Google Common Expression Language
What it is and what it does
cel-python is a pure Python runtime for Google's Common Expression Language, a domain-specific language designed for secure, portable expression evaluation across systems without exposing the full power of Python. It compiles CEL source code into an abstract syntax tree, then into an executable program that can be evaluated against provided context data. The package is intended for use cases where you need to safely evaluate user-supplied or policy-defined expressions—such as security filters, access control rules, or data validation—without the risks of arbitrary code execution.
The implementation follows the Go CEL reference closely, with six core dependencies (google-re2, jmespath, lark, pendulum, pyyaml, tomli) that handle regex matching, JSON path queries, parsing, date/time operations, and configuration. It can be used as a library within Python applications or invoked from the command line as a calculator-like tool or JSON filter. Type semantics differ from Python's native types; division truncates toward zero rather than toward negative infinity, and type coercion is minimal.
Use it for:
- Embed security policy filters in infrastructure-as-code systems to evaluate compliance rules without executing arbitrary Python code.
- Evaluate access control expressions in API gateways or authorization systems where policies must be portable across languages.
- Validate or transform JSON data from stdin using CEL expressions, similar to jq but with CEL's type system and semantics.
- Define and check complex business rules (e.g., account overdraft protection logic) in a sandboxed, language-neutral format.
- Build policy-as-code systems where non-developers can write safe, auditable expressions for infrastructure or application decisions.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses and evaluates Google Common Expression Language (CEL) expressions in Python, enabling secure policy evaluation and cross-platform expression interoperability without requiring full Python execution.
Yes, if you need to evaluate untrusted or policy-defined expressions safely without exposing Python's full execution model. The low install friction and lack of known vulnerabilities are positives. However, the aging maintenance status (195 days since last release) and unclear license require verification before production use. Suitable for embedded policy evaluation; less suitable if you need active upstream support.
Install
cel-python on PyPI
pip
pip install cel-pythonuv
uv add cel-pythonpoetry
poetry add cel-pythonInstalling cel-python
Before you install
Low install friction with six runtime dependencies bundled as a wheel. Maintenance status is aging—last release was 195 days ago—but the package remains in Beta and supports current Python versions (requires Python 3.10+).
License in practice
License treatment is unclear; no SPDX identifier or raw license text is available in the package metadata. Verify the actual license terms before use in proprietary or copyleft-sensitive projects.
Quickstart
import cel-python
env = Environment()
ast = env.compile('account.balance >= 500')
prgm = env.program(ast)
result = prgm.evaluate({'account': json_to_cel({'balance': 600})})
Requires Python 3.10 or later.
Verify before relying
- Whether the package is actively maintained or in maintenance-only mode given the 195-day gap since last release.
- The actual license under which cel-python is distributed, since metadata shows no SPDX or raw license text.
- Performance characteristics and scalability limits for large or complex CEL expressions in production use.
- How type coercion and division semantics (truncating toward zero) affect real-world policy evaluation workflows.
Package facts
| License | not declared (unclear) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 6 — google-re2, jmespath, lark, pendulum, pyyaml, tomli |
| Maintenance | aging — 195 days since the last release |
| First released | |
| Downloads | 6,706,378/month — #1,867 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cel_python-0.5.0-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
cel-expr-pythonA Python wrapper for the CEL C++ implementation…
permissive · top 15,000 on PyPI
common-expression-languageEvaluates Google's Common Expression Language…
permissive · top 15,000 on PyPI
levalLeval evaluates limited expressions safely by…
permissive · top 15,000 on PyPI
astevalAsteval is a safe Python expression and…
permissive · top 5,000 on PyPI
simpleevalEvaluates mathematical and logical expressions…
permissive · top 5,000 on PyPI
jsonata-pythonEvaluates JSONata expressions against JSON…
permissive · top 5,000 on PyPI
pure-evalSafely evaluate Python AST nodes without…
permissive · top 1,000 on PyPI
promql-parserParses Prometheus query language (PromQL)…
unclear · top 15,000 on PyPI
protovalidateValidates Protocol Buffer messages against…
permissive · top 5,000 on PyPI
google-re2A drop-in replacement for Python's re module…
permissive · top 5,000 on PyPI