From c92f070f9e892657690ab22a787647f57cbde954 Mon Sep 17 00:00:00 2001 From: Kuzu CI Date: Wed, 9 Oct 2024 11:27:27 -0400 Subject: [PATCH] Backport extension collect script --- collect-extensions.py | 58 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 collect-extensions.py diff --git a/collect-extensions.py b/collect-extensions.py new file mode 100644 index 00000000000..de7b496e4dd --- /dev/null +++ b/collect-extensions.py @@ -0,0 +1,58 @@ +import os +import shutil +import platform + +FILE_DIR = os.path.dirname(os.path.abspath(__file__)) +DST_DIR = os.path.abspath(os.path.join(FILE_DIR, "..", "extension-artifacts")) +SRC_DIR = os.path.abspath(os.path.join(FILE_DIR, "..", "extension")) + + +def collect_exts(): + for ext in os.listdir(SRC_DIR): + ext_build_path = os.path.abspath(os.path.join(SRC_DIR, ext, "build")) + if not os.path.exists(ext_build_path): + continue + print("Found extension: " + ext) + ext_dst_path = os.path.abspath(os.path.join(DST_DIR, ext)) + os.makedirs(ext_dst_path, exist_ok=True) + for f in os.listdir(ext_build_path): + if not f.endswith(".kuzu_extension"): + continue + ext_file_path = os.path.abspath(os.path.join(ext_build_path, f)) + shutil.copy(ext_file_path, ext_dst_path) + print(" \tCopied: " + f, "=>", ext_dst_path) + + +def find_duckdb(): + if platform.system() == 'Darwin': + candidates = ["/usr/local/lib/libduckdb.dylib", "/opt/homebrew/lib/libduckdb.dylib"] + elif platform.system() == 'Linux': + candidates = ["/usr/local/lib/libduckdb.so", "/usr/lib/libduckdb.so", "/usr/lib64/libduckdb.so"] + elif platform.system() == 'Windows': + candidates = ["C:\\Program Files\\duckdb\\build\\release\\src\\Release\\duckdb.lib"] + for candidate in candidates: + if os.path.exists(candidate): + return os.path.abspath(candidate) + return None + + +def copy_duckdb(): + duckdb_dst_path = os.path.abspath(os.path.join(DST_DIR, "common")) + os.makedirs(duckdb_dst_path, exist_ok=True) + duckdb_path = find_duckdb() + if duckdb_path is None: + print("DuckDB not found, copying is skipped") + return + shutil.copy(duckdb_path, duckdb_dst_path) + print("Copied DuckDB: " + duckdb_path, "=>", duckdb_dst_path) + + +def main(): + shutil.rmtree(DST_DIR, ignore_errors=True) + os.makedirs(DST_DIR, exist_ok=True) + collect_exts() + copy_duckdb() + + +if __name__ == "__main__": + main()