@@ -61,7 +61,6 @@ def make_tarball(
6161 base_dir : str | os .PathLike [str ],
6262 compress : Literal ["gzip" , "bzip2" , "xz" ] | None = "gzip" ,
6363 verbose : bool = False ,
64- dry_run : bool = False ,
6564 owner : str | None = None ,
6665 group : str | None = None ,
6766) -> str :
@@ -96,7 +95,7 @@ def make_tarball(
9695 archive_name = base_name + '.tar'
9796 archive_name += compress_ext .get (compress , '' )
9897
99- mkpath (os .path .dirname (archive_name ), dry_run = dry_run )
98+ mkpath (os .path .dirname (archive_name ))
10099
101100 # creating the tarball
102101 import tarfile # late import so Python build itself doesn't break
@@ -115,21 +114,19 @@ def _set_uid_gid(tarinfo):
115114 tarinfo .uname = owner
116115 return tarinfo
117116
118- if not dry_run :
119- tar = tarfile .open (archive_name , f'w|{ tar_compression [compress ]} ' )
120- try :
121- tar .add (base_dir , filter = _set_uid_gid )
122- finally :
123- tar .close ()
117+ tar = tarfile .open (archive_name , f'w|{ tar_compression [compress ]} ' )
118+ try :
119+ tar .add (base_dir , filter = _set_uid_gid )
120+ finally :
121+ tar .close ()
124122
125123 return archive_name
126124
127125
128- def make_zipfile ( # noqa: C901
126+ def make_zipfile (
129127 base_name : str ,
130128 base_dir : str | os .PathLike [str ],
131129 verbose : bool = False ,
132- dry_run : bool = False ,
133130) -> str :
134131 """Create a zip file from all the files under 'base_dir'.
135132
@@ -140,7 +137,7 @@ def make_zipfile( # noqa: C901
140137 file.
141138 """
142139 zip_filename = base_name + ".zip"
143- mkpath (os .path .dirname (zip_filename ), dry_run = dry_run )
140+ mkpath (os .path .dirname (zip_filename ))
144141
145142 # If zipfile module is not available, try spawning an external
146143 # 'zip' command.
@@ -151,7 +148,7 @@ def make_zipfile( # noqa: C901
151148 zipoptions = "-rq"
152149
153150 try :
154- spawn (["zip" , zipoptions , zip_filename , base_dir ], dry_run = dry_run )
151+ spawn (["zip" , zipoptions , zip_filename , base_dir ])
155152 except DistutilsExecError :
156153 # XXX really should distinguish between "couldn't find
157154 # external 'zip' command" and "zip failed".
@@ -164,29 +161,26 @@ def make_zipfile( # noqa: C901
164161 else :
165162 log .info ("creating '%s' and adding '%s' to it" , zip_filename , base_dir )
166163
167- if not dry_run :
168- try :
169- zip = zipfile .ZipFile (
170- zip_filename , "w" , compression = zipfile .ZIP_DEFLATED
171- )
172- except RuntimeError :
173- zip = zipfile .ZipFile (zip_filename , "w" , compression = zipfile .ZIP_STORED )
174-
175- with zip :
176- if base_dir != os .curdir :
177- path = os .path .normpath (os .path .join (base_dir , '' ))
164+ try :
165+ zip = zipfile .ZipFile (zip_filename , "w" , compression = zipfile .ZIP_DEFLATED )
166+ except RuntimeError :
167+ zip = zipfile .ZipFile (zip_filename , "w" , compression = zipfile .ZIP_STORED )
168+
169+ with zip :
170+ if base_dir != os .curdir :
171+ path = os .path .normpath (os .path .join (base_dir , '' ))
172+ zip .write (path , path )
173+ log .info ("adding '%s'" , path )
174+ for dirpath , dirnames , filenames in os .walk (base_dir ):
175+ for name in dirnames :
176+ path = os .path .normpath (os .path .join (dirpath , name , '' ))
178177 zip .write (path , path )
179178 log .info ("adding '%s'" , path )
180- for dirpath , dirnames , filenames in os . walk ( base_dir ) :
181- for name in dirnames :
182- path = os .path .normpath ( os . path . join ( dirpath , name , '' ))
179+ for name in filenames :
180+ path = os . path . normpath ( os . path . join ( dirpath , name ))
181+ if os .path .isfile ( path ):
183182 zip .write (path , path )
184183 log .info ("adding '%s'" , path )
185- for name in filenames :
186- path = os .path .normpath (os .path .join (dirpath , name ))
187- if os .path .isfile (path ):
188- zip .write (path , path )
189- log .info ("adding '%s'" , path )
190184
191185 return zip_filename
192186
@@ -219,7 +213,6 @@ def make_archive(
219213 root_dir : str | os .PathLike [str ] | bytes | os .PathLike [bytes ] | None = None ,
220214 base_dir : str | None = None ,
221215 verbose : bool = False ,
222- dry_run : bool = False ,
223216 owner : str | None = None ,
224217 group : str | None = None ,
225218) -> str : ...
@@ -230,7 +223,6 @@ def make_archive(
230223 root_dir : str | os .PathLike [str ] | bytes | os .PathLike [bytes ],
231224 base_dir : str | None = None ,
232225 verbose : bool = False ,
233- dry_run : bool = False ,
234226 owner : str | None = None ,
235227 group : str | None = None ,
236228) -> str : ...
@@ -240,7 +232,6 @@ def make_archive(
240232 root_dir : str | os .PathLike [str ] | bytes | os .PathLike [bytes ] | None = None ,
241233 base_dir : str | None = None ,
242234 verbose : bool = False ,
243- dry_run : bool = False ,
244235 owner : str | None = None ,
245236 group : str | None = None ,
246237) -> str :
@@ -264,13 +255,12 @@ def make_archive(
264255 if root_dir is not None :
265256 log .debug ("changing into '%s'" , root_dir )
266257 base_name = os .path .abspath (base_name )
267- if not dry_run :
268- os .chdir (root_dir )
258+ os .chdir (root_dir )
269259
270260 if base_dir is None :
271261 base_dir = os .curdir
272262
273- kwargs = {'dry_run' : dry_run }
263+ kwargs : dict [ str , bool | None ] = {}
274264
275265 try :
276266 format_info = ARCHIVE_FORMATS [format ]
0 commit comments