Skip to content

Commit

Permalink
separate py scripts for each os
Browse files Browse the repository at this point in the history
  • Loading branch information
jraymakers committed Jun 30, 2024
1 parent 1cd098b commit 8c5e6ac
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 49 deletions.
3 changes: 2 additions & 1 deletion alt/bindings/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
libduckdb
package/lib/*
package/lib/*
__pycache__
22 changes: 5 additions & 17 deletions alt/bindings/binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,27 @@
'conditions': [
['OS=="linux"', {
'variables': {
'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',
],
'script_path': '<(module_root_dir)/scripts/fetch_libduckdb_linux.py',
},
}],
['OS=="mac"', {
'variables': {
'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',
],
'script_path': '<(module_root_dir)/scripts/fetch_libduckdb_mac.py',
},
}],
['OS=="win"', {
'variables': {
'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
],
},
}],
],
'actions': [
{
'action_name': 'run_fetch_libduckdb_script',
'message': 'Running fetch libduckdb script',
'message': 'Fetching and extracting libduckdb',
'inputs': [],
'action': ['python3', '<(script_path)', '<@(script_args)'],
'outputs': ['<(module_root_dir)/libduckdb/libduckdb.zip'],
'action': ['python3', '<(script_path)'],
'outputs': ['<(module_root_dir)/libduckdb'],
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions alt/bindings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"scripts": {
"configure": "node-gyp configure",
"build": "node-gyp build",
"clean": "npm run clean:downloads && npm run clean:gyp && npm run clean:package",
"clean:downloads": "rimraf downloads",
"clean": "npm run clean:gyp && npm run clean:libduckdb && npm run clean:package",
"clean:gyp": "node-gyp clean",
"clean:libduckdb": "rimraf libduckdb",
"clean:package": "rimraf package/lib"
},
"dependencies": {
Expand Down
24 changes: 11 additions & 13 deletions alt/bindings/scripts/fetch_libduckdb.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import os
import sys
import urllib.request
import zipfile

output_dir = sys.argv[1]
zip_url = sys.argv[2]
def fetch_libduckdb(zip_url, output_dir, files):
if not os.path.exists(output_dir):
os.makedirs(output_dir)

local_zip_path = os.path.join(output_dir, "libduckdb.zip")
print("fetching: " + zip_url)
urllib.request.urlretrieve(zip_url, local_zip_path)

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)
zip = zipfile.ZipFile(local_zip_path)
for file in files:
print("extracting: " + file)
zip.extract(file, output_dir)
10 changes: 10 additions & 0 deletions alt/bindings/scripts/fetch_libduckdb_linux.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from fetch_libduckdb import fetch_libduckdb

zip_url = "https://github.com/duckdb/duckdb/releases/download/v1.0.0/libduckdb-linux-amd64.zip"
output_dir = "libduckdb"
files = [
"duckdb.h",
"libduckdb.so",
]

fetch_libduckdb(zip_url, output_dir, files)
10 changes: 10 additions & 0 deletions alt/bindings/scripts/fetch_libduckdb_mac.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from fetch_libduckdb import fetch_libduckdb

zip_url = "https://github.com/duckdb/duckdb/releases/download/v1.0.0/libduckdb-osx-universal.zip"
output_dir = "libduckdb"
files = [
"duckdb.h",
"libduckdb.dylib",
]

fetch_libduckdb(zip_url, output_dir, files)
25 changes: 9 additions & 16 deletions alt/bindings/scripts/fetch_libduckdb_win.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import os
import sys
import urllib.request
import zipfile
from fetch_libduckdb import fetch_libduckdb

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)
output_dir = "libduckdb"
files = [
"duckdb.h",
"duckdb.lib",
"duckdb.dll",
]

fetch_libduckdb(zip_url, output_dir, files)

0 comments on commit 8c5e6ac

Please sign in to comment.