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
Workaround: emerge dev-python/pip with 'vanilla' use flag.
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.
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.)
Related bug: Bug #700376
*** Bug 700376 has been marked as a duplicate of this bug. ***
*** Bug 726316 has been marked as a duplicate of this bug. ***
I'm sorry that this took so long. I have a new patch ready now, and will test it ASAP.
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(-)