Skip to content

pipenv clean fails when pip freeze produces output with comments #2229

Closed
@nelfin

Description

do_clean assumes that the output of pip freeze produces only requirement lines, but it can in some cases produce #-prefixed comments (see https://github.com/pypa/pip/blob/729990c9869148f3f0098a2b2a0c0b92aefb8a69/src/pip/_internal/operations/freeze.py#L188 for one such example). It looks as though this was noticed and fixed for pipenv update in 9.1.0 (see f322d93)

$ python -m pipenv.help output

Pipenv version: '2018.05.18'

Pipenv location: '$HOME/.virtualenvs/pipenv-issue/local/lib/python2.7/site-packages/pipenv'

Python location: '$HOME/.virtualenvs/pipenv-issue/bin/python'

Other Python installations in PATH:

  • 2.7: $HOME/.virtualenvs/pipenv-issue/bin/python2.7

  • 2.7: $HOME/.virtualenvs/pipenv-issue/bin/python2.7

  • 2.7: /usr/bin/python2.7

  • 3.5: /usr/bin/python3.5m

  • 3.5: /usr/bin/python3.5

  • 2.7.12: $HOME/.virtualenvs/pipenv-issue/bin/python

  • 2.7.12: /usr/bin/python

  • 2.7.12: $HOME/.virtualenvs/pipenv-issue/bin/python2

  • 2.7.12: /usr/bin/python2

  • 3.5.2: /usr/bin/python3

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '0',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '4.4.0-124-generic',
 'platform_system': 'Linux',
 'platform_version': '#148-Ubuntu SMP Wed May 2 13:00:18 UTC 2018',
 'python_full_version': '2.7.12',
 'python_version': '2.7',
 'sys_platform': 'linux2'}

System environment variables:

  • MANDATORY_PATH
  • XDG_GREETER_DATA_DIR
  • GNOME_DESKTOP_SESSION_ID
  • UPSTART_EVENTS
  • PYTHONDONTWRITEBYTECODE
  • LESSOPEN
  • XDG_SESSION_TYPE
  • QT_IM_MODULE
  • LOGNAME
  • USER
  • PATH
  • XDG_VTNR
  • GNOME_KEYRING_CONTROL
  • PS1
  • DISPLAY
  • LANG
  • TERM
  • SHELL
  • XDG_SESSION_PATH
  • XAUTHORITY
  • LANGUAGE
  • COMPIZ_CONFIG_PROFILE
  • SHLVL
  • QT_LINUX_ACCESSIBILITY_ALWAYS_ON
  • QT_QPA_PLATFORMTHEME
  • QT_ACCESSIBILITY
  • UPSTART_INSTANCE
  • CLUTTER_IM_MODULE
  • WINDOWID
  • SESSIONTYPE
  • XMODIFIERS
  • GPG_AGENT_INFO
  • HOME
  • QT4_IM_MODULE
  • GTK2_MODULES
  • XDG_SESSION_DESKTOP
  • SSH_AUTH_SOCK
  • XDG_RUNTIME_DIR
  • INSTANCE
  • COMP_WORDBREAKS
  • VTE_VERSION
  • GDMSESSION
  • IM_CONFIG_PHASE
  • UPSTART_JOB
  • UPSTART_SESSION
  • GNOME_KEYRING_PID
  • XDG_SEAT_PATH
  • LESSCLOSE
  • PIP_PYTHON_PATH
  • XDG_CURRENT_DESKTOP
  • XDG_SESSION_ID
  • DBUS_SESSION_BUS_ADDRESS
  • _
  • DEFAULTS_PATH
  • GTK_IM_MODULE
  • DESKTOP_SESSION
  • VIRTUAL_ENV
  • XDG_CONFIG_DIRS
  • GTK_MODULES
  • GDM_LANG
  • XDG_DATA_DIRS
  • PWD
  • JOB
  • LS_COLORS
  • XDG_SEAT

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: $HOME/.virtualenvs/pipenv-issue/bin:$HOME/.local/bin:$HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:$HOME/.rvm/bin:$HOME/.rvm/bin
  • SHELL: /usr/bin/fish
  • LANG: en_AU.UTF-8
  • PWD: $HOME
  • VIRTUAL_ENV: $HOME/.virtualenvs/pipenv-issue


Expected result
$ pipenv clean
Uninstalling 'empty'…
Actual result

$ pipenv clean
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (dfae9f)!
Traceback (most recent call last):
  File "$HOME/.virtualenvs/pipenv-issue/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "$HOME/.virtualenvs/pipenv-issue/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "$HOME/.virtualenvs/pipenv-issue/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "$HOME/.virtualenvs/pipenv-issue/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "$HOME/.virtualenvs/pipenv-issue/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "$HOME/.virtualenvs/pipenv-issue/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "$HOME/.virtualenvs/pipenv-issue/lib/python2.7/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "$HOME/.virtualenvs/pipenv-issue/local/lib/python2.7/site-packages/pipenv/cli.py", line 1009, in clean
    ctx=ctx, three=three, python=python, dry_run=dry_run, verbose=verbose
  File "$HOME/.virtualenvs/pipenv-issue/local/lib/python2.7/site-packages/pipenv/core.py", line 2539, in do_clean
    r = get_requirement(installed)
  File "$HOME/.virtualenvs/pipenv-issue/local/lib/python2.7/site-packages/pipenv/utils.py", line 142, in get_requirement
    req = [r for r in requirements.parse(dep)][0]
IndexError: list index out of range
Steps to replicate
$ cd $(mktemp -d)
$ cat <<EOF >setup.py
> from setuptools import setup
> setup(name='empty')
> EOF
$ mkdir .git
$ pipenv run pip install -e .
$ pipenv clean

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions