@@ -117,6 +117,7 @@ def __init__(
117
117
118
118
self ._tmp_dir : tempfile .TemporaryDirectory = None
119
119
self ._build_success = False
120
+ self ._is_greater_than_python_37 = sys .version_info .minor >= 7 and sys .version_info .major >= 3
120
121
121
122
def ensure_args (self ):
122
123
if not self .unzip :
@@ -188,15 +189,15 @@ def create_archive_layer(self):
188
189
else :
189
190
compression = ZIP_DEFLATED
190
191
compresslevel = 0
191
- with ZipFile ( str ( self . _output_path ),
192
- mode = 'w' ,
193
- compression = compression ,
194
- compresslevel = compresslevel ) as zf :
192
+ _kwargs = dict ( mode = 'w' , compression = compression )
193
+ if self . _is_greater_than_python_37 :
194
+ _kwargs [ 'compresslevel' ] = compresslevel
195
+ with ZipFile ( str ( self . _output_path ), ** _kwargs ) as zf :
195
196
for f in self ._cache_path .glob ('**/*' ):
196
197
zf .write (f , str (f .relative_to (self ._cache_path )))
197
198
198
199
def create_archive (self ):
199
- if sys . version_info . minor >= 7 :
200
+ if self . _is_greater_than_python_37 :
200
201
zipapp .create_archive (source = self ._cache_path ,
201
202
target = str (self ._output_path .absolute ()),
202
203
interpreter = self .interpreter ,
0 commit comments