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

Poetry changes sys.argv[0]? #480

Closed
2 tasks done
probablykasper opened this issue Oct 7, 2018 · 8 comments
Closed
2 tasks done

Poetry changes sys.argv[0]? #480

probablykasper opened this issue Oct 7, 2018 · 8 comments
Labels
area/cli Related to the command line

Comments

@probablykasper
Copy link
Contributor

  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Question

Hi. For the help menus in my CLI scripts, I like to print usage instructions like this:

print("Usage:")
print("    "+sys.argv[0]+" <command> [options]")

But Poetry seems to change sys.argv[0] to the full path of the script, instead of keeping what the user actually typed in. Why? Is there any way around this?

@probablykasper probablykasper changed the title sys.argv[0] is changed in scripts? Poetry changes sys.argv[0]? Oct 7, 2018
@fridex
Copy link

fridex commented Oct 7, 2018

import os
import sys

os.path.basename(sys.argv[0])

@probablykasper
Copy link
Contributor Author

@fridex That doesn't really fix the problem. If the user did type in the full path with that code, he would only get the basename.

@fridex
Copy link

fridex commented Oct 7, 2018

Ah, OK. You want to replicate the whole invocation. That makes sense 👍

@probablykasper
Copy link
Contributor Author

@fridex Correct :)

@stale
Copy link

stale bot commented Nov 13, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 13, 2019
@chdsbd
Copy link
Contributor

chdsbd commented Nov 13, 2019

This is still an issue. I think it relates to #965.

@stale stale bot removed the stale label Nov 13, 2019
@finswimmer finswimmer added the area/cli Related to the command line label Feb 7, 2020
@finswimmer
Copy link
Member

Duplicate of #965

@finswimmer finswimmer marked this as a duplicate of #965 Jul 1, 2022
Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/cli Related to the command line
Projects
None yet
Development

No branches or pull requests

4 participants