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

Disable use of pip install --python on Gentoo debundled pip #861

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mgorny
Copy link

@mgorny mgorny commented Feb 15, 2025

In the debundled pip version distributed on Gentoo systems, pip install --python is nonfunctional since it expects all of pip's dependencies to be present in the (empty) virtual environment. Detect this case by the removal of pip._vendor package, and use the "no valid outer pip" codepath.

Bug: https://bugs.gentoo.org/934922

@mgorny
Copy link
Author

mgorny commented Feb 15, 2025

Looks like distutils import hack from setuptools is causing trouble here. Any suggestion how to deal with that?

@henryiii
Copy link
Contributor

I don't think this will fix it, but I'd not do import if you aren't going to use it later; use importlib.util.find_spec("pip._vendor") instead, it's much faster. To me, isn't it a bit broken if pip install --python can't be used? You can target a completely empty environment with pip install --python normally.

@mgorny
Copy link
Author

mgorny commented Feb 18, 2025

Yes, it is. Unfortunately, I don't see how to fix it — in the end, the --python is a huge hack, and we find unbundling dependencies more important than, well, an option that we didn't even knew existed before build started using it.

@mgorny
Copy link
Author

mgorny commented Feb 18, 2025

I think the remaining failures are flaky tests.

src/build/env.py Outdated Show resolved Hide resolved
@henryiii
Copy link
Contributor

What's the warning, out of curiosity?

@mgorny
Copy link
Author

mgorny commented Feb 18, 2025

What's the warning, out of curiosity?

Basically this:

>>> import distutils
>>> import pip
/usr/lib/python3.10/site-packages/_distutils_hack/__init__.py:30: UserWarning: Setuptools is replacing distutils. Support for replacing an already imported distutils is deprecated. In the future, this condition will fail. Register concerns at https://github.com/pypa/setuptools/issues/new?template=distutils-deprecation.yml
  warnings.warn(

@henryiii
Copy link
Contributor

henryiii commented Feb 18, 2025

the --python is a huge hack

Pip is full of hacks - the build-isolation support is a mess, for example. IMO using --python instead of installing pip into every single environment is much more reasonable, and the main reason people don't use it is because it's a newer feature and it's not the way we used to work. uv always works this way, and it makes more sense.

Regardless, though, this seems fine.

I'll try to fix the univeral= warning soon.

mgorny and others added 5 commits February 18, 2025 11:23
In the debundled pip version distributed on Gentoo systems, `pip install
--python` is nonfunctional since it expects all of pip's dependencies
to be present in the (empty) virtual environment.  Detect this case
by the removal of `pip._vendor` package, and use the "no valid outer
pip" codepath.

Bug: https://bugs.gentoo.org/934922
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

Successfully merging this pull request may close these issues.

2 participants