Skip to content

Commit f204219

Browse files
committed
add debug info to show time of [un]zip
1 parent 6c46685 commit f204219

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/auditwheel/tools.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import argparse
4+
import logging
45
import os
56
import subprocess
67
import zipfile
@@ -11,6 +12,8 @@
1112

1213
_T = TypeVar("_T")
1314

15+
logger = logging.getLogger(__name__)
16+
1417

1518
def unique_by_index(sequence: Iterable[_T]) -> list[_T]:
1619
"""unique elements in `sequence` in the order in which they occur
@@ -90,6 +93,7 @@ def zip2dir(zip_fname: Path, out_dir: Path) -> None:
9093
out_dir : str
9194
Directory path containing files to go in the zip archive
9295
"""
96+
start = datetime.now()
9397
with zipfile.ZipFile(zip_fname, "r") as z:
9498
for name in z.namelist():
9599
member = z.getinfo(name)
@@ -102,6 +106,7 @@ def zip2dir(zip_fname: Path, out_dir: Path) -> None:
102106
attr &= 511 # only keep permission bits
103107
attr |= 6 << 6 # at least read/write for current user
104108
os.chmod(extracted_path, attr)
109+
logger.info(f"zip2dir from {zip_fname} to {out_dir} takes {datetime.now() - start}")
105110

106111

107112
def dir2zip(in_dir: Path, zip_fname: Path, date_time: datetime | None = None) -> None:
@@ -120,6 +125,7 @@ def dir2zip(in_dir: Path, zip_fname: Path, date_time: datetime | None = None) ->
120125
date_time : Optional[datetime]
121126
Time stamp to set on each file in the archive
122127
"""
128+
start = datetime.now()
123129
in_dir = in_dir.resolve(strict=True)
124130
if date_time is None:
125131
st = in_dir.stat()
@@ -141,6 +147,7 @@ def dir2zip(in_dir: Path, zip_fname: Path, date_time: datetime | None = None) ->
141147
zinfo.compress_type = compression
142148
with open(fname, "rb") as fp:
143149
z.writestr(zinfo, fp.read())
150+
logger.info(f"dir2zip from {in_dir} to {zip_fname} takes {datetime.now() - start}")
144151

145152

146153
def tarbz2todir(tarbz2_fname: Path, out_dir: Path) -> None:

0 commit comments

Comments
 (0)