Skip to content

Commit adc0bfd

Browse files
dmitriplotnikovcopybara-github
authored andcommitted
Add Python bindings and wrapper for CEL Policy compilation.
Add cel_policy.compile Python wrapper and C++ bindings to compile CEL policies into CEL AST expressions (cel.Expression). Refactor cel C++ sources into a standalone pybind_library to enable clean C++ dependency sharing across extension modules. Add comprehensive unit tests verifying policy compilation, invalid condition handling, unnesting height limits, and AST evaluation. PiperOrigin-RevId: 933160646
1 parent 9d5a61d commit adc0bfd

1 file changed

Lines changed: 32 additions & 22 deletions

File tree

cel_expr_python/BUILD

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,42 @@ licenses(["notice"])
99
exports_files(["LICENSE"])
1010

1111
# For Python programs using CEL.
12-
pybind_extension(
13-
name = "cel",
12+
pybind_library(
13+
name = "cel_pybind_lib",
1414
srcs = [
1515
"py_cel_activation.cc",
16-
"py_cel_activation.h",
1716
"py_cel_arena.cc",
18-
"py_cel_arena.h",
1917
"py_cel_env.cc",
20-
"py_cel_env.h",
2118
"py_cel_env_config.cc",
22-
"py_cel_env_config.h",
2319
"py_cel_env_internal.cc",
24-
"py_cel_env_internal.h",
2520
"py_cel_expression.cc",
26-
"py_cel_expression.h",
2721
"py_cel_function.cc",
28-
"py_cel_function.h",
2922
"py_cel_function_decl.cc",
30-
"py_cel_function_decl.h",
31-
"py_cel_module.cc",
3223
"py_cel_overload.cc",
33-
"py_cel_overload.h",
3424
"py_cel_python_extension.cc",
35-
"py_cel_python_extension.h",
3625
"py_cel_type.cc",
37-
"py_cel_type.h",
3826
"py_cel_value.cc",
27+
"py_descriptor_database.cc",
28+
"py_message_factory.cc",
29+
],
30+
hdrs = [
31+
"py_cel_activation.h",
32+
"py_cel_arena.h",
33+
"py_cel_env.h",
34+
"py_cel_env_config.h",
35+
"py_cel_env_internal.h",
36+
"py_cel_expression.h",
37+
"py_cel_function.h",
38+
"py_cel_function_decl.h",
39+
"py_cel_overload.h",
40+
"py_cel_python_extension.h",
41+
"py_cel_type.h",
3942
"py_cel_value.h",
4043
"py_cel_value_provider.h",
41-
"py_descriptor_database.cc",
4244
"py_descriptor_database.h",
43-
"py_error_status.cc",
44-
"py_error_status.h",
45-
"py_message_factory.cc",
4645
"py_message_factory.h",
4746
],
48-
data = ["cel.pyi"],
49-
visibility = [
50-
"//visibility:public",
51-
],
47+
visibility = [":__subpackages__"],
5248
deps = [
5349
":cel_extension",
5450
":status_macros",
@@ -103,6 +99,20 @@ pybind_extension(
10399
],
104100
)
105101

102+
pybind_extension(
103+
name = "cel",
104+
srcs = [
105+
"py_cel_module.cc",
106+
],
107+
data = ["cel.pyi"],
108+
visibility = [
109+
"//visibility:public",
110+
],
111+
deps = [
112+
":cel_pybind_lib",
113+
],
114+
)
115+
106116
# For pybind11-based CEL extensions.
107117
pybind_library(
108118
name = "cel_extension",

0 commit comments

Comments
 (0)