Skip to content

Commit 5c03937

Browse files
committed
Update
[ghstack-poisoned]
1 parent d46bb95 commit 5c03937

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

setup.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,16 @@ def build_extension(self, ext: _BaseExtension) -> None:
684684
name = dst_file.name
685685
if ".so." in name:
686686
unversioned = dst_file.with_name(name.split(".so.")[0] + ".so")
687-
if not unversioned.exists():
687+
# exists() follows symlinks, so a stale link left by an earlier build
688+
# looks absent and then symlink() fails. Replace it outright. A
689+
# failure here must not break packaging, since the real library is
690+
# already in place and only the convenience alias would be missing.
691+
try:
692+
if unversioned.is_symlink() or unversioned.exists():
693+
unversioned.unlink()
688694
os.symlink(name, unversioned)
695+
except OSError:
696+
pass
689697

690698
# Ensure that the destination file is writable, even if the source was
691699
# not. build_py does this by passing preserve_mode=False to copy_file,

0 commit comments

Comments
 (0)