Godot Engine – Multi-platform 2D and 3D game engine
SCons: Fix `compress_buffer_zstd()` on Alpine Linux
David Snopek593e4734fc2f
diff --git a/methods.py b/methods.pyindex cb26e65ad06..3dca5ad6145 100644--- a/methods.py+++ b/methods.py@@ -1586,9 +1586,12 @@ def compress_buffer_zstd(buffer: bytes, env):# but costs some extra decompression time (+30%). It's not helping at high levels.level = 20 if env["production"] else 7ldm = False if env["production"] or env.dev_build else True- if sys.version_info >= (3, 14):+ has_compression_zstd = True+ try:import compression.zstd-+ except ImportError:+ has_compression_zstd = False+ if has_compression_zstd:CP = compression.zstd.CompressionParameteroptions = {CP.compression_level: level, CP.enable_long_distance_matching: ldm}return compression.zstd.compress(buffer, options=options)@@ -1596,7 +1599,9 @@ def compress_buffer_zstd(buffer: bytes, env):try:import zstandardexcept ImportError:- print_error("Python versions earlier than 3.14 require the `zstandard` module")+ print_error(+ "The Python `zstandard` module is needed. You can install it through your Python package manager."+ )sys.exit(255)params = zstandard.ZstdCompressionParameters.from_level(level, enable_ldm=ldm)return zstandard.ZstdCompressor(compression_params=params).compress(buffer)