Skip to content

Poetry changes sys.argv[0]? #480

Closed
Closed

Description

@kasper9n
  • 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?

Activity

  1. changed the title [-]sys.argv[0] is changed in scripts?[/-] [+]Poetry changes sys.argv[0]?[/+] on Oct 7, 2018
  2. fridex commented on Oct 7, 2018

    @fridex
    import os
    import sys
    
    os.path.basename(sys.argv[0])
  3. kasper9n commented on Oct 7, 2018

    @kasper9n
    ContributorAuthor

    @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.

  4. fridex commented on Oct 7, 2018

    @fridex

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

  5. kasper9n commented on Oct 7, 2018

    @kasper9n
    ContributorAuthor

    @fridex Correct :)

  6. stale commented on Nov 13, 2019

    @stale

    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.

  7. chdsbd commented on Nov 13, 2019

    @chdsbd
    Contributor

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

  8. finswimmer commented on Jul 1, 2022

    @finswimmer
    Member

    Duplicate of #965

  9. github-actions commented on Mar 1, 2024

    @github-actions

    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.

  10. locked as resolved and limited conversation to collaborators on Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cliRelated to the command line

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions