aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/gen_yql_python_udf.py
diff options
context:
space:
mode:
authoralexv-smirnov <alex@ydb.tech>2023-06-13 11:05:01 +0300
committeralexv-smirnov <alex@ydb.tech>2023-06-13 11:05:01 +0300
commitbf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0 (patch)
tree1d1df72c0541a59a81439842f46d95396d3e7189 /build/scripts/gen_yql_python_udf.py
parent8bfdfa9a9bd19bddbc58d888e180fbd1218681be (diff)
downloadydb-bf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0.tar.gz
add ymake export to ydb
Diffstat (limited to 'build/scripts/gen_yql_python_udf.py')
-rw-r--r--build/scripts/gen_yql_python_udf.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/build/scripts/gen_yql_python_udf.py b/build/scripts/gen_yql_python_udf.py
new file mode 100644
index 0000000000..13b5898117
--- /dev/null
+++ b/build/scripts/gen_yql_python_udf.py
@@ -0,0 +1,55 @@
+import sys
+
+TEMPLATE="""
+#include <yql/udfs/common/python/python_udf/python_udf.h>
+
+#include <ydb/library/yql/public/udf/udf_registrator.h>
+
+#if @WITH_LIBRA@
+#include <yql/udfs/quality/libra/module/module.h>
+#endif
+
+using namespace NKikimr::NUdf;
+
+#ifdef BUILD_UDF
+
+#if @WITH_LIBRA@
+LIBRA_MODULE(TLibraModule, "Libra@MODULE_NAME@");
+#endif
+
+extern "C" UDF_API void Register(IRegistrator& registrator, ui32 flags) {
+ RegisterYqlPythonUdf(registrator, flags, TStringBuf("@MODULE_NAME@"), TStringBuf("@PACKAGE_NAME@"), EPythonFlavor::@FLAVOR@);
+#if @WITH_LIBRA@
+ RegisterHelper<TLibraModule>(registrator);
+#endif
+}
+
+extern "C" UDF_API ui32 AbiVersion() {
+ return CurrentAbiVersion();
+}
+
+extern "C" UDF_API void SetBackTraceCallback(TBackTraceCallback callback) {
+ SetBackTraceCallbackImpl(callback);
+}
+
+#endif
+"""
+
+
+def main():
+ assert len(sys.argv) == 6
+ flavor, module_name, package_name, path, libra_flag = sys.argv[1:]
+ with open(path, 'w') as f:
+ f.write(
+ TEMPLATE
+ .strip()
+ .replace('@MODULE_NAME@', module_name)
+ .replace('@PACKAGE_NAME@', package_name)
+ .replace('@FLAVOR@', flavor)
+ .replace('@WITH_LIBRA@', libra_flag)
+ )
+ f.write('\n')
+
+
+if __name__ == "__main__":
+ main()