Skip to content

Commit 69b8784

Browse files
Ensure we copy actual file before symlinks
Add implementation of build_package_data method for the subclass which does not use os.chmod that does not suppot symbolic links
1 parent cd6e804 commit 69b8784

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

setup.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ def copy_file(self, src, dst, preserve_mode=True):
8585
_patched_copy_file(src, dst, preserve_mode=preserve_mode)
8686
return (dst, 1)
8787

88+
def build_package_data(self):
89+
"""Copy data files into build directory"""
90+
for package, src_dir, build_dir, filenames in self.data_files:
91+
for filename in filenames:
92+
target = os.path.join(build_dir, filename)
93+
self.mkpath(os.path.dirname(target))
94+
srcfile = os.path.join(src_dir, filename)
95+
outf, copied = self.copy_file(srcfile, target)
96+
srcfile = os.path.abspath(srcfile)
97+
8898

8999
class InstallCmd(_skbuild_install):
90100
def run(self):
@@ -93,13 +103,19 @@ def run(self):
93103
this_dir = os.path.dirname(os.path.abspath(__file__))
94104
dpctl_build_dir = os.path.join(this_dir, self.build_lib, "dpctl")
95105
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)
106+
sofiles = glob.glob(
107+
os.path.join(dpctl_build_dir, "*DPCTLSyclInterface.so*")
108+
)
109+
# insert actual file at the beginning of the list
110+
pos = [i for i, fn in enumerate(sofiles) if not os.path.islink(fn)]
111+
if pos:
112+
hard_file = sofiles.pop(pos[0])
113+
sofiles.insert(0, hard_file)
114+
for fn in sofiles:
100115
base_fn = os.path.basename(fn)
101116
src_file = os.path.join(dpctl_build_dir, base_fn)
102117
dst_file = os.path.join(dpctl_install_dir, base_fn)
118+
os.remove(dst_file)
103119
_patched_copy_file(src_file, dst_file)
104120
return ret
105121

0 commit comments

Comments
 (0)