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

[venv] Add a CLI flag to venv to use the pwd basename as the prompt #83082

Closed
brettcannon opened this issue Nov 23, 2019 · 9 comments
Closed
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@brettcannon
Copy link
Member

BPO 38901
Nosy @brettcannon, @vsajip, @JulienPalard, @DahlitzFlorian, @tirkarthi
PRs
  • bpo-38901: Allow setting a venv's prompt to the basename of the current directory. #17946
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-01-14.23:57:53.719>
    created_at = <Date 2019-11-23.22:28:34.409>
    labels = ['type-feature', 'library']
    title = '[venv] Add a CLI flag to venv to use the pwd basename as the prompt'
    updated_at = <Date 2020-01-14.23:57:53.718>
    user = 'https://github.com/brettcannon'

    bugs.python.org fields:

    activity = <Date 2020-01-14.23:57:53.718>
    actor = 'vinay.sajip'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-01-14.23:57:53.719>
    closer = 'vinay.sajip'
    components = ['Library (Lib)']
    creation = <Date 2019-11-23.22:28:34.409>
    creator = 'brett.cannon'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38901
    keywords = ['patch']
    message_count = 9.0
    messages = ['357385', '357418', '357420', '357452', '357493', '358039', '359462', '359993', '360003']
    nosy_count = 5.0
    nosy_names = ['brett.cannon', 'vinay.sajip', 'mdk', 'DahlitzFlorian', 'xtreak']
    pr_nums = ['17946']
    priority = 'low'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue38901'
    versions = []

    @brettcannon
    Copy link
    Member Author

    I did a Twitter poll to see if there was consistent naming of the directory people created a virtual environment into when done locally to code (the answer is no). But a common theme was people not liking that the prompt defaults to the name of the directory that the virtual environment is in and seem to prefer for it to be os.path.basename(os.getcwd()).

    Maybe it makes sense to add a --basename-prompt flag to set the prompt to the current working directory's basename?

    @brettcannon brettcannon added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Nov 23, 2019
    @vsajip
    Copy link
    Member

    vsajip commented Nov 24, 2019

    Maybe it makes sense to add a --basename-prompt flag to set the prompt to the current working directory's basename?

    What does this buy you beyond using

    --prompt $(basename $PWD)

    ? Perhaps I'm not understanding what you're getting at - how about an example of what you mean?

    @JulienPalard
    Copy link
    Member

    I like the idea and I think I will use it!

    As it's a bit long to type, I'm searching if other shorter variants could be usefull like:

    python3 -m venv --here
    python3 -m venv --cwd
    python3 -m venv --project
    

    being the equivalent of python3 -m venv --basename-prompt venv, but I'm not satisfied with the names (and it enforces using "venv" as a directory name)...

    @brettcannon
    Copy link
    Member Author

    @vinay you got exactly what I mean. I had to actually teach a ton of people that shell trick with basename and pwd on Twitter, that trick doesn't seem to be something people know about, and yet a ton of people seem to be creating virtual environments with prompts manually specified like that.

    Plus that trick varies from shell to shell and we already have enough issues just explaining to people how to activate between Windows and UNIX and then between even shells on the same OS.

    So this is entirely for convenience.

    @julien default directory names is an entirely separate topic as people can't agree on the default name (e.g. I prefer .venv as my default).

    @vsajip
    Copy link
    Member

    vsajip commented Nov 26, 2019

    Since there is already a --prompt available, I'd prefer a solution that allowed some special value(s) to be passed for this, e.g.

    --prompt .

    or perhaps

    --prompt __curdir__

    @brettcannon
    Copy link
    Member Author

    If it were . would we then always check if the prompt was a folder and then use the folder's name in that case? Or would it only apply to .?

    As for __curdir__, it could work, but I don't know how easy would that be to remember or explain to new users compared to .?

    My vote is to support . and make the rule that if you specify a folder it will use the basename automatically.

    @brettcannon brettcannon changed the title Add a CLI flag to venv to use the pwd basename as the prompt [venv] Add a CLI flag to venv to use the pwd basename as the prompt Jan 6, 2020
    @brettcannon
    Copy link
    Member Author

    Any more feedback from anyone on the idea of using the basename of a directory if specified for --prompt?

    @vsajip
    Copy link
    Member

    vsajip commented Jan 14, 2020

    New changeset 7d63780 by Vinay Sajip in branch 'master':
    bpo-38901: Allow setting a venv's prompt to the basename of the current directory. (GH-17946)
    7d63780

    @brettcannon
    Copy link
    Member Author

    Can this now be closed, Vinay?

    @vsajip vsajip closed this as completed Jan 14, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants