Conversation
|
I've been experiencing issue #70 while running Trogon with my python installation managed by pyenv, and this change fixes it. In the meantime for anyone else experiencing this issue, manually activating my venv with |
daneah
left a comment
There was a problem hiding this comment.
On further checking, I run Trogon for a CLI installed as a package and run as an executable (call it mycli) through pipx, and this change breaks that use case—Trogon ends up looking for mycli in the directory where the program is invoked, rather than on the $PATH.
Might we handle both cases reasonably here?
|
I'm not familiar with pipx. But however are there only two options of "sys.executable": python itself (and its variants) and "mycli-package"? |
|
pipx isn't necessarily the important bit, as there are a few other common ways by which packages can expose executables. But the crux of this use case is that the CLI app is run by being another executable on the path (via #!/path/to/some/python
# -*- coding: utf-8 -*-
import re
import sys
from mycli.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main()) |
solves #70