Skip to content

Commit 62346e2

Browse files
authored
1 parent 91cbe06 commit 62346e2

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

setup.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,20 @@ def add_mim_extension():
134134

135135
if mode == 'symlink':
136136
src_relpath = osp.relpath(src_path, osp.dirname(tar_path))
137-
os.symlink(src_relpath, tar_path)
138-
elif mode == 'copy':
137+
try:
138+
os.symlink(src_relpath, tar_path)
139+
except OSError:
140+
# Creating a symbolic link on windows may raise an
141+
# `OSError: [WinError 1314]` due to privilege. If
142+
# the error happens, the src file will be copied
143+
mode = 'copy'
144+
warnings.warn(
145+
f'Failed to create a symbolic link for {src_relpath}, '
146+
f'and it will be copied to {tar_path}')
147+
else:
148+
continue
149+
150+
if mode == 'copy':
139151
if osp.isfile(src_path):
140152
shutil.copyfile(src_path, tar_path)
141153
elif osp.isdir(src_path):

0 commit comments

Comments
 (0)