Skip to content

Commit b4e1874

Browse files
GiteaBotwxiaoguang
andauthored
Fix links in PyPI Simple Repository API page (#30594) (#30612)
Backport #30594 by wxiaoguang Thanks to @Zottelchen for looking into problem and proposing the fix. Ref: astral-sh/uv#3017 , https://peps.python.org/pep-0503/ This PR's change is from Zottelchen's work. And I by the way rename the `$p` to `$pd` because `p` is used as "package" in code, while `pd` is used as "package description". ---- Co-authored-by: Zottelchen Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 parent 60f0493 commit b4e1874

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

templates/api/packages/pypi/simple.tmpl

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
<title>Links for {{.PackageDescriptor.Package.Name}}</title>
55
</head>
66
<body>
7+
{{- /* PEP 503 – Simple Repository API: https://peps.python.org/pep-0503/ */ -}}
78
<h1>Links for {{.PackageDescriptor.Package.Name}}</h1>
89
{{range .PackageDescriptors}}
9-
{{$p := .}}
10+
{{$pd := .}}
1011
{{range .Files}}
11-
<a href="{{$.RegistryURL}}/files/{{$p.Package.LowerName}}/{{$p.Version.Version}}/{{.File.Name}}#sha256-{{.Blob.HashSHA256}}"{{if $p.Metadata.RequiresPython}} data-requires-python="{{$p.Metadata.RequiresPython}}"{{end}}>{{.File.Name}}</a><br>
12+
<a href="{{$.RegistryURL}}/files/{{$pd.Package.LowerName}}/{{$pd.Version.Version}}/{{.File.Name}}#sha256={{.Blob.HashSHA256}}"{{if $pd.Metadata.RequiresPython}} data-requires-python="{{$pd.Metadata.RequiresPython}}"{{end}}>{{.File.Name}}</a><br>
1213
{{end}}
1314
{{end}}
1415
</body>

tests/integration/api_packages_pypi_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func TestPackagePyPI(t *testing.T) {
164164
nodes := htmlDoc.doc.Find("a").Nodes
165165
assert.Len(t, nodes, 2)
166166

167-
hrefMatcher := regexp.MustCompile(fmt.Sprintf(`%s/files/%s/%s/test\..+#sha256-%s`, root, regexp.QuoteMeta(packageName), regexp.QuoteMeta(packageVersion), hashSHA256))
167+
hrefMatcher := regexp.MustCompile(fmt.Sprintf(`%s/files/%s/%s/test\..+#sha256=%s`, root, regexp.QuoteMeta(packageName), regexp.QuoteMeta(packageVersion), hashSHA256))
168168

169169
for _, a := range nodes {
170170
for _, att := range a.Attr {

0 commit comments

Comments
 (0)