mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The `__future__` we relied on is now, where the 3 specific things are all included [since Python 3.0](https://docs.python.org/3/library/__future__.html): * absolute_import * print_function * unicode_literals * division These import statements are no-ops and are no longer necessary.
30 lines
862 B
Python
30 lines
862 B
Python
#!/usr/bin/env python3
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
if len(sys.argv) < 3:
|
|
print('Too few args to ' + sys.argv[0])
|
|
print('Usage: symlink.py <link_points_to> <link_path> [--dir | --file]')
|
|
sys.exit(1)
|
|
|
|
points_to = sys.argv[1]
|
|
link_path = sys.argv[2]
|
|
|
|
if sys.platform == 'win32':
|
|
points_to = points_to.replace('/', '\\')
|
|
link_path = link_path.replace('/', '\\')
|
|
if len(sys.argv) >= 4 and sys.argv[3] == '--dir':
|
|
is_dir = True
|
|
elif len(sys.argv) >= 4 and sys.argv[3] == '--file':
|
|
is_dir = False
|
|
else:
|
|
is_dir = os.path.isdir(sys.argv[1])
|
|
|
|
# Windows symlink support was introduced in python 3.2
|
|
subprocess.check_call(['cmd.exe', '/C',
|
|
'mklink ' + ('/D' if is_dir else ''),
|
|
link_path, points_to])
|
|
else:
|
|
os.symlink(points_to, link_path)
|