60
60
}
61
61
62
62
63
- def main ():
63
+ def main (all_platforms ):
64
+ is_windows = sys .platform .startswith ('win' )
65
+ do_unix = all_platforms or not is_windows
66
+ do_windows = all_platforms or is_windows
67
+
64
68
def generate_entry_points (cmd , path ):
65
69
sh_file = path + '.sh'
66
70
bat_file = path + '.bat'
@@ -81,20 +85,22 @@ def generate_entry_points(cmd, path):
81
85
bat_data = bat_data .replace ('%~n0' , entry_remap [entry_point ].replace ('/' , '\\ ' ))
82
86
ps1_data = ps1_data .replace (r"$MyInvocation.MyCommand.Path -replace '\.ps1$', '.py'" , fr'"$PSScriptRoot/{ entry_remap [entry_point ]} .py"' )
83
87
84
- out_sh_file = os .path .join (__rootdir__ , entry_point )
85
- with open (out_sh_file , 'w' ) as f :
86
- f .write (sh_data )
87
- os .chmod (out_sh_file , stat .S_IMODE (os .stat (out_sh_file ).st_mode ) | stat .S_IXUSR )
88
+ if do_unix :
89
+ out_sh_file = os .path .join (__rootdir__ , entry_point )
90
+ with open (out_sh_file , 'w' ) as f :
91
+ f .write (sh_data )
92
+ os .chmod (out_sh_file , stat .S_IMODE (os .stat (out_sh_file ).st_mode ) | stat .S_IXUSR )
88
93
89
- with open (os .path .join (__rootdir__ , entry_point + '.bat' ), 'w' ) as f :
90
- f .write (bat_data )
94
+ if do_windows :
95
+ with open (os .path .join (__rootdir__ , entry_point + '.bat' ), 'w' ) as f :
96
+ f .write (bat_data )
91
97
92
- with open (os .path .join (__rootdir__ , entry_point + '.ps1' ), 'w' ) as f :
93
- f .write (ps1_data )
98
+ with open (os .path .join (__rootdir__ , entry_point + '.ps1' ), 'w' ) as f :
99
+ f .write (ps1_data )
94
100
95
101
generate_entry_points (entry_points , os .path .join (__scriptdir__ , 'run_python' ))
96
102
generate_entry_points (compiler_entry_points , os .path .join (__scriptdir__ , 'run_python_compiler' ))
97
103
98
104
99
105
if __name__ == '__main__' :
100
- sys .exit (main ())
106
+ sys .exit (main ('--all' in sys . argv ))
0 commit comments