Skip to content

Commit a684757

Browse files
committed
temp
1 parent 3cb2cac commit a684757

File tree

5 files changed

+22
-27
lines changed

5 files changed

+22
-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: 17 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 %}
@@ -33,16 +32,17 @@
3332
</html>
3433
"""
3534

35+
# noqa: E501
3636
simple_detail_template = """<!DOCTYPE html>
3737
<html>
3838
<head>
3939
<title>Links for {{ project_name }}</title>
40-
<meta name="api-version" value="2" />
40+
<meta name="pypi:repository-version" content="{SIMPLE_API_VERSION}">
4141
</head>
4242
<body>
4343
<h1>Links for {{ project_name }}</h1>
4444
{% for pkg in project_packages %}
45-
<a href="{{ pkg.url }}#sha256={{ pkg.sha256 }}" rel="internal">{{ pkg.filename }}</a><br/>
45+
<a href="{{ pkg.url }}#sha256={{ pkg.sha256 }}" rel="internal">{{ pkg.filename }}{% if pkg.yanked %}data-yanked="{{ pkg.yanked_reason }}"{% endif %}</a><br/>
4646
{% endfor %}
4747
</body>
4848
</html>
@@ -131,6 +131,9 @@ def parse_project_metadata(project):
131131
# Release metadata
132132
"packagetype": project.get("packagetype") or "",
133133
"python_version": project.get("python_version") or "",
134+
"yanked": False,
135+
"yanked_reason": "",
136+
"metadata_sha256": "", # TODO
134137
}
135138

136139

@@ -163,7 +166,7 @@ def parse_metadata(project, version, distribution):
163166
) # noqa: E501
164167
package["yanked"] = distribution.get("yanked") or False
165168
package["yanked_reason"] = distribution.get("yanked_reason") or ""
166-
package["sha256_metadata"] = distribution.get("data-dist-info-metadata", {}).get("sha256") or ""
169+
package["metadata_sha256"] = distribution.get("data-dist-info-metadata", {}).get("sha256") or ""
167170

168171
return package
169172

@@ -209,10 +212,6 @@ def artifact_to_python_content_data(filename, artifact, domain=None):
209212
data["filename"] = filename
210213
data["pulp_domain"] = domain or artifact.pulp_domain
211214
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"] = ""
216215
return data
217216

218217

@@ -335,7 +334,6 @@ def python_content_to_info(content):
335334
"platform": content.platform or "",
336335
"requires_dist": json_to_dict(content.requires_dist) or None,
337336
"classifiers": json_to_dict(content.classifiers) or None,
338-
# todo yanked
339337
"yanked": False, # These are no longer used on PyPI, but are still present
340338
"yanked_reason": None,
341339
# New core metadata (Version 2.1, 2.2, 2.4)
@@ -429,7 +427,7 @@ def write_simple_detail(project_name, project_packages, streamed=False):
429427
def write_simple_index_json(project_names):
430428
"""Writes the simple index in JSON format."""
431429
return {
432-
"meta": {"api-version": PYPI_API_VERSION, "_last-serial": PYPI_SERIAL_CONSTANT},
430+
"meta": {"api-version": SIMPLE_API_VERSION, "_last-serial": PYPI_SERIAL_CONSTANT},
433431
"projects": [
434432
{"name": name, "_last-serial": PYPI_SERIAL_CONSTANT} for name in project_names
435433
],
@@ -439,7 +437,7 @@ def write_simple_index_json(project_names):
439437
def write_simple_detail_json(project_name, project_packages):
440438
"""Writes the simple detail page in JSON format."""
441439
return {
442-
"meta": {"api-version": PYPI_API_VERSION, "_last-serial": PYPI_SERIAL_CONSTANT},
440+
"meta": {"api-version": SIMPLE_API_VERSION, "_last-serial": PYPI_SERIAL_CONSTANT},
443441
"name": canonicalize_name(project_name),
444442
"files": [
445443
{
@@ -450,23 +448,21 @@ def write_simple_detail_json(project_name, project_packages):
450448
"requires_python": package["requires_python"] or None,
451449
# data-dist-info-metadata is deprecated alias for core-metadata
452450
"data-dist-info-metadata": (
453-
{"sha256": package["sha256_metadata"]} if package["sha256_metadata"] else False
451+
{"sha256": package["metadata_sha256"]} if package["metadata_sha256"] else False
454452
),
455453
"yanked": (
456454
package["yanked_reason"]
457455
if package["yanked"] and package["yanked_reason"]
458456
else package["yanked"]
459457
),
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)
458+
# TODO:
459+
# size, upload-time (v1.1, PEP 700)
460+
# core-metadata (PEP 714)
461+
# provenance and digital attestation (v1.3, PEP 740)
466462
}
467463
for package in project_packages
468464
],
469-
# todo (from new PEPs):
465+
# TODO:
470466
# versions (v1.1, PEP 700)
471467
# alternate-locations (v1.2, PEP 708)
472468
# project-status (v1.4, PEP 792 - pypi and docs differ)

0 commit comments

Comments
 (0)