summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Lindström <henrik@lxm.se>2025-05-11 09:56:38 +0200
committerEli Schwartz <eschwartz93@gmail.com>2025-05-11 15:58:40 -0400
commit25854d75846ea9fea357e3b28c5242ffe48dda79 (patch)
treee58b7688de6d3fc392259a4963e4a14e55313418
parent24d7c347f5650b14f991da8f8c92b8ef6e4ff110 (diff)
downloadmeson-25854d75846ea9fea357e3b28c5242ffe48dda79.tar.gz
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.
-rw-r--r--mesonbuild/mdist.py2
1 files changed, 1 insertions, 1 deletions
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)