pip: [pip 25.1] `assert req.source_dir` fails with the legacy resolver enabled

Description

Seeing build failures because of this function, my guess is this function was supposed to check whether the stuff needs to be built, but the commit https://github.com/pypa/pip/commit/5b20593ef6c3719d5f33785476ed9fff36890006 is causing assertion failures, we will need to pin pip till this is resolved.

Expected behavior

The assertion should not be there, a check was fine.

pip version

25.1

Python version

3.9

OS

Al2023

How to Reproduce

Try installing certifi,

I will add more details soon.

Output

File "/usr/local/lib/python3.9/site-packages/pip/_internal
/wheel_builder.py", line 53, in _should_build
2025-04-27 12:03:18,230:INFO:__main__:deploy_model: 24.64
assert req.source_dir

Code of Conduct

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 24 (17 by maintainers)

Commits related to this issue

Most upvoted comments

@ramannanda9 Unfortunately, that’s not a good reason for pip to retain the legacy resolver. Being able to install a set of requirements that are incompatible was a bug in the legacy resolver, and supporting people who rely on that bug has never been a goal.

If projects want to continue using that capability, then at some point they will have to pin their version of pip.

I’m -1 on adding warnings to the log output, but I could see some value to adding a warning message to the normal output.

By log output, I mean the normal output (I didn’t realise pip even wrote logs to a file for successful builds?).

The answer of why it fails with the legacy resolver is that we don’t really support the legacy resolver anymore. We have some tests, but we haven’t added any legacy resolver tests since well… it was NOT legacy. We’ve kept it around because its removal would’ve been quite disruptive. I’m not sure how disruptive it would be today, but in general, it hasn’t been a burden either so it’s been left alone.

@Rahlir thanks! I tried this but it does not reproduce:

#!/bin/bash
set -eaux
venv=$(mktemp -d)
python3.9 -m venv $venv
$venv/bin/pip install --upgrade pip
$venv/bin/pip install aiohttp[speedups]==3.11.16

Can you provide additional information? Maybe pip config debug.

Edit: same with python 3.11.12, and 3.11.9.

One particular thing that could shed light on this issue - are the people experiencing this bug just using pip as a command line tool, or are they using code that imports pip in some way? Because we changed the test to an assert because pip should never be passing a requirement without a source_dir to _should_build. If it is, we need a reproducer to find out where that is occurring (and fix that, rather than just remove the check and accept that we don’t know what pip is doing internally 🙁).

If the issue is triggered by importing pip and using internals somehow, then such usage is not supported, as people will be aware. We may still be able to help, but not without understanding what people are trying to do (and of course, as it’s unsupported usage, there are no guarantees).

Either way, we can do nothing without a description of how to trigger the issue.