def symlink(source, link_name):
if os.path.islink(link_name) and os.readlink(link_name) == source:<EOL><INDENT>return<EOL><DEDENT>os_symlink = getattr(os, "<STR_LIT>", None)<EOL>if callable(os_symlink):<EOL><INDENT>os_symlink(source, link_name)<EOL><DEDENT>else:<EOL><INDENT>import ctypes<EOL>csl = ctypes.windll.kernel32.CreateSymbolicLinkW<EOL>csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)<EOL>csl.restype = ctypes.c_ubyte<EOL>flags = <NUM_LIT:1> if os.path.isdir(source) else <NUM_LIT:0><EOL>if csl(link_name, source, flags) == <NUM_LIT:0>:<EOL><INDENT>raise ctypes.WinError()<EOL><DEDENT><DEDENT>
Method to allow creating symlinks on Windows