From 3c1fe51904f062d7ec8c6cbc89f33362105e66e9 Mon Sep 17 00:00:00 2001 From: Andrew Krieger Date: Tue, 2 Apr 2024 11:35:58 -0700 Subject: [PATCH] Handle safe_copy failing to hardlink on Windows due to too many existing links. --- pex/common.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pex/common.py b/pex/common.py index b96020b6a..dcb28fba1 100644 --- a/pex/common.py +++ b/pex/common.py @@ -105,7 +105,6 @@ def do_copy(): os.rename(temp_dest, dest) # If the platform supports hard-linking, use that and fall back to copying. - # Windows does not support hard-linking. if hasattr(os, "link"): try: os.link(source, dest) @@ -127,6 +126,10 @@ def do_copy(): # # See also https://github.com/pex-tool/pex/issues/850 where this was discovered. do_copy() + elif getattr(e, 'winerror', None) == 1142: + # OSError: [WinError 1142] An attempt was made to create more links on a file than + # the file system supports + do_copy() else: raise elif os.path.exists(dest):