Skip to content

Commit

Permalink
try fix win
Browse files Browse the repository at this point in the history
  • Loading branch information
jraymakers committed Jun 23, 2024
1 parent bbe4079 commit 4842acc
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions generate-wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,24 +238,35 @@ def get_lib_file_name():
raise Exception("Unsupported system: " + system)

if __name__ == "__main__":
dir_path = os.path.dirname(os.path.realpath(__file__))
# dir_path = os.path.dirname(os.path.realpath(__file__))

with tempfile.TemporaryDirectory() as zip_tmp:
zip_path = os.path.join(zip_tmp, "libduckdb.zip")

release_zip_url = get_release_zip_url()
print("Downloading " + release_zip_url)
urllib.request.urlretrieve(release_zip_url, zip_path)
print("Downloaded " + zip_path)

print("Extracting zip")
print("Opening zip")
zip = zipfile.ZipFile(zip_path)

with tempfile.TemporaryDirectory() as ext_tmp:
lib_file_name = get_lib_file_name()
print("Lib file name is " + lib_file_name)

print("Extracting lib file to temp dir: " + ext_tmp)
zip.extract(lib_file_name, ext_tmp)
shutil.copy(os.path.join(ext_tmp, lib_file_name), os.path.join(dir_path, "lib", "binding", "libduckdb"))

extracted_lib_file_path = os.path.join(ext_tmp, lib_file_name)
target_lib_file_path = os.path.join("lib", "binding", "libduckdb")

print("Copying lib to " + target_lib_file_path)
shutil.copy(extracted_lib_file_path, target_lib_file_path)

print("Extracting duckdb.h to src")
zip.extract("duckdb.h", "src")
print("Extracting duckdb.h to temp dir " + ext_tmp)
zip.extract("duckdb.h", ext_tmp)

print("Preprocessing duckdb.h")
Expand All @@ -266,7 +277,7 @@ def get_lib_file_name():
print("Generating C code and TypeScript definitions")
cpp_result, types_result = create_func_defs(os.path.join(ext_tmp, "duckdb-preprocessed.h"))

out = open(os.path.join(dir_path, "src", "duckdb_node_generated.cpp"), 'wb')
out = open(os.path.join("src", "duckdb_node_generated.cpp"), 'wb')
out.write('''// This file is generated by generate-wrapper.py, please do not edit
#include "duckdb.h"
Expand Down

0 comments on commit 4842acc

Please sign in to comment.