aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/cffi/py2/gen
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2023-10-17 14:59:20 +0300
committershadchin <shadchin@yandex-team.com>2023-10-17 16:11:54 +0300
commitf5137907c9d082d5651b490d9d76e93cefca9c73 (patch)
treee3a7d50e77ec6ba83e833462d123fc85c47143cc /contrib/python/cffi/py2/gen
parent674acb9e3f858c628f128c2e7796a4bca668b7c4 (diff)
downloadydb-f5137907c9d082d5651b490d9d76e93cefca9c73.tar.gz
Split cffi on py2/py3
Diffstat (limited to 'contrib/python/cffi/py2/gen')
-rw-r--r--contrib/python/cffi/py2/gen/lib/ya.make19
-rw-r--r--contrib/python/cffi/py2/gen/main.py37
-rw-r--r--contrib/python/cffi/py2/gen/ya.make17
3 files changed, 73 insertions, 0 deletions
diff --git a/contrib/python/cffi/py2/gen/lib/ya.make b/contrib/python/cffi/py2/gen/lib/ya.make
new file mode 100644
index 0000000000..64e54a67c3
--- /dev/null
+++ b/contrib/python/cffi/py2/gen/lib/ya.make
@@ -0,0 +1,19 @@
+PY2_LIBRARY()
+
+LICENSE(MIT)
+
+PEERDIR(
+ contrib/python/cffi
+)
+
+SRCDIR(
+ contrib/python/cffi/py2/gen
+)
+
+PY_SRCS(
+ MAIN main.py
+)
+
+NO_LINT()
+
+END()
diff --git a/contrib/python/cffi/py2/gen/main.py b/contrib/python/cffi/py2/gen/main.py
new file mode 100644
index 0000000000..106293d3c5
--- /dev/null
+++ b/contrib/python/cffi/py2/gen/main.py
@@ -0,0 +1,37 @@
+import os.path
+import sys
+
+from cffi.setuptools_ext import execfile
+
+usage = '''Usage: {} INPUT:VAR OUTPUT
+Generate CFFI C module source code.
+
+INPUT is a source .py file.
+VAR is a cffi.FFI() object defined in the source file.
+OUTPUT is a .c or .cpp output file.
+'''
+
+
+def main():
+ if len(sys.argv) != 3 or ':' not in sys.argv[1]:
+ sys.stdout.write(usage.format(sys.argv[0]))
+ sys.exit(1)
+
+ mod_spec, c_file = sys.argv[1:3]
+ build_file_name, ffi_var_name = mod_spec.rsplit(':', 1)
+
+ source_dir = os.path.dirname(os.path.abspath(build_file_name))
+ sys._MEIPASS = source_dir # For pygit2.
+ sys.dont_write_bytecode = True
+ sys.path = [source_dir]
+ mod_vars = {'__name__': '__cffi__', '__file__': build_file_name}
+ execfile(build_file_name, mod_vars)
+
+ ffi = mod_vars[ffi_var_name]
+ if callable(ffi):
+ ffi = ffi()
+ ffi.emit_c_code(c_file)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/contrib/python/cffi/py2/gen/ya.make b/contrib/python/cffi/py2/gen/ya.make
new file mode 100644
index 0000000000..3a78fd7359
--- /dev/null
+++ b/contrib/python/cffi/py2/gen/ya.make
@@ -0,0 +1,17 @@
+PY2_PROGRAM(cffigen)
+
+DISABLE(PYTHON_SQLITE3)
+
+LICENSE(MIT)
+
+PEERDIR(
+ contrib/python/cffi/py2/gen/lib
+)
+
+INDUCED_DEPS(cpp ${ARCADIA_ROOT}/contrib/python/cffi/py2/cffi/_cffi_include.h)
+
+END()
+
+RECURSE(
+ lib
+)