(all_platforms, use_bat_file)
| 84 | |
| 85 | |
| 86 | def main(all_platforms, use_bat_file): |
| 87 | if 'EM_USE_BAT_FILES' in os.environ: |
| 88 | use_bat_file = True |
| 89 | is_windows = sys.platform.startswith('win') |
| 90 | is_msys2 = 'MSYSTEM' in os.environ |
| 91 | do_unix = all_platforms or not is_windows or is_msys2 |
| 92 | do_windows = all_platforms or is_windows |
| 93 | |
| 94 | def generate_entry_points(cmd, path): |
| 95 | sh_file = path + '.sh' |
| 96 | bat_file = path + '.bat' |
| 97 | ps1_file = path + '.ps1' |
| 98 | sh_file = read_file(sh_file) |
| 99 | bat_file = read_file(bat_file) |
| 100 | ps1_file = read_file(ps1_file) |
| 101 | |
| 102 | for entry_point in cmd: |
| 103 | sh_data = sh_file |
| 104 | bat_data = bat_file |
| 105 | ps1_data = ps1_file |
| 106 | if entry_point in entry_remap: |
| 107 | sh_data = sh_data.replace('$0', '$(dirname $0)/' + entry_remap[entry_point]) |
| 108 | bat_data = bat_data.replace('%~n0', entry_remap[entry_point].replace('/', '\\')) |
| 109 | ps1_data = ps1_data.replace(r"$MyInvocation.MyCommand.Path -replace '\.ps1$', '.py'", fr'"$PSScriptRoot/{entry_remap[entry_point]}.py"') |
| 110 | |
| 111 | launcher = os.path.join(__rootdir__, entry_point) |
| 112 | if do_unix: |
| 113 | write_file(launcher, sh_data) |
| 114 | make_executable(launcher) |
| 115 | |
| 116 | if do_windows: |
| 117 | maybe_remove(launcher + '.ps1') |
| 118 | maybe_remove(launcher + '.exe') |
| 119 | if use_bat_file: |
| 120 | write_file(launcher + '.bat', bat_data) |
| 121 | write_file(launcher + '.ps1', ps1_data) |
| 122 | else: |
| 123 | shutil.copyfile(windows_exe, launcher + '.exe') |
| 124 | |
| 125 | generate_entry_points(entry_points, os.path.join(__scriptdir__, 'run_python')) |
| 126 | generate_entry_points(compiler_entry_points, os.path.join(__scriptdir__, 'run_python_compiler')) |
| 127 | |
| 128 | |
| 129 | if __name__ == '__main__': |
no test coverage detected