From 25854d75846ea9fea357e3b28c5242ffe48dda79 Mon Sep 17 00:00:00 2001 From: Henrik Lindström Date: Sun, 11 May 2025 09:56:38 +0200 Subject: mdist.py: Import gzip only when needed This is already done for bz2 and lzma, but even gzip is not always available in a minimal Python installation. For example, this happens when building Python from source without having zlib available. --- mesonbuild/mdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesonbuild/mdist.py b/mesonbuild/mdist.py index 0361606a5..6e1bfd0ee 100644 --- a/mesonbuild/mdist.py +++ b/mesonbuild/mdist.py @@ -7,7 +7,6 @@ from __future__ import annotations import abc import argparse -import gzip import os import sys import shlex @@ -294,6 +293,7 @@ class HgDist(Dist): shutil.copyfileobj(tf, bf) output_names.append(bz2name) if 'gztar' in archives: + import gzip with gzip.open(gzname, 'wb') as zf, open(tarname, 'rb') as tf: shutil.copyfileobj(tf, zf) output_names.append(gzname) -- cgit v1.2.3