aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/gen_py3_reg.py
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.com>2022-08-19 15:00:44 +0300
committerthegeorg <thegeorg@yandex-team.com>2022-08-19 15:00:44 +0300
commitad2a1b622d2bf6cf025982846153d9c4c791af2c (patch)
tree8906addc18a494ece9dff28b2701a37ef4b52bf8 /build/scripts/gen_py3_reg.py
parent7b61b052f3baa7e43edca48c373f95b5e5f1c845 (diff)
downloadydb-ad2a1b622d2bf6cf025982846153d9c4c791af2c.tar.gz
Let cmake export determine which build/scripts are mandatory
Diffstat (limited to 'build/scripts/gen_py3_reg.py')
-rw-r--r--build/scripts/gen_py3_reg.py34
1 files changed, 0 insertions, 34 deletions
diff --git a/build/scripts/gen_py3_reg.py b/build/scripts/gen_py3_reg.py
deleted file mode 100644
index 149c094898..0000000000
--- a/build/scripts/gen_py3_reg.py
+++ /dev/null
@@ -1,34 +0,0 @@
-import sys
-
-template = '''
-struct PyObject;
-extern "C" int PyImport_AppendInittab(const char* name, PyObject* (*initfunc)());
-extern "C" PyObject* {1}();
-
-namespace {
- struct TRegistrar {
- inline TRegistrar() {
- // TODO Collect all modules and call PyImport_ExtendInittab once
- PyImport_AppendInittab("{0}", {1});
- }
- } REG;
-}
-'''
-
-
-def mangle(name):
- if '.' not in name:
- return name
- return ''.join('{}{}'.format(len(s), s) for s in name.split('.'))
-
-if __name__ == '__main__':
- if len(sys.argv) != 3:
- print >>sys.stderr, 'Usage: <path/to/gen_py_reg.py> <python_module_name> <output_file>'
- print >>sys.stderr, 'Passed: ' + ' '.join(sys.argv)
- sys.exit(1)
-
- with open(sys.argv[2], 'w') as f:
- modname = sys.argv[1]
- initname = 'PyInit_' + mangle(modname)
- code = template.replace('{0}', modname).replace('{1}', initname)
- f.write(code)