Skip to content

Commit

Permalink
separate py script for win
Browse files Browse the repository at this point in the history
  • Loading branch information
jraymakers committed Jun 30, 2024
1 parent 868a578 commit 1cd098b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 31 deletions.
20 changes: 16 additions & 4 deletions alt/bindings/binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
},
}],
],
Expand All @@ -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'],
},
],
Expand Down
33 changes: 6 additions & 27 deletions alt/bindings/scripts/fetch_libduckdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
18 changes: 18 additions & 0 deletions alt/bindings/scripts/fetch_libduckdb_win.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 1cd098b

Please sign in to comment.