diff --git a/alt/bindings/binding.gyp b/alt/bindings/binding.gyp index a65d75a5..eb2393c3 100644 --- a/alt/bindings/binding.gyp +++ b/alt/bindings/binding.gyp @@ -6,17 +6,29 @@ 'conditions': [ ['OS=="linux"', { 'variables': { - 'zip_url': '"https://github.com/duckdb/duckdb/releases/download/v1.0.0/libduckdb-linux-amd64.zip"', + 'script_path': '<(module_root_dir)/scripts/fetch_libduckdb.py', + 'script_args': [ + '<(module_root_dir)/libduckdb', + 'https://github.com/duckdb/duckdb/releases/download/v1.0.0/libduckdb-linux-amd64.zip', + ], }, }], ['OS=="mac"', { 'variables': { - 'zip_url': '"https://github.com/duckdb/duckdb/releases/download/v1.0.0/libduckdb-osx-universal.zip"', + 'script_path': '<(module_root_dir)/scripts/fetch_libduckdb.py', + 'script_args': [ + '<(module_root_dir)/libduckdb', + 'https://github.com/duckdb/duckdb/releases/download/v1.0.0/libduckdb-osx-universal.zip', + ], }, }], ['OS=="win"', { 'variables': { - 'zip_url': '"https://github.com/duckdb/duckdb/releases/download/v1.0.0/libduckdb-windows-amd64.zip"', + 'script_path': '<(module_root_dir)/scripts/fetch_libduckdb_win.py', + 'script_args': [ + '<(module_root_dir)/libduckdb', + # zip url is hard-coded into fetch_libduckdb_win.py to work around file path issues on Windows + ], }, }], ], @@ -25,7 +37,7 @@ 'action_name': 'run_fetch_libduckdb_script', 'message': 'Running fetch libduckdb script', 'inputs': [], - 'action': ['python3', '<(module_root_dir)/scripts/fetch_libduckdb.py', '<(OS)', '<(module_root_dir)/libduckdb', '<(zip_url)'], + 'action': ['python3', '<(script_path)', '<@(script_args)'], 'outputs': ['<(module_root_dir)/libduckdb/libduckdb.zip'], }, ], diff --git a/alt/bindings/scripts/fetch_libduckdb.py b/alt/bindings/scripts/fetch_libduckdb.py index 2106abd0..5f56b933 100644 --- a/alt/bindings/scripts/fetch_libduckdb.py +++ b/alt/bindings/scripts/fetch_libduckdb.py @@ -3,37 +3,16 @@ import urllib.request import zipfile -libduckdb_zip_url_for_os = { - "linux": "https://github.com/duckdb/duckdb/releases/download/v1.0.0/libduckdb-linux-amd64.zip", # TODO: handle linux-aarch64 - "mac": "https://github.com/duckdb/duckdb/releases/download/v1.0.0/libduckdb-osx-universal.zip", - "win": "https://github.com/duckdb/duckdb/releases/download/v1.0.0/libduckdb-windows-amd64.zip", -} +output_dir = sys.argv[1] +zip_url = sys.argv[2] -# libduckdb_file_names_for_os = { -# "linux": ["duckdb.h", "libduckdb.so"], -# "mac": ["duckdb.h", "libduckdb.dylib"], -# "win": ["duckdb.h", "libduckdb.lib", "libduckdb.dll"], -# } - -os_name = sys.argv[1] -output_dir = sys.argv[2] -zip_url = sys.argv[3] - -print("os_name: " + os_name) print("output_dir: " + output_dir) print("zip_url: " + zip_url) -libduckdb_zip_url = libduckdb_zip_url_for_os[os_name] -# libduckdb_file_names = libduckdb_file_names_for_os[os_name] +local_zip_path = os.path.join(output_dir, "libduckdb.zip") +print("fetching: " + zip_url) +urllib.request.urlretrieve(zip_url, local_zip_path) -libduckdb_zip_path = os.path.join(output_dir, "libduckdb.zip") -print("fetching: " + libduckdb_zip_url) -urllib.request.urlretrieve(libduckdb_zip_url, libduckdb_zip_path) - -zip = zipfile.ZipFile(libduckdb_zip_path) +zip = zipfile.ZipFile(local_zip_path) print("extracting: " + ", ".join(zip.namelist())) zip.extractall(output_dir) - -# for file_name in libduckdb_file_names: -# print("extracting: " + file_name) -# zip.extract(file_name, output_dir) diff --git a/alt/bindings/scripts/fetch_libduckdb_win.py b/alt/bindings/scripts/fetch_libduckdb_win.py new file mode 100644 index 00000000..a4d98914 --- /dev/null +++ b/alt/bindings/scripts/fetch_libduckdb_win.py @@ -0,0 +1,18 @@ +import os +import sys +import urllib.request +import zipfile + +output_dir = sys.argv[1] +zip_url = "https://github.com/duckdb/duckdb/releases/download/v1.0.0/libduckdb-windows-amd64.zip" + +print("output_dir: " + output_dir) +print("zip_url: " + zip_url) + +local_zip_path = os.path.join(output_dir, "libduckdb.zip") +print("fetching: " + zip_url) +urllib.request.urlretrieve(zip_url, local_zip_path) + +zip = zipfile.ZipFile(local_zip_path) +print("extracting: " + ", ".join(zip.namelist())) +zip.extractall(output_dir)