Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 692960 - dev-python/pip: Gentoo patch should not reject --prefix installs
Summary: dev-python/pip: Gentoo patch should not reject --prefix installs
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
: 700376 726316 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-08-27 16:02 UTC by WGH
Modified: 2020-07-29 08:03 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description WGH 2019-08-27 16:02:53 UTC
A simple reproduction would be a directory with a single file 'pyproject.toml' containing the following:

    [build-system]
    requires = ["setuptools"]

Running 'pip3 install .' (or pip2) on it will result in the following error:

Processing /tmp/test
  Installing build dependencies ... error
  ERROR: Complete output from command /usr/bin/python3.6 /usr/lib64/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-iy1aswz6/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools:
  ERROR: ERROR: (Gentoo) Please run pip with the --user option to avoid breaking python-exec
  ----------------------------------------
ERROR: Command "/usr/bin/python3.6 /usr/lib64/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-iy1aswz6/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools" failed with error code 1 in None

It's caused by the following Gentoo-specific patch:
        if not options.use_user_site and not options.target_dir and not options.root_path:
            raise CommandError("(Gentoo) Please run pip with the --user option to avoid breaking python-exec")

These conditions include --user, --root and --target, but not --prefix.

I'm not sure whether the upstream should use --root/--target for installing build dependencies, or Gentoo should add 'options.prefix_path' to the condition.

The offending function is https://github.com/pypa/pip/blob/3b2d1384001c16c4946ec133dc3da0973543a9fc/src/pip/_internal/build_env.py#L159-L201
Comment 1 WGH 2019-08-27 16:06:14 UTC
Workaround: emerge dev-python/pip with 'vanilla' use flag.
Comment 2 Cecil Curry 2019-10-16 03:47:53 UTC
I can confirm this breaking issue for both "dev-python/pip" 19.1 (stable) and 19.2.2 (unstable), having just drunkenly stumbled into this brickwall myself. In its current state, "dev-python/pip" >= 19.1 is functionally broken for PEP 51{7,8}-compliant projects.

> I'm not sure whether the upstream should use --root/--target for installing build dependencies...

Convincing upstream to do anything not already delineated in a PEP is an exercise in futility. That is to say, let's not do this.

> ...or Gentoo should add 'options.prefix_path' to the condition.

That seems useful. That said, would even that suffice? Why are the "--ignore-installed" and "--no-user" options being implicitly passed to "pip" when the end user did not explicitly pass those options on the command line? Why reinstall dependencies into a temporary prefix rather than leverage system dependencies already installed by Portage? Moreover, why prohibit user-relative installations?

What's going on here? After inspecting "dev-python/pip/pip-19.2.2.ebuild", most of that doesn't appear to be our fault (aside from "files/pip-19.1-disable-system-install.patch" failing to test "options.prefix_path", as WGH noted). "pip" itself is intentionally passing these options when installing build dependencies. That is beyond frustrating. "Explicit is better than implicit" should be the maxim of every Python project – "pip" included.

In any case, we need new "dev-python/pip/pip-19.1-r1.ebuild" and "dev-python/pip/pip-19.2.2-r1.ebuild" revisions that either:

* Patch "files/pip-19.1-disable-system-install.patch" to test "options.prefix_path". (Untested, of course.)
* Enable the "vanilla" USE flag by default.
Comment 3 Cecil Curry 2019-10-16 03:56:42 UTC
Also, note that because "pip" does implicitly pass "--no-user" to itself when installing build dependencies, the current Gentoo-specific error message patched in by "files/pip-19.1-disable-system-install.patch" is unhelpful in the extreme:

    ERROR: ERROR: (Gentoo) Please run pip with the --user option to avoid breaking python-exec

That doesn't work. "pip" silently ignores any "--user" option passed by the end user when installing build dependencies – for inscrutable and probably nonsensical reasons known only to "pip" developers. (This is why we can't have good things.)
Comment 4 Beetle B. 2020-04-18 05:49:19 UTC
Related bug:

Bug #700376
Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2020-07-29 05:52:24 UTC
*** Bug 700376 has been marked as a duplicate of this bug. ***
Comment 6 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2020-07-29 05:52:29 UTC
*** Bug 726316 has been marked as a duplicate of this bug. ***
Comment 7 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2020-07-29 05:55:36 UTC
I'm sorry that this took so long.  I have a new patch ready now, and will test it ASAP.
Comment 8 Larry the Git Cow gentoo-dev 2020-07-29 08:03:04 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3db16f64fdfa6fde20bc062e43b7c0b3388c0afa

commit 3db16f64fdfa6fde20bc062e43b7c0b3388c0afa
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: 2020-07-29 07:54:25 +0000
Commit:     Michał Górny <mgorny@gentoo.org>
CommitDate: 2020-07-29 08:02:57 +0000

    dev-python/pip: Unblock --prefix installs
    
    Closes: https://bugs.gentoo.org/692960
    Signed-off-by: Michał Górny <mgorny@gentoo.org>

 .../pip/files/pip-20.0.2-disable-system-install.patch    | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)