Skip to content

Commit de00930

Browse files
Ensure we copy actual file before symlinks
1 parent cd6e804 commit de00930

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

setup.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,19 @@ def run(self):
9393
this_dir = os.path.dirname(os.path.abspath(__file__))
9494
dpctl_build_dir = os.path.join(this_dir, self.build_lib, "dpctl")
9595
dpctl_install_dir = os.path.join(self.install_libbase, "dpctl")
96-
for fn in glob.glob(
97-
os.path.join(dpctl_install_dir, "*DPCTLSyclInterface.so*")
98-
):
99-
os.remove(fn)
96+
sofiles = glob.glob(
97+
os.path.join(dpctl_build_dir, "*DPCTLSyclInterface.so*")
98+
)
99+
# insert actual file at the beginning of the list
100+
pos = [i for i, fn in enumerate(sofiles) if not os.path.islink(fn)]
101+
if pos:
102+
hard_file = sofiles.pop(pos[0])
103+
sofiles.insert(0, hard_file)
104+
for fn in sofiles:
100105
base_fn = os.path.basename(fn)
101106
src_file = os.path.join(dpctl_build_dir, base_fn)
102107
dst_file = os.path.join(dpctl_install_dir, base_fn)
108+
os.remove(dst_file)
103109
_patched_copy_file(src_file, dst_file)
104110
return ret
105111

0 commit comments

Comments
 (0)