|
18 | 18 | """TODO This serial constant is temporary until Python repositories implements serials""" |
19 | 19 | PYPI_SERIAL_CONSTANT = 1000000000 |
20 | 20 |
|
21 | | -SIMPLE_API_VERSION = "1.0" |
| 21 | +SIMPLE_API_VERSION = "1.1" |
22 | 22 |
|
23 | 23 | simple_index_template = """<!DOCTYPE html> |
24 | 24 | <html> |
@@ -161,6 +161,7 @@ def parse_metadata(project, version, distribution): |
161 | 161 | package["sha256"] = distribution.get("digests", {}).get("sha256") or "" |
162 | 162 | package["python_version"] = distribution.get("python_version") or "" |
163 | 163 | package["requires_python"] = distribution.get("requires_python") or "" |
| 164 | + package["size"] = distribution.get("size") or None |
164 | 165 |
|
165 | 166 | return package |
166 | 167 |
|
@@ -223,6 +224,7 @@ def artifact_to_python_content_data(filename, artifact, domain=None): |
223 | 224 | metadata = get_project_metadata_from_file(temp_file.name) |
224 | 225 | data = parse_project_metadata(vars(metadata)) |
225 | 226 | data["sha256"] = artifact.sha256 |
| 227 | + data["size"] = artifact.size |
226 | 228 | data["filename"] = filename |
227 | 229 | data["pulp_domain"] = domain or artifact.pulp_domain |
228 | 230 | data["_pulp_domain"] = data["pulp_domain"] |
@@ -403,7 +405,7 @@ def find_artifact(): |
403 | 405 | components.insert(2, domain.name) |
404 | 406 | url = "/".join(components) |
405 | 407 | md5 = artifact.md5 if artifact and artifact.md5 else "" |
406 | | - size = artifact.size if artifact and artifact.size else 0 |
| 408 | + size = content.size or 0 |
407 | 409 | return { |
408 | 410 | "comment_text": "", |
409 | 411 | "digests": {"md5": md5, "sha256": content.sha256}, |
@@ -471,15 +473,18 @@ def write_simple_detail_json(project_name, project_packages): |
471 | 473 | {"sha256": package["metadata_sha256"]} if package["metadata_sha256"] else False |
472 | 474 | ), |
473 | 475 | # yanked and yanked_reason are not implemented because they are mutable |
| 476 | + # (v1.1, PEP 700) |
| 477 | + "size": package["size"], |
| 478 | + "upload-time": package["upload_time"], |
474 | 479 | # TODO in the future: |
475 | | - # size, upload-time (v1.1, PEP 700) |
476 | 480 | # core-metadata (PEP 7.14) |
477 | 481 | # provenance (v1.3, PEP 740) |
478 | 482 | } |
479 | 483 | for package in project_packages |
480 | 484 | ], |
| 485 | + # (v1.1, PEP 700) |
| 486 | + "versions": [package["version"] for package in project_packages], |
481 | 487 | # TODO in the future: |
482 | | - # versions (v1.1, PEP 700) |
483 | 488 | # alternate-locations (v1.2, PEP 708) |
484 | 489 | # project-status (v1.4, PEP 792 - pypi and docs differ) |
485 | 490 | } |
|
0 commit comments