+ # N.B. Python 2.x does not have os.symlink for Windows.
+ # Python 3 has os.symlink for Windows, but requires either the admin-
+ # granted privilege SeCreateSymbolicLinkPrivilege or, as of Windows 10
+ # 1703, that Developer Mode be enabled. Hard links and junctions do not
+ # require any extra privileges to create.
+ if os.name == 'nt':
+ # mklink does not tolerate /-delimited path names.
+ t = t.replace('/', '\\')
+ s = s.replace('/', '\\')
+ # N.B. This tool only handles file hardlinks, not directory junctions.
+ subprocess.check_output(['cmd.exe', '/c', 'mklink', '/H', t, s],
+ stderr=subprocess.STDOUT)
+ else:
+ os.symlink(s, t)
+ except OSError as e: