Skip to content

Commit 03b668a

Browse files
authored
Only create compiler entry points for the current platform (by default) (#24857)
1 parent 52e67f1 commit 03b668a

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

tools/maint/create_entry_points.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@
6060
}
6161

6262

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+
6468
def generate_entry_points(cmd, path):
6569
sh_file = path + '.sh'
6670
bat_file = path + '.bat'
@@ -81,20 +85,22 @@ def generate_entry_points(cmd, path):
8185
bat_data = bat_data.replace('%~n0', entry_remap[entry_point].replace('/', '\\'))
8286
ps1_data = ps1_data.replace(r"$MyInvocation.MyCommand.Path -replace '\.ps1$', '.py'", fr'"$PSScriptRoot/{entry_remap[entry_point]}.py"')
8387

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)
8893

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)
9197

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)
94100

95101
generate_entry_points(entry_points, os.path.join(__scriptdir__, 'run_python'))
96102
generate_entry_points(compiler_entry_points, os.path.join(__scriptdir__, 'run_python_compiler'))
97103

98104

99105
if __name__ == '__main__':
100-
sys.exit(main())
106+
sys.exit(main('--all' in sys.argv))

0 commit comments

Comments
 (0)