def make_script(python_script, target_path='<STR_LIT>', target_name='<STR_LIT>', user=False, make_link=False,<EOL>force=False, remove=False, no_check_shebang=False, no_check_path=False):
if user and target_path:<EOL><INDENT>raise RunnerErrorWithUsage("<STR_LIT>")<EOL><DEDENT>source = os.path.abspath(python_script)<EOL>dest_dir = os.path.normpath(os.path.expanduser('<STR_LIT>' if user else target_path or os.path.dirname(sys.executable)))<EOL>target = os.path.join(dest_dir, target_name if target_name else os.path.splitext(os.path.basename(source))[<NUM_LIT:0>])<EOL>target_exists = os.path.exists(target)<EOL>if remove:<EOL><INDENT>if target_exists:<EOL><INDENT>os.unlink(target)<EOL>print("<STR_LIT>" % target)<EOL><DEDENT>else:<EOL><INDENT>print("<STR_LIT>" % target)<EOL><DEDENT>return<EOL><DEDENT>if not os.path.exists(source):<EOL><INDENT>raise RunnerError("<STR_LIT>" % source)<EOL><DEDENT>if DEBUG:<EOL><INDENT>print('<STR_LIT>', source, target)<EOL><DEDENT>if target_exists:<EOL><INDENT>def same_file_same_type(source, target):<EOL><INDENT>if os.path.islink(target):<EOL><INDENT>return make_link and os.path.samefile(source, target)<EOL><DEDENT>else:<EOL><INDENT>return not make_link and (open(source, '<STR_LIT:rb>').read() == open(target, '<STR_LIT:rb>').read())<EOL><DEDENT><DEDENT>if same_file_same_type(source, target):<EOL><INDENT>print("<STR_LIT>" % target)<EOL>return<EOL><DEDENT>elif not force:<EOL><INDENT>raise RunnerError("<STR_LIT>" % target)<EOL><DEDENT><DEDENT>if not os.path.isdir(dest_dir):<EOL><INDENT>try:<EOL><INDENT>os.makedirs(dest_dir)<EOL><DEDENT>except OSError:<EOL><INDENT>raise RunnerError("<STR_LIT>" % dest_dir)<EOL><DEDENT><DEDENT>if not no_check_shebang:<EOL><INDENT>first_line = open(source).readline()<EOL>if not ('<STR_LIT>' in first_line and '<STR_LIT>' in first_line):<EOL><INDENT>raise RunnerError("<STR_LIT>")<EOL><DEDENT><DEDENT>if target_exists:<EOL><INDENT>os.unlink(target)<EOL><DEDENT>import stat<EOL>perms = stat.S_IXUSR | stat.S_IXGRP<EOL>if os.getuid() == <NUM_LIT:0>:<EOL><INDENT>perms |= stat.S_IXOTH<EOL><DEDENT>if make_link:<EOL><INDENT>st = os.stat(source)<EOL>if st.st_mode & perms != perms:<EOL><INDENT>os.chmod(source, st.st_mode | perms)<EOL><DEDENT>os.symlink(source, target)<EOL>st = os.stat(target)<EOL>os.chmod(target, st.st_mode | perms)<EOL>print('<STR_LIT>' % (source, target))<EOL><DEDENT>else:<EOL><INDENT>import shutil<EOL>shutil.copyfile(source, target)<EOL>st = os.stat(target)<EOL>os.chmod(target, st.st_mode | perms)<EOL>print('<STR_LIT>' % (source, target))<EOL><DEDENT>path_env = os.environ.get('<STR_LIT>')<EOL>if not no_check_path and (not path_env or dest_dir not in path_env):<EOL><INDENT>print("<STR_LIT>" % dest_dir)<EOL><DEDENT>
v{VERSION}
    This script makes a command line script out of a python script.
    For example, 'clingon script.py' will copy or symlink script.py
    (without the .py extension) to:
    - <python-exe-path>/script (default),
    - <target-path>/script if --target-path is specfied,
    - ~/bin/script if --user is specified,
    and then set the copy / symlink as executable.
    See https://github.com/francois-vincent/clingon