ynput / ayon-launcher

AYON desktop application launcher
Apache License 2.0
32 stars 14 forks source link

Remove start.py from sys argv #94

Closed tokejepsen closed 8 months ago

tokejepsen commented 9 months ago

Changelog Description

When running python script that uses argparse, the extra argument of the start.py file messes up the parsing.

Testing notes:

  1. Setup python script like below:
    
    import argparse

def main():

Create ArgumentParser object

parser = argparse.ArgumentParser(description="Script description")

# Add arguments
parser.add_argument(
    "--something", type=str, required=True
)

# Parse the arguments
args = parser.parse_args()
print(args.something)

if name == "main": main()

2. Run commandline to execute python script in AYON context:

.\tools\manage.ps1 run C:\Users\tokejepsen\Desktop\temp.py --something else


Error this PR fixes:

usage: start.py [-h] --something SOMETHING start.py: error: unrecognized arguments: C:\Users\tokejepsen\Desktop\temp.py

iLLiCiTiT commented 9 months ago

This would break openpype/ayon-core logic to launch ayon subprocess.

tokejepsen commented 9 months ago

This would break openpype/ayon-core logic to launch ayon subprocess.

Could you elaborate so I can test and find a solution? Is it when using the tray?

iLLiCiTiT commented 8 months ago

Could you elaborate so I can test and find a solution? Is it when using the tray?

You can't use get_ayon_launch_args (or legacy get_openpype_launch_args) in the script with this change. And the first argument is executable path, when used from build.

tokejepsen commented 8 months ago

Ok, will close and do this in the python script instead.

iLLiCiTiT commented 8 months ago

It can be done, but more carefully. Will create PR when I'll find some time. You can use ayon run <script> for the time being.