@@ -216,34 +216,62 @@ def _calc(prefix, filename, calculate_dest=calculate_dest):
216216
217217
218218def _create_shortcut_pep514 (cmd , install , shortcut ):
219- from .pep514utils import update_registry
220- update_registry (cmd .pep514_root , install , shortcut , cmd .tags )
219+ try :
220+ from .pep514utils import update_registry
221+ root = cmd .pep514_root
222+ except (ImportError , AttributeError ):
223+ LOGGER .debug ("Skipping PEP 514 creation." , exc_info = True )
224+ return
225+ update_registry (root , install , shortcut , cmd .tags )
221226
222227
223228def _cleanup_shortcut_pep514 (cmd , install_shortcut_pairs ):
224- from .pep514utils import cleanup_registry
225- cleanup_registry (cmd .pep514_root , {s ["Key" ] for i , s in install_shortcut_pairs }, cmd .tags )
229+ try :
230+ from .pep514utils import cleanup_registry
231+ root = cmd .pep514_root
232+ except (ImportError , AttributeError ):
233+ LOGGER .debug ("Skipping PEP 514 cleanup." , exc_info = True )
234+ return
235+ cleanup_registry (root , {s ["Key" ] for i , s in install_shortcut_pairs }, getattr (cmd , "tags" , None ))
226236
227237
228238def _create_start_shortcut (cmd , install , shortcut ):
229- from .startutils import create_one
230- create_one (cmd .start_folder , install , shortcut , cmd .tags )
239+ try :
240+ from .startutils import create_one
241+ root = cmd .start_folder
242+ except (ImportError , AttributeError ):
243+ LOGGER .debug ("Skipping Start shortcut creation." , exc_info = True )
244+ return
245+ create_one (root , install , shortcut , cmd .tags )
231246
232247
233248def _cleanup_start_shortcut (cmd , install_shortcut_pairs ):
234- from .startutils import cleanup
235- cleanup (cmd .start_folder , [s for i , s in install_shortcut_pairs ], cmd .tags )
249+ try :
250+ from .startutils import cleanup
251+ root = cmd .start_folder
252+ except (ImportError , AttributeError ):
253+ LOGGER .debug ("Skipping Start shortcut cleanup." , exc_info = True )
254+ return
255+ cleanup (root , [s for i , s in install_shortcut_pairs ], getattr (cmd , "tags" , None ))
236256
237257
238258def _create_arp_entry (cmd , install , shortcut ):
239259 # ARP = Add/Remove Programs
240- from .arputils import create_one
241- create_one (install , shortcut , cmd .tags )
260+ try :
261+ from .arputils import create_one
262+ except ImportError :
263+ LOGGER .debug ("Skipping ARP entry creation." , exc_info = True )
264+ return
265+ create_one (install , shortcut , getattr (cmd , "tags" , None ))
242266
243267
244268def _cleanup_arp_entries (cmd , install_shortcut_pairs ):
245- from .arputils import cleanup
246- cleanup ([i for i , s in install_shortcut_pairs ], cmd .tags )
269+ try :
270+ from .arputils import cleanup
271+ except ImportError :
272+ LOGGER .debug ("Skipping ARP entry cleanup." , exc_info = True )
273+ return
274+ cleanup ([i for i , s in install_shortcut_pairs ], getattr (cmd , "tags" , None ))
247275
248276
249277def _create_entrypoints (cmd , install , shortcut ):
@@ -279,7 +307,7 @@ def update_all_shortcuts(cmd, *, _aliasutils=None):
279307 try :
280308 aliases .extend (_aliasutils .calculate_aliases (cmd , i ))
281309 except LookupError :
282- LOGGER .warn ("Failed to process aliases for %s." , i [ "display-name" ] )
310+ LOGGER .warn ("Failed to process aliases for %s." , i . get ( "display-name" , i [ "id" ]) )
283311 LOGGER .debug ("TRACEBACK" , exc_info = True )
284312 _aliasutils .create_aliases (cmd , aliases )
285313 _aliasutils .cleanup_aliases (cmd , preserve = aliases )
@@ -301,7 +329,8 @@ def update_all_shortcuts(cmd, *, _aliasutils=None):
301329 shortcut_written .setdefault (s ["kind" ], []).append ((i , s ))
302330
303331 for k , (_ , cleanup ) in SHORTCUT_HANDLERS .items ():
304- cleanup (cmd , shortcut_written .get (k , []))
332+ if cleanup :
333+ cleanup (cmd , shortcut_written .get (k , []))
305334
306335
307336def print_cli_shortcuts (cmd ):
0 commit comments