trogon icon indicating copy to clipboard operation
trogon copied to clipboard

Improve how trogon is calling the command with arguments

Open bigbirdcode opened this issue 9 months ago • 10 comments

This PR tries to resolve several problems. All the changes are small and connected, that is why I opened just one PR.

Please review it commit by commit.

Fixes:

#104 - In run_command.py file the UserCommandData.to_cli_args() now contains string conversion. I have not added conversion to _to_cli_args() as it was already too complex.

#105 - shlex replaced to oslex, for the need of Windows users. I have added to pyproject.toml. TODO: poetry.lock was not updated, I don't have tooling for that.

#106 - To run well and wait for the output on Windows I have added sys.exit(subprocess.call(..., shell=True)) as the pair of os.execvp() call. Note: shell=True was needed for me.

#81 , #70 , #67 , #65 - I try to fix all these. In the file detect_run_string.py the function detect_run_string() returns a short version of the command, while for execution we need the full version. So I have added a function exact_run_commands(). I have also modified how the command is called in trogon.py and replaced os.execvp() to os.execv().

Tested:

  • Windows, from venv with and without -m, outside of a venv with direct path to Python.exe, and with installed app
  • Linux, from venv with and without -m, outside of a venv with direct path to python3

I have not tested with pipx or such cases. Please tell me of more modification is needed.

bigbirdcode avatar Feb 01 '25 20:02 bigbirdcode

I have tested this PR and it solve my issues with running commands on Windows. Especially https://github.com/Textualize/trogon/issues/67.

bissonex avatar Mar 21 '25 16:03 bissonex

I am waiting on the merge as well

Mythical-Github avatar Apr 04 '25 11:04 Mythical-Github

@daneah by any chance can you review and comment my PR?

bigbirdcode avatar Apr 06 '25 19:04 bigbirdcode

I'll try to review in depth soon @bigbirdcode — I'm working through finalizing my talk about our internal CLI tooling for PyTexas this coming weekend.

daneah avatar Apr 06 '25 23:04 daneah

This PR also solves #46 I am waiting for the merge.

Tijoxa avatar Jun 26 '25 06:06 Tijoxa

Same, been for a while, currently I am monkey patching instead, and would really rather not

Mythical-Github avatar Jun 26 '25 16:06 Mythical-Github

Sorry for not replying for a long time, I have changed job, I had other priorities in my life. But now I fixed the finding, thank you for that, and I'm ready to do other changes if needed.

You can also take into account that Python 3.14 has changed the argparse module, it now has a _prog_name function, with the same goal, to find the right executable name.

bigbirdcode avatar Jun 28 '25 08:06 bigbirdcode

Are there any news on this? I have the issue calling os.execvp on Mac M1 with Python 3.11 Sound that there would be a solution to fix this that is pending a merge.

Is there something I can do to help bring this into trogons release?

42sol-eu avatar Jul 25 '25 21:07 42sol-eu

This is taking an awfully long time to merge in. I am not trying to be impatient, but it's been months, and this is a small easy to understand change. This change fixes a lot of things that cause trogon to flat out not work on windows. Which is a lot of my users for my applications.

Mythical-Github avatar Aug 29 '25 23:08 Mythical-Github

Is there anything I can help to support a new release? My previous team use my fork and branch to install Trogon on Windows. But this is sad...

bigbirdcode avatar Aug 30 '25 16:08 bigbirdcode