warehouse icon indicating copy to clipboard operation
warehouse copied to clipboard

Implement Alternate Repository Location for PEP 708

Open cofiem opened this issue 1 year ago • 2 comments

Adds per-project Alternate Repository Location as per PEP 708.

  • Implements the UI and database changes.
  • Includes changes to the html and json APIs.
  • Includes tests.
  • The alternate repository location information is on the project settings page.
  • There is a form to add, and a list to show and delete existing entries.

Notes:

  • The 'tracks' metadata does not make sense for PyPI, as PyPI does not extend other repositories.

Relates to #15431

Previews:

HTML: curl http://localhost/simple/[project_name]/

<!DOCTYPE html>
<html>
  <head>
    <meta name="pypi:repository-version" content="1.1">
    <meta name="pypi:alternate-locations" content="https://example.org">
    <title>Links for [project_name]</title>
  </head>
...

JSON: curl -H "Accept: application/vnd.pypi.simple.v1+json" http://localhost/simple/[project_name]/

{"alternate-locations":["https://example.org"], ... }

image

cofiem avatar Apr 03 '24 13:04 cofiem

Hi @cofiem and thank you for your contribution! I'm going to ask @dstufft to take a look as PEP author.

ewdurbin avatar Jul 09 '24 22:07 ewdurbin

Thanks very much for the initial review, @ewdurbin! I'll have a look at the cache keys for the model.

cofiem avatar Jul 10 '24 03:07 cofiem

Thanks for picking this up by the way! Really jazzed to see it getting worked on.

dstufft avatar Aug 22 '24 02:08 dstufft

Thanks for reviewing @dstufft! @cofiem, I believe the comments from Donald should address the outstanding open questions.

Once this is updated I think it is ready for final review and merge!

ewdurbin avatar Aug 22 '24 13:08 ewdurbin

@cofiem thank you! I pushed a commit to fix tests and include the self-reference in JSON API as well.

@dstufft I think this is ready to go, but I am curious if we should always send the self-reference in alternate-repositories value... or only when an alternate has been specified.

ewdurbin avatar Aug 23 '24 12:08 ewdurbin

@ewdurbin That commit to fix tests and make the JSON & HTML apis match makes sense!

cofiem avatar Aug 26 '24 07:08 cofiem

I'm going to hold off for a couple days, but if I don't hear from @dstufft on the two remaining open questions, I will remove the self-reference in alternate-repositories values and merge. The PEP reads as though they can be implied "When using alternate locations, clients MUST implicitly assume that the url the response was fetched from was included in the list."

ewdurbin avatar Sep 16 '24 18:09 ewdurbin

Added a small callout block that we should remove when PEP 708 provisional acceptance becomes acceptance acceptance. Screenshot 2024-09-19 at 9 46 34 AM

ewdurbin avatar Sep 19 '24 13:09 ewdurbin

Excellent, thanks @ewdurbin!

cofiem avatar Sep 20 '24 23:09 cofiem