Skip to content

Commit

Permalink
Update _get_zstd.py
Browse files Browse the repository at this point in the history
The zip file structure changed. The files are now in a subdirectory.
  • Loading branch information
martinellimarco authored May 4, 2024
1 parent f2805fd commit 8375f26
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions libzstd/_get_zstd.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,20 @@


with zipfile.ZipFile(io.BytesIO(zip_data)) as zf:
INCLUDE_DIR.joinpath("zstd.h").write_bytes(zf.read("include/zstd.h"))
LIBRARY_DIR.joinpath("libzstd.dll").write_bytes(zf.read("dll/libzstd.dll"))
files = zf.namelist()
zstd_h = next((f for f in files if "include/zstd.h" in f), None)
libzstd_dll = next((f for f in files if "dll/libzstd.dll" in f), None)
libzstd_lib = next((f for f in files if "dll/libzstd.lib" in f), None)
libzstd_dll_a = next((f for f in files if "dll/libzstd.dll.a" in f), None)

INCLUDE_DIR.joinpath("zstd.h").write_bytes(zf.read(zstd_h))
LIBRARY_DIR.joinpath("libzstd.dll").write_bytes(zf.read(libzstd_dll))
try:
_libzstd_lib = zf.read("dll/libzstd.lib")
_libzstd_lib = zf.read(libzstd_lib)
except KeyError:
_libzstd_lib = zf.read("dll/libzstd.dll.a")
_libzstd_lib = zf.read(libzstd_dll_a)
# this renames libzstd.dll.a to libzstd.lib for setuptools to work
LIBRARY_DIR.joinpath("libzstd.lib").write_bytes(_libzstd_lib)


print("success")

0 comments on commit 8375f26

Please sign in to comment.