Skip to content

feat: emit PEP 691 JSON simple repository pages - #140

Draft
aiolibsbot wants to merge 3 commits into
bdraco:mainfrom
aiolibsbot:koan/pep-691-json-api
Draft

feat: emit PEP 691 JSON simple repository pages#140
aiolibsbot wants to merge 3 commits into
bdraco:mainfrom
aiolibsbot:koan/pep-691-json-api

Conversation

@aiolibsbot

@aiolibsbot aiolibsbot commented May 17, 2026

Copy link
Copy Markdown

What

Write index.v1_json alongside each index.html so the generated tree also
serves the PEP 691 JSON Simple Repository API
(application/vnd.pypi.simple.v1+json).

Why

Pip 22.0+ negotiates for JSON via the Accept header — it's smaller, faster
to parse, and now the de-facto API for modern installers. The HTML pages
remain the source of truth for older clients.

How

  • New json_generator.py builds the root index and per-project payloads using
    the same canonicalisation/natsort ordering as the HTML generator. Optional
    fields (requires-python, core-metadata, size) are emitted only when
    set, and core-metadata: true is preserved.
  • IndexMaker.generate_index_pages writes both files atomically via the
    existing write_utf8_file helper.
  • README documents the nginx Accept-header rewrite needed for static hosting.

Testing

  • New unit tests in tests/test_json_generator.py cover canonicalisation,
    optional-field omission, and the core-metadata: true passthrough.
  • New end-to-end assertion in tests/test_index.py verifies the JSON files
    exist with correct mode and content for both root and project pages.
  • Full suite: 20 passed.

🤖 Generated with Claude Code


Quality Report

Changes: 5 files changed, 212 insertions(+), 6 deletions(-)

Code scan: clean

Tests: failed (command not found)

Branch hygiene: 1 issue(s)

  • Branch is not pushed to remote

Generated by Kōan post-mission quality pipeline

aiolibsbot and others added 3 commits May 17, 2026 17:51
Adds index.v1_json alongside each index.html so pip 22.0+ clients can
consume the JSON Simple Repository API
(application/vnd.pypi.simple.v1+json) when the serving web server is
configured for Accept-header content negotiation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant