Navigation Menu

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

shebanged scripts can escape from venv depending on how it was created #83837

Closed
asottile mannequin opened this issue Feb 16, 2020 · 2 comments
Closed

shebanged scripts can escape from venv depending on how it was created #83837

asottile mannequin opened this issue Feb 16, 2020 · 2 comments
Labels
3.9 only security fixes stdlib Python modules in the Lib dir

Comments

@asottile
Copy link
Mannequin

asottile mannequin commented Feb 16, 2020

BPO 39656
Nosy @vsajip, @asottile
PRs
  • bpo-39656: Ensure bin/python3.# is always present in virtual environments #19030
  • 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-03-19.11:20:59.876>
    created_at = <Date 2020-02-16.19:21:51.580>
    labels = ['library', '3.9']
    title = 'shebanged scripts can escape from `venv` depending on how it was created'
    updated_at = <Date 2020-03-19.11:20:59.875>
    user = 'https://github.com/asottile'

    bugs.python.org fields:

    activity = <Date 2020-03-19.11:20:59.875>
    actor = 'vinay.sajip'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-03-19.11:20:59.876>
    closer = 'vinay.sajip'
    components = ['Library (Lib)']
    creation = <Date 2020-02-16.19:21:51.580>
    creator = 'Anthony Sottile'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39656
    keywords = ['patch']
    message_count = 2.0
    messages = ['362095', '364389']
    nosy_count = 2.0
    nosy_names = ['vinay.sajip', 'Anthony Sottile']
    pr_nums = ['19030']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue39656'
    versions = ['Python 3.9']

    @asottile
    Copy link
    Mannequin Author

    asottile mannequin commented Feb 16, 2020

    This is distilled from a larger example to be small/silly, however this caused real problems

    A script which was intended for python3.6 exactly was written as follows:

    #!/usr/bin/env python3.6
    ...
    

    when creating a virtualenv with python3.6 -m venv venv36 you end up with python / python3 / python3.6 executables in the venv

    however, when creating a virtualenv with python3 -m venv venv36 you only end up with python / python3 executables


    using -mvirtualenv (pypa/virtualenv) instead of venv, all three are reliably created


    the fix is fairly straightforward, adding f'python3.{sys.version_info[0]}' to this tuple:

    for suffix in ('python', 'python3'):

    @asottile asottile mannequin added 3.9 only security fixes stdlib Python modules in the Lib dir labels Feb 16, 2020
    @vsajip
    Copy link
    Member

    vsajip commented Mar 17, 2020

    New changeset 58ec58a by Anthony Sottile in branch 'master':
    bpo-39656: Ensure bin/python3.# is always present in virtual environments on POSIX (GH-19030)
    58ec58a

    @vsajip vsajip closed this as completed Mar 19, 2020
    @vsajip vsajip closed this as completed Mar 19, 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
    3.9 only security fixes stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant