Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

execvp fix #84

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

antonio-antuan
Copy link

solves #70

@DanielMaysWilliams
Copy link

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 source ~/.pyenv/path/to/env/bin/activate allows me to run my Trogon app.

@daneah daneah added the bug Something isn't working label Sep 20, 2024
Copy link
Collaborator

@daneah daneah left a comment

Choose a reason for hiding this comment

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

On my reading of the issues and understanding of this change, it should be the case that this:

Fixes #65
Fixes #67
Fixes #70
Fixes #81

Copy link
Collaborator

@daneah daneah left a comment

Choose a reason for hiding this comment

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

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?

@antonio-antuan
Copy link
Author

I'm not familiar with pipx. But however are there only two options of "sys.executable": python itself (and its variants) and "mycli-package"?

@daneah
Copy link
Collaborator

daneah commented Sep 20, 2024

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 options.entry_points.console_scripts). That executable file, generated by pip machinery, is something like this:

#!/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())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants