This is something I’ve been thinking about for a while, but has also come up more recently with shifts in how people have been approaching “supply chain” security in an OSS context (with cooldowns, malware advisories, quarantines, etc.).
Questions
- What would it look like to deprecate PEP 503? Can it even be done?
- What would the consequences of doing so be?
- If we were to deprecate and then formally remove PEP 503 (on PyPI), what timeline could we possibly do that on?
(To be clear, these are extremely open questions given how central PEP 503 is at the moment. But I consider it a healthy practice to allow ourselves to periodically rethink/reevaluate foundational assumptions in Python packaging, even if the conclusion is “absolutely no”
)
Context / status quo
The Python packaging ecosystem has two parallel index representations: HTML via PEP 503, and JSON via PEP 691. These two representations are more or less maintained in tandem in packaging PEPs, but PEP 503 is the de facto baseline index standard because it formalizes the pre-existing (pre-standardization) index layout.
This has two downstream effects:
- Because the HTML representation predates standardization, a ton (the majority?) of third-party Python packaging indices only use it. In other words, they don’t offer a PEP 691 index at all, and only offer something vaguely resembling the bare minimum of a PEP 503 index.
- Packaging PEPs that modify the index in some way (like PEP 740, PEP 792, etc.) need to jump through hoops to make their changes fit into the right “shape” for compatibility with the HTML index, versus the more straightforward process of updating the JSON representation (by adding new keys, etc.). Some packaging PEPs (like PEP 700) bypass making changes to the HTML index entirely, under the assumption that consumers of the HTML index don’t need certain information facets. This is done without formally deprecating the HTML index, but effectively bifurcates the two in functionality.
Consequences
The above has negative downstream consequences for the ecosystem:
- Installers (like pip and uv) are increasingly moving to enable dependency cooldowns, which require the index to provide
upload-timemetadata. This works cromulently with PEP 700’s amendments to the JSON index, but no similar feature exists for the HTML index.- In principle, the HTML index could also be modified to shoehorn
upload-timeinto the representation. However, doing so is unlikely to result in much of a net-positive change for downstreams that use third-party indices, since corporate index hosts haven’t moved much (at all) beyond the PEP 503 baseline. So this might be good to do from a consistency perspective, but won’t necessarily be a huge boon to many teams looking to adopt cooldowns.
- In principle, the HTML index could also be modified to shoehorn
- Similarly, PyPI uses PEP 792 project statuses to signal things like archival and quarantine (e.g. for malware), but clients that consume PyPI indirectly (e.g. through corporate mirrors) lack visibility into those statuses when their hosted index service strips everything away into just a bare PEP 503 form.
Long term, I think this status quo represents a modernization risk to the ecosystem, similar to one that Python has been through before (with 2->3, wheels, etc.): indices that only support the bare minimum required by PEP 503 effectively function as a source of drag on installers and other clients (e.g. uploading clients like twine), and make it harder to make important ecosystem-wide security and usability enhancements to Python packaging.
Solutions?
The extreme solution is to deprecate PEP 503. Once deprecated (and this would take a long time, almost certainly), a series of interlocking constraints could be untangled:
- PyPI could stop serving PEP 503 index responses, or only serve them with an explicit
Accept: application/vnd.pypi.simple.v1+htmlrequest rather than by default. This will force mirrors to make a conscious decision to remain on the HTML index. - uv and pip could (again, slowly) deprecate their PEP 503 support, first by warning when an index fails to offer a PEP 691 response and eventually removing support entirely (with an appropriate error).
Combined, these would ideally produce the appropriate incentive structure with third-party services to modernize their index representations: the former allows PyPI to gracefully nudge them during a “yellow” deprecation period, followed by a “red” period in which they’ll need to explicitly opt into mirroring the HTML index, following by similar periods for installers wherein everything will continue to function until the final day of installer-side removal.
That’s the “extreme” solution; less extreme options are possible, but accomplish fewer goals around reducing ecosystem drag. Some less extreme options:
- Never deprecate the HTML index, but instead make the
Accept: application/vnd.pypi.simple.v1+htmlheader mandatory (again, after a deprecation period) and default to the JSON index index on PyPI. This will allow everything to keep chugging along, but would (hopefully) nudge mirrors into making the migration. - Never deprecate PEP 503, but instead encourage installers (pip and uv) to emit more warnings when encountering an HTML index that’s entirely unversioned (missing a
pypi:repository-versiontag). This would also serve as a nudge, but a software one (and IMO therefore not an especially effective one). - Never deprecate PEP 503, and instead look at “backporting” PEP 700 to the HTML index (to help with use-cases like cooldowns). I think this is potentially worth doing independently anyways, but the outcomes will still primarily be limited to PyPI versus third-party indices.
There are of course many other options, and I’m positive I’m not thinking of the overwhelming majority of them
. I’d really appreciate hearing others’ thoughts on both the above and alternatives!
Disclosures
I’m writing this out of personal interest (my track record with writing index PEPs will hopefully evidence this!), but in this interest of transparency I’m disclosing that I work for Astral on both a client (uv) and an index implementation (pyx). My experience on both of those has colored my opinions about the value of this idea, but the idea itself predates any interest my employer may have in the topic.