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

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

Closed
1 task done
nelfin opened this issue May 21, 2018 · 3 comments
Closed
1 task done

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

nelfin opened this issue May 21, 2018 · 3 comments

Comments

@nelfin
Copy link
Contributor

nelfin commented May 21, 2018

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
nelfin added a commit to nelfin/pipenv that referenced this issue May 21, 2018
requirements.txt files (and by extension pipfreeze) can contain comment
lines, but the stdout of pip freeze is used in a number of places with
the assumption that every line contains a dependency declaration. This
change adds an integration test that could trigger one of these cases
that was the cause of the behaviour seen in issue pypa#2229.
nelfin added a commit to nelfin/pipenv that referenced this issue May 21, 2018
Ref pypa#2229. This change only fixes the issue seen when calling `pipenv
clean`. A future refactor should consolidate these behaviours (or use
the actual parsing of lines from pip, i.e. FrozenRequirement, if we can
rely on this API).
@nelfin
Copy link
Contributor Author

nelfin commented May 22, 2018

By the way, this also affects pipenv update:

$ cd $(mktemp -d)
$ cat <<EOF >setup.py
> from setuptools import setup
> setup(name='empty')
> EOF
$ mkdir .git
$ pipenv run pip install -e .
$ pipenv update --outdated --dry-run
Traceback (most recent call last):
  ...
  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

@uranusjr
Copy link
Member

Of course it does. It also fails with sync, if you haven’t noticed :) This is a failure when Pipenv prepares arguments to pass to pip, so any commands that installs and uninstalls things will be affected. (pipenv install <package> is an exception since the requirements are no longer empty after the specified package is added.)

uranusjr pushed a commit that referenced this issue May 25, 2018
requirements.txt files (and by extension pipfreeze) can contain comment
lines, but the stdout of pip freeze is used in a number of places with
the assumption that every line contains a dependency declaration. This
change adds an integration test that could trigger one of these cases
that was the cause of the behaviour seen in issue #2229.
uranusjr pushed a commit that referenced this issue May 25, 2018
Ref #2229. This change only fixes the issue seen when calling `pipenv
clean`. A future refactor should consolidate these behaviours (or use
the actual parsing of lines from pip, i.e. FrozenRequirement, if we can
rely on this API).
uranusjr pushed a commit that referenced this issue May 31, 2018
requirements.txt files (and by extension pipfreeze) can contain comment
lines, but the stdout of pip freeze is used in a number of places with
the assumption that every line contains a dependency declaration. This
change adds an integration test that could trigger one of these cases
that was the cause of the behaviour seen in issue #2229.
uranusjr pushed a commit that referenced this issue May 31, 2018
Ref #2229. This change only fixes the issue seen when calling `pipenv
clean`. A future refactor should consolidate these behaviours (or use
the actual parsing of lines from pip, i.e. FrozenRequirement, if we can
rely on this API).
@uranusjr
Copy link
Member

uranusjr commented Jun 6, 2018

This one is fixed.

@uranusjr uranusjr closed this as completed Jun 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants