A recent exchange on distutils-sig got me thinking about how we can improve UX when the user supplies a wrong value as
--[extra-]index-url. I also remember an incident where a user got very confused why pip can’t find a package version because they incorrectly supplied
--index-url (instead of the correct
So the problem here is that find-links and index pages are defined very loosely (basically any HTML page works), and a tool has no choice but to consume anything HTML the user passes in, leading to confusing behaviour or cryptic errors. This probably can never be fully amended as long as we stick to the Simple API (backwards compatibility), but I wonder maybe it’d be possible to at least introduce a way to mark an HTML page as not a listing page, adding it to pages commonly supplied by mistake (e.g.
pypi.org/project/<name>/), so pip can error out as soon as possible with a clear error message.
My idea right now:
- Specify a custom attribute to mark an HTML page as non-listing (something like
- Add that attribute to pages commonly supplied by mistake.
- (Optional) Amend PEP 503 to require the index root page to contain that attribute?
- Implement pip so it stops reading/processing the page as soon as it encounters that attribute.
- Error out (or emit a message like it does when
Content-Typeis not HTML) when 4. happens.
I can draft a PEP if that’s needed.