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

ensurepip fails if cwd contains illformed setup.cf #86216

Closed
htgoebel mannequin opened this issue Oct 16, 2020 · 7 comments
Closed

ensurepip fails if cwd contains illformed setup.cf #86216

htgoebel mannequin opened this issue Oct 16, 2020 · 7 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes pending The issue will be closed if no feedback is provided stdlib Python modules in the Lib dir type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@htgoebel
Copy link
Mannequin

htgoebel mannequin commented Oct 16, 2020

BPO 42050
Nosy @ncoghlan, @dstufft, @pradyunsg, @con-f-use, @FFY00
Files
  • shell-session.txt
  • 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 = None
    created_at = <Date 2020-10-16.08:27:23.104>
    labels = ['3.8', '3.7', 'library', 'type-crash']
    title = 'ensurepip fails if cwd contains illformed setup.cf'
    updated_at = <Date 2021-01-30.11:31:05.012>
    user = 'https://bugs.python.org/htgoebel'

    bugs.python.org fields:

    activity = <Date 2021-01-30.11:31:05.012>
    actor = 'con-f-use'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2020-10-16.08:27:23.104>
    creator = 'htgoebel'
    dependencies = []
    files = ['49779']
    hgrepos = []
    issue_num = 42050
    keywords = []
    message_count = 2.0
    messages = ['378706', '385980']
    nosy_count = 6.0
    nosy_names = ['htgoebel', 'ncoghlan', 'dstufft', 'pradyunsg', 'con-f-use', 'FFY00']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue42050'
    versions = ['Python 3.7', 'Python 3.8']

    @htgoebel
    Copy link
    Mannequin Author

    htgoebel mannequin commented Oct 16, 2020

    If the current directory contains a ill-formed setup.cfg, setting up a virtual env fails, caused by ensurepip failing:

    Expected behaviour:
    running ensurepip should completely ignore the content of the current working directory.

    How to reproduce:

    $ rm -rf /tmp/v2
    $ mkdir /tmp/v2
    $ cd /tmp/v2
    $ cat > setup.cfg <<EOF
    > [options]
    > setuptools_requires
    > EOF
    $ python3 -m venv /tmp/v2/_venv
    Error: Command '['/tmp/v2/_venv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 2.
    $ /tmp/v2/_venv/bin/python3 -Im ensurepip --upgrade --default-pip
    Looking in links: /tmp/tmpimoh6tke
    Collecting setuptools
    Collecting pip
    Installing collected packages: setuptools, pip
    Exception:
    
    configparser.ParsingError: Source contains parsing errors: 'setup.cfg'
            [line  2]: 'setuptools_requires\n'

    Environment:
    Tested with both Python 3.8.2 and 3.7.6

    @htgoebel htgoebel mannequin added 3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-crash A hard crash of the interpreter, possibly with a core dump labels Oct 16, 2020
    @con-f-use
    Copy link
    Mannequin

    con-f-use mannequin commented Jan 30, 2021

    Just wanted to say, I ran into this while using direnv. See the issue I opened before knowing of this one: https://bugs.python.org/issue43038

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @iritkatriel
    Copy link
    Member

    I'm unable to reproduce this on 3.12. Since (according to https://bugs.python.org/issue43038) it is related to distutils, it may no longer be relevant.

    @iritkatriel iritkatriel added the pending The issue will be closed if no feedback is provided label Nov 23, 2022
    @pradyunsg pradyunsg added the 3.9 only security fixes label Nov 23, 2022
    @pradyunsg
    Copy link
    Member

    This is related to pip's usage of distutils as the source of truth for figuring out where to install things (i.e. "locations"). Starting Python 3.10, pip now uses sysconfig for that, which means that it won't try using the code path that invoked distutils to trigger this crash.

    The relevant portion of pip's codebase is https://github.com/pypa/pip/tree/22.3.1/src/pip/_internal/locations (__init__.py has the logic for picking between sysconfig vs distutils).

    @iritkatriel
    Copy link
    Member

    So this issue is out date?

    @pradyunsg
    Copy link
    Member

    pradyunsg commented Nov 23, 2022

    Given that 3.7, 3.8 and 3.9 are in a security-fix status, I don't think we're gonna be fixing/changing the behaviour of distutils for this case. 3.10+ aren't affected unless CPython is patched by a downstream redistributor.

    This would've been the first time I'm gonna click close on an issue on CPython with my "new" triage permissions. But, I'm gonna be cautious and avoid doing things wrong -- and defer to a core dev or another triager to close this. :)

    @iritkatriel
    Copy link
    Member

    Closing on @pradyunsg's recommendation :)

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes pending The issue will be closed if no feedback is provided stdlib Python modules in the Lib dir type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants