Skip to content

Commit 2ca18da

Browse files
committed
temp
1 parent 3cb2cac commit 2ca18da

File tree

5 files changed

+21
-27
lines changed

5 files changed

+21
-27
lines changed

pulp_python/app/migrations/0016_pythonpackagecontent_sha256_metadata_and_more.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class Migration(migrations.Migration):
1212
operations = [
1313
migrations.AddField(
1414
model_name="pythonpackagecontent",
15-
name="sha256_metadata",
16-
field=models.CharField(default="", max_length=64),
15+
name="metadata_sha256",
16+
field=models.CharField(null=True, max_length=64),
1717
preserve_default=False,
1818
),
1919
migrations.AddField(

pulp_python/app/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class PythonPackageContent(Content):
192192
packagetype = models.TextField(choices=PACKAGE_TYPES)
193193
python_version = models.TextField()
194194
sha256 = models.CharField(db_index=True, max_length=64)
195-
sha256_metadata = models.CharField(max_length=64)
195+
metadata_sha256 = models.CharField(max_length=64, null=True)
196196
yanked = models.BooleanField(default=False)
197197
yanked_reason = models.TextField()
198198

pulp_python/app/pypi/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def retrieve(self, request, path, package):
342342
"filename",
343343
"sha256",
344344
"name",
345-
"sha256_metadata",
345+
"metadata_sha256",
346346
"requires_python",
347347
"yanked",
348348
"yanked_reason",
@@ -361,7 +361,7 @@ def retrieve(self, request, path, package):
361361
"filename": f,
362362
"url": urljoin(self.base_content_url, f"{path}/{f}"),
363363
"sha256": s,
364-
"sha256_metadata": sm,
364+
"metadata_sha256": sm,
365365
"requires_python": rp,
366366
"yanked": y,
367367
"yanked_reason": yr,

pulp_python/app/tasks/publish.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ def write_project_page(name, simple_dir, package_releases, publication):
118118
metadata_relative_path = f"{project_dir}index.html"
119119

120120
with open(metadata_relative_path, "w") as simple_metadata:
121-
# todo?
122121
simple_metadata.write(write_simple_detail(name, package_releases))
123122

124123
project_metadata = models.PublishedMetadata.create_from_file(

pulp_python/app/utils.py

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,17 @@
1212
from pulpcore.plugin.models import Remote
1313

1414

15-
# todo: why upper case?
1615
PYPI_LAST_SERIAL = "X-PYPI-LAST-SERIAL"
1716
"""TODO This serial constant is temporary until Python repositories implements serials"""
1817
PYPI_SERIAL_CONSTANT = 1000000000
1918

20-
PYPI_API_VERSION = "1.0"
19+
SIMPLE_API_VERSION = "1.0"
2120

2221
simple_index_template = """<!DOCTYPE html>
2322
<html>
2423
<head>
2524
<title>Simple Index</title>
26-
<meta name="api-version" value="2" />
25+
<meta name="pypi:repository-version" content="{SIMPLE_API_VERSION}">
2726
</head>
2827
<body>
2928
{% for name, canonical_name in projects %}
@@ -37,12 +36,12 @@
3736
<html>
3837
<head>
3938
<title>Links for {{ project_name }}</title>
40-
<meta name="api-version" value="2" />
39+
<meta name="pypi:repository-version" content="{SIMPLE_API_VERSION}">
4140
</head>
4241
<body>
4342
<h1>Links for {{ project_name }}</h1>
4443
{% for pkg in project_packages %}
45-
<a href="{{ pkg.url }}#sha256={{ pkg.sha256 }}" rel="internal">{{ pkg.filename }}</a><br/>
44+
<a href="{{ pkg.url }}#sha256={{ pkg.sha256 }}" rel="internal">{{ pkg.filename }}{% if pkg.yanked %}data-yanked="{{ pkg.yanked_reason }}"{% endif %}</a><br/>
4645
{% endfor %}
4746
</body>
4847
</html>
@@ -131,6 +130,9 @@ def parse_project_metadata(project):
131130
# Release metadata
132131
"packagetype": project.get("packagetype") or "",
133132
"python_version": project.get("python_version") or "",
133+
"yanked": False,
134+
"yanked_reason": "",
135+
"metadata_sha256": "", # TODO
134136
}
135137

136138

@@ -163,7 +165,7 @@ def parse_metadata(project, version, distribution):
163165
) # noqa: E501
164166
package["yanked"] = distribution.get("yanked") or False
165167
package["yanked_reason"] = distribution.get("yanked_reason") or ""
166-
package["sha256_metadata"] = distribution.get("data-dist-info-metadata", {}).get("sha256") or ""
168+
package["metadata_sha256"] = distribution.get("data-dist-info-metadata", {}).get("sha256") or ""
167169

168170
return package
169171

@@ -209,10 +211,6 @@ def artifact_to_python_content_data(filename, artifact, domain=None):
209211
data["filename"] = filename
210212
data["pulp_domain"] = domain or artifact.pulp_domain
211213
data["_pulp_domain"] = data["pulp_domain"]
212-
# todo: how to get these / should they be here?
213-
# data["yanked"] = False
214-
# data["yanked_reason"] = ""
215-
# data["sha256_metadata"] = ""
216214
return data
217215

218216

@@ -335,7 +333,6 @@ def python_content_to_info(content):
335333
"platform": content.platform or "",
336334
"requires_dist": json_to_dict(content.requires_dist) or None,
337335
"classifiers": json_to_dict(content.classifiers) or None,
338-
# todo yanked
339336
"yanked": False, # These are no longer used on PyPI, but are still present
340337
"yanked_reason": None,
341338
# New core metadata (Version 2.1, 2.2, 2.4)
@@ -429,7 +426,7 @@ def write_simple_detail(project_name, project_packages, streamed=False):
429426
def write_simple_index_json(project_names):
430427
"""Writes the simple index in JSON format."""
431428
return {
432-
"meta": {"api-version": PYPI_API_VERSION, "_last-serial": PYPI_SERIAL_CONSTANT},
429+
"meta": {"api-version": SIMPLE_API_VERSION, "_last-serial": PYPI_SERIAL_CONSTANT},
433430
"projects": [
434431
{"name": name, "_last-serial": PYPI_SERIAL_CONSTANT} for name in project_names
435432
],
@@ -439,7 +436,7 @@ def write_simple_index_json(project_names):
439436
def write_simple_detail_json(project_name, project_packages):
440437
"""Writes the simple detail page in JSON format."""
441438
return {
442-
"meta": {"api-version": PYPI_API_VERSION, "_last-serial": PYPI_SERIAL_CONSTANT},
439+
"meta": {"api-version": SIMPLE_API_VERSION, "_last-serial": PYPI_SERIAL_CONSTANT},
443440
"name": canonicalize_name(project_name),
444441
"files": [
445442
{
@@ -450,23 +447,21 @@ def write_simple_detail_json(project_name, project_packages):
450447
"requires_python": package["requires_python"] or None,
451448
# data-dist-info-metadata is deprecated alias for core-metadata
452449
"data-dist-info-metadata": (
453-
{"sha256": package["sha256_metadata"]} if package["sha256_metadata"] else False
450+
{"sha256": package["metadata_sha256"]} if package["metadata_sha256"] else False
454451
),
455452
"yanked": (
456453
package["yanked_reason"]
457454
if package["yanked"] and package["yanked_reason"]
458455
else package["yanked"]
459456
),
460-
# gpg-sig (not in warehouse)
461-
# todo (from new PEPs):
462-
# size (v1.1, PEP 700)
463-
# upload-time (v1.1, PEP 700)
464-
# core-metadata (PEP 7.14)
465-
# provenance (v1.3, PEP 740)
457+
# TODO:
458+
# size, upload-time (v1.1, PEP 700)
459+
# core-metadata (PEP 714)
460+
# provenance and digital attestation (v1.3, PEP 740)
466461
}
467462
for package in project_packages
468463
],
469-
# todo (from new PEPs):
464+
# TODO:
470465
# versions (v1.1, PEP 700)
471466
# alternate-locations (v1.2, PEP 708)
472467
# project-status (v1.4, PEP 792 - pypi and docs differ)

0 commit comments

Comments
 (0)