aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/tar_sources.py
diff options
context:
space:
mode:
authoralexv-smirnov <alex@ydb.tech>2023-03-15 19:59:12 +0300
committeralexv-smirnov <alex@ydb.tech>2023-03-15 19:59:12 +0300
commit056bb284ccf8dd6793ec3a54ffa36c4fb2b9ad11 (patch)
tree4740980126f32e3af7937ba0ca5f83e59baa4ab0 /build/scripts/tar_sources.py
parent269126dcced1cc8b53eb4398b4a33e5142f10290 (diff)
downloadydb-056bb284ccf8dd6793ec3a54ffa36c4fb2b9ad11.tar.gz
add library/cpp/actors, ymake build to ydb oss export
Diffstat (limited to 'build/scripts/tar_sources.py')
-rw-r--r--build/scripts/tar_sources.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/build/scripts/tar_sources.py b/build/scripts/tar_sources.py
new file mode 100644
index 0000000000..54e2839a69
--- /dev/null
+++ b/build/scripts/tar_sources.py
@@ -0,0 +1,41 @@
+import argparse
+import os
+import tarfile
+
+
+def parse_args():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--exts', nargs='*', default=None)
+ parser.add_argument('--flat', action='store_true')
+ parser.add_argument('--input', required=True)
+ parser.add_argument('--output', required=True)
+ parser.add_argument('--prefix', default=None)
+
+ return parser.parse_args()
+
+
+def main():
+ args = parse_args()
+
+ py_srcs = []
+ for root, _, files in os.walk(args.input):
+ for f in files:
+ if not args.exts or f.endswith(tuple(args.exts)):
+ py_srcs.append(os.path.join(root, f))
+
+ compression_mode = ''
+ if args.output.endswith(('.tar.gz', '.tgz')):
+ compression_mode = 'gz'
+ elif args.output.endswith('.bzip2'):
+ compression_mode = 'bz2'
+
+ with tarfile.open(args.output, 'w:{}'.format(compression_mode)) as out:
+ for f in py_srcs:
+ arcname = os.path.basename(f) if args.flat else os.path.relpath(f, args.input)
+ if args.prefix:
+ arcname = os.path.join(args.prefix, arcname)
+ out.add(f, arcname=arcname)
+
+
+if __name__ == '__main__':
+ main()