@@ -358,12 +358,6 @@ def _getinfo(self) -> ZipInfo:
358
358
return self ._zip_file .getinfo (self .src_record_path )
359
359
360
360
def save (self ) -> None :
361
- # directory creation is lazy and after file filtering
362
- # to ensure we don't install empty dirs; empty dirs can't be
363
- # uninstalled.
364
- parent_dir = os .path .dirname (self .dest_path )
365
- ensure_dir (parent_dir )
366
-
367
361
# When we open the output file below, any existing file is truncated
368
362
# before we start writing the new contents. This is fine in most
369
363
# cases, but can cause a segfault if pip has loaded a shared
@@ -421,7 +415,7 @@ def make(
421
415
return super ().make (specification , options )
422
416
423
417
424
- def _install_wheel (
418
+ def _install_wheel ( # noqa: C901, PLR0915 function is too long
425
419
name : str ,
426
420
wheel_zip : ZipFile ,
427
421
wheel_path : str ,
@@ -580,7 +574,15 @@ def is_entrypoint_wrapper(file: "File") -> bool:
580
574
script_scheme_files = map (ScriptFile , script_scheme_files )
581
575
files = chain (files , script_scheme_files )
582
576
577
+ existing_parents = set ()
583
578
for file in files :
579
+ # directory creation is lazy and after file filtering
580
+ # to ensure we don't install empty dirs; empty dirs can't be
581
+ # uninstalled.
582
+ parent_dir = os .path .dirname (file .dest_path )
583
+ if parent_dir not in existing_parents :
584
+ ensure_dir (parent_dir )
585
+ existing_parents .add (parent_dir )
584
586
file .save ()
585
587
record_installed (file .src_record_path , file .dest_path , file .changed )
586
588
0 commit comments