Bug#876145: python-pip: pip install --system as non-root shouldn't default --ignore-installed

2017-09-18 Thread Peter Amstutz
Source: python-pip
Version: 9.0.1-2
Severity: normal

Dear Maintainer,

When running "pip install --system" as a non-root user, the change in
set_user_default.patch forces the --ignore-installed flag to be enabled.

This has the effect of breaking pip for use cases that install packages as non-
root but don't use --user or virtualenv.  When dependencies are shared among
multiple packages, the --ignore-installed option causes pip to blindly install
the latest version of each dependency requested by each package, even if a
compatible package version is already installed, and even if this breaks the
requirement spec of some other package.  This results in package version
conflicts.

For example:

pip install pkg_A (requires pkg_B==1.0)
pip install pkg_C (requires pkg_B>=1.0)

Because of --ignore-installed, pkg_C ignores the existing pkg_B (which it is
otherwise compatible with) and installs the latest pkg_B==2.0, as a result this
breaks pkg_A.

Here's the relevant logic in pip/commands/install.py:

default_user = True
if running_under_virtualenv():
default_user = False
if os.geteuid() == 0:
default_user = False

cmd_opts.add_option(
'-I', '--ignore-installed',
dest='ignore_installed',
action='store_true',
default=default_user,
help='Ignore the installed packages (reinstalling instead).')

My preferred fix would be that when the --system flag is set, it should retain
the default behavior of pip, and not interfere with the unrelated --ignore-
installed flag.

Thanks,
Peter



-- System Information:
Debian Release: 9.1
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.9.0-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)



Bug#876145: python-pip: pip install --system as non-root shouldn't default --ignore-installed

2018-01-03 Thread Kjell Braden
On Mon, 18 Sep 2017 21:21:31 -0400 Peter Amstutz
 wrote:
> When running "pip install --system" as a non-root user, the change in
> set_user_default.patch forces the --ignore-installed flag to be enabled.
> 
> This has the effect of breaking pip for use cases that install packages as 
> non-
> root but don't use --user or virtualenv.

This also means that if I install a package with --user it will have any
dependencies installed in the user's home, even if they already exist in
the system directories (i.e. installed through apt) and satisfy all
requirements - with no possible workaround, other than reverting this patch.

Also note that the virtualenv detection fails on python3 venv, breaking
the --system-site-packages option.

Even more reason (see #830892) to drop the patch in question.



Bug#876145: python-pip: pip install --system as non-root shouldn't default --ignore-installed

2018-01-03 Thread Kjell Braden
On Wed, 3 Jan 2018 17:02:14 +0100 Kjell Braden  wrote:>
Also note that the virtualenv detection fails on python3 venv, breaking
> the --system-site-packages option.

Disregard that, this can be worked around by invoking "python3 -m pip"
instead of "pip3", and is a different issue.