Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions tools/maint/create_entry_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@
}


def main():
def main(all_platforms):
is_windows = sys.platform.startswith('win')
do_unix = all_platforms or not is_windows
do_windows = all_platforms or is_windows

def generate_entry_points(cmd, path):
sh_file = path + '.sh'
bat_file = path + '.bat'
Expand All @@ -81,20 +85,22 @@ def generate_entry_points(cmd, path):
bat_data = bat_data.replace('%~n0', entry_remap[entry_point].replace('/', '\\'))
ps1_data = ps1_data.replace(r"$MyInvocation.MyCommand.Path -replace '\.ps1$', '.py'", fr'"$PSScriptRoot/{entry_remap[entry_point]}.py"')

out_sh_file = os.path.join(__rootdir__, entry_point)
with open(out_sh_file, 'w') as f:
f.write(sh_data)
os.chmod(out_sh_file, stat.S_IMODE(os.stat(out_sh_file).st_mode) | stat.S_IXUSR)
if do_unix:
out_sh_file = os.path.join(__rootdir__, entry_point)
with open(out_sh_file, 'w') as f:
f.write(sh_data)
os.chmod(out_sh_file, stat.S_IMODE(os.stat(out_sh_file).st_mode) | stat.S_IXUSR)

with open(os.path.join(__rootdir__, entry_point + '.bat'), 'w') as f:
f.write(bat_data)
if do_windows:
with open(os.path.join(__rootdir__, entry_point + '.bat'), 'w') as f:
f.write(bat_data)

with open(os.path.join(__rootdir__, entry_point + '.ps1'), 'w') as f:
f.write(ps1_data)
with open(os.path.join(__rootdir__, entry_point + '.ps1'), 'w') as f:
f.write(ps1_data)

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


if __name__ == '__main__':
sys.exit(main())
sys.exit(main('--all' in sys.argv))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this going to be used from?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe nowhere? I just figured some folks might want to generate all possible versions of the scripts. As a developer its quite useful so you can see what would happen on a windows machine for example.