Skip to content

Commit c6f7ff9

Browse files
committed
Add ZIP support
1 parent 0cc00ab commit c6f7ff9

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

setup.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@
88
def get_extensions() -> list[Extension]:
99
import numpy # Lazy import; numpy provided via build-system requires
1010

11-
# Gather C++ sources excluding file_zip.cpp
11+
# Gather all C++ sources (including file_zip.cpp for ZIP support)
12+
# Exclude file.cpp since file_zip.cpp provides the full implementation
1213
libgambatte_sources = [
1314
p
1415
for p in glob.glob("libgambatte/**/*.cpp", recursive=True)
15-
if not p.endswith("file_zip.cpp")
16+
if not p.endswith("file.cpp")
1617
]
1718

18-
# Include dirs: parents of all headers + cython wrapper dir + numpy include
19+
# Add minizip C sources for ZIP support
20+
minizip_sources = glob.glob("libgambatte/src/file/unzip/*.c", recursive=True)
21+
22+
# Include dirs: parents of all headers
1923
include_dirs = list(
2024
{str(Path(h).parent) for h in glob.glob("libgambatte/**/*.h", recursive=True)}
2125
)
@@ -25,7 +29,12 @@ def get_extensions() -> list[Extension]:
2529
language="c++",
2630
include_dirs=[*include_dirs, "libgambatte_ext", numpy.get_include()],
2731
extra_compile_args=["-DHAVE_STDINT_H"],
28-
sources=[*libgambatte_sources, "libgambatte_ext/libgambatte.pyx"],
32+
libraries=["z"], # Link against zlib for ZIP support
33+
sources=[
34+
*libgambatte_sources,
35+
*minizip_sources,
36+
"libgambatte_ext/libgambatte.pyx",
37+
],
2938
)
3039

3140
termblit_extension = Extension(

0 commit comments

Comments
 (0)