3 # This is a valid shell script and also a valid Python script. When this file
4 # is executed as a shell script, it finds a python binary and executes this
5 # file as a Python script, passing along all of the command line arguments.
6 # When this file is executed as a Python script, it loads and runs Dotbot. This
7 # is useful because we don't know the name of the python binary.
9 ''':' # begin python string; this line is interpreted by the shell as `:`
10 command -v python3
>/dev
/null
2>&1 && exec python3
"$0" "$@"
11 command -v python
>/dev
/null
2>&1 && exec python
"$0" "$@"
12 >&2 echo "error: cannot find python"
20 # this file is syntactically valid Python 2; bail out if the interpreter is Python 2
21 if sys.version_info[0] < 3:
22 print('error
: this version of Dotbot is not compatible with Python
2:\nhttps
://github.com
/anishathalye
/dotbot
/wiki
/Troubleshooting
#python-2')
24 if sys.version_info
< (3, 6):
25 print
('error: this version of Dotbot requires Python 3.6+')
28 PROJECT_ROOT_DIRECTORY
= os.path.
dirname(
29 os.path.
dirname(os.path.realpath
(__file__
)))
32 path
= os.path.
join(PROJECT_ROOT_DIRECTORY
, 'lib', lib_path
)
33 sys.path.insert
(0, path
)
37 if os.path.exists
(os.path.
join(PROJECT_ROOT_DIRECTORY
, 'dotbot')):
38 if PROJECT_ROOT_DIRECTORY not
in sys.path
:
39 sys.path.insert
(0, PROJECT_ROOT_DIRECTORY
)
40 os.putenv
('PYTHONPATH', PROJECT_ROOT_DIRECTORY
)
47 if __name__
== '__main__':