From 2c7bd88ec1647ba936cd1ec03688232070ccf438 Mon Sep 17 00:00:00 2001 From: Daniel Alley Date: Tue, 25 Jun 2024 10:15:55 -0400 Subject: [PATCH] Update pkginfo library to support newer python packages closes #689 --- CHANGES/689.feature | 1 + .../0014_pythonpackagecontent_dynamic.py | 19 +++++++++++++++++++ pulp_python/app/models.py | 5 +++++ pulp_python/app/utils.py | 2 ++ 4 files changed, 27 insertions(+) create mode 100644 CHANGES/689.feature create mode 100644 pulp_python/app/migrations/0014_pythonpackagecontent_dynamic.py diff --git a/CHANGES/689.feature b/CHANGES/689.feature new file mode 100644 index 00000000..324f8edd --- /dev/null +++ b/CHANGES/689.feature @@ -0,0 +1 @@ +Support Python package metadata version 2.3 diff --git a/pulp_python/app/migrations/0014_pythonpackagecontent_dynamic.py b/pulp_python/app/migrations/0014_pythonpackagecontent_dynamic.py new file mode 100644 index 00000000..7702c315 --- /dev/null +++ b/pulp_python/app/migrations/0014_pythonpackagecontent_dynamic.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.10 on 2024-06-28 04:12 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('python', '0013_add_rbac_permissions'), + ] + + operations = [ + migrations.AddField( + model_name='pythonpackagecontent', + name='dynamic', + field=models.TextField(default=''), + preserve_default=False, + ), + ] diff --git a/pulp_python/app/models.py b/pulp_python/app/models.py index e3e0d2c8..62ea23ab 100644 --- a/pulp_python/app/models.py +++ b/pulp_python/app/models.py @@ -145,6 +145,10 @@ class PythonPackageContent(Content): PROTECTED_FROM_RECLAIM = False + # TODO: it appears we've set the default (usually empty-string) for each of these fields + # manually in the migrations rather than setting them declaratively. That's not ideal. + # At some point we should add proper default values and probably make some fields nullable. + TYPE = "python" repo_key_fields = ("filename",) # Required metadata @@ -178,6 +182,7 @@ class PythonPackageContent(Content): classifiers = models.JSONField(default=list) project_urls = models.JSONField(default=dict) description_content_type = models.TextField() + dynamic = models.TextField() # Pulp Domains _pulp_domain = models.ForeignKey("core.Domain", default=get_domain_pk, on_delete=models.PROTECT) diff --git a/pulp_python/app/utils.py b/pulp_python/app/utils.py index f66dcbd7..56bbfd27 100644 --- a/pulp_python/app/utils.py +++ b/pulp_python/app/utils.py @@ -93,6 +93,7 @@ def parse_project_metadata(project): package['classifiers'] = json.dumps(project.get('classifiers', [])) package['project_urls'] = json.dumps(project.get('project_urls', {})) package['description_content_type'] = project.get('description_content_type') or "" + package['dynamic'] = project.get('dynamic') or "" return package @@ -220,6 +221,7 @@ def python_content_to_info(content): "keywords": content.keywords or "", "description": content.description or "", "description_content_type": content.description_content_type or "", + "dynamic": content.dynamic or None, "bugtrack_url": None, # These two are basically never used "docs_url": None, "downloads": {"last_day": -1, "last_month": -1, "last_week": -1},