2 GoCheese -- Python private package repository and caching proxy
3 Copyright (C) 2019-2021 Sergey Matveev <stargrave@stargrave.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, version 3 of the License.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 MetadataFile = ".metadata.rec"
25 // https://packaging.python.org/specifications/core-metadata/
26 MetadataVersion = "2.1"
27 MetadataFieldMetadataVersion = "Metadata-Version"
28 MetadataFieldName = "Name"
29 MetadataFieldVersion = "Version"
30 MetadataFieldDescription = "Description"
31 MetadataFieldPlatform = "Platform"
32 MetadataFieldSupportedPlatform = "Supported-Platform"
33 MetadataFieldSummary = "Summary"
34 MetadataFieldDescriptionContentType = "Description-Content-Type"
35 MetadataFieldKeywords = "Keywords"
36 MetadataFieldHomePage = "Home-page"
37 MetadataFieldAuthor = "Author"
38 MetadataFieldAuthorEmail = "Author-email"
39 MetadataFieldMaintainer = "Maintainer"
40 MetadataFieldMaintainerEmail = "Maintainer-Email"
41 MetadataFieldLicense = "License"
42 MetadataFieldRequiresDist = "Requires-Dist"
43 MetadataFieldRequiresPython = "Requires-Python"
44 MetadataFieldRequiresExternal = "Requires-External"
45 MetadataFieldProjectURL = "Project-URL"
46 MetadataFieldProvidesExtra = "Provides-Extra"
47 MetadataFieldClassifier = "Classifier"
50 func metadataFieldToRecField(f string) string {
51 return strings.ReplaceAll(f, "-", "")
54 // It should follow https://www.python.org/dev/peps/pep-0566/
56 Name string `json:"name"`
57 Version string `json:"version"`
58 Platform []string `json:"platform,omitempty"`
59 SupportedPlatform []string `json:"supported_platform,omitempty"`
60 Summary string `json:"summary,omitempty"`
61 Description string `json:"description,omitempty"`
62 DescriptionContentType string `json:"description_content_type,omitempty"`
63 Keywords string `json:"keywords,omitempty"`
64 HomePage string `json:"home_page,omitempty"`
65 Author string `json:"author,omitempty"`
66 AuthorEmail string `json:"author_email,omitempty"`
67 Maintainer string `json:"maintainer,omitempty"`
68 MaintainerEmail string `json:"maintainer_email,omitempty"`
69 License string `json:"license,omitempty"`
70 Classifier []string `json:"classifier,omitempty"`
71 RequiresDist []string `json:"requires_dist,omitempty"`
72 RequiresPython string `json:"requires_python,omitempty"`
73 RequiresExternal []string `json:"requires_external,omitempty"`
74 ProjectURL []string `json:"project_url,omitempty"`
75 ProvidesExtra []string `json:"provides_extra,omitempty"`
78 // But current PyPI does not follow PEP-0566, so just ignore some fields
79 type PkgInfoStripped struct {
80 Name string `json:"name"`
81 Version string `json:"version"`
82 Summary string `json:"summary,omitempty"`
83 Description string `json:"description,omitempty"`
84 DescriptionContentType string `json:"description_content_type,omitempty"`
85 Keywords string `json:"keywords,omitempty"`
86 HomePage string `json:"home_page,omitempty"`
87 Author string `json:"author,omitempty"`
88 AuthorEmail string `json:"author_email,omitempty"`
89 Maintainer string `json:"maintainer,omitempty"`
90 MaintainerEmail string `json:"maintainer_email,omitempty"`
91 License string `json:"license,omitempty"`
92 Classifier []string `json:"classifiers,omitempty"`
93 RequiresPython string `json:"requires_python,omitempty"`
94 RequiresDist []string `json:"requires_dist,omitempty"`
97 // Unknown format: no detailed specification available
98 // https://github.com/cooperlees/peps/blob/warehouse_json_api/pep-9999.rst
99 type PkgReleaseInfo struct {
100 Filename string `json:"filename"`
101 Version string `json:"version"`
102 UploadTimeISO8601 string `json:"upload_time_iso_8601"`
103 Size int64 `json:"size"`
104 HasSig bool `json:"has_sig"`
106 Digests map[string]string `json:"digests"`
109 type PkgMeta struct {
110 Info PkgInfo `json:"info"`
111 LastSerial int `json:"last_serial"`
112 Releases map[string][]*PkgReleaseInfo `json:"releases"`
113 URLs []*PkgReleaseInfo `json:"urls"`
116 type PkgMetaStripped struct {
117 Info PkgInfoStripped `json:"info"`
118 Releases map[string][]*PkgReleaseInfo `json:"releases"`