pulp-python 3.12.9__py3-none-any.whl → 3.12.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pulp_python/__init__.py +1 -1
- pulp_python/app/__init__.py +5 -3
- pulp_python/app/fields.py +1 -1
- pulp_python/app/global_access_conditions.py +0 -1
- pulp_python/app/modelresource.py +1 -0
- pulp_python/app/models.py +8 -7
- pulp_python/app/pypi/serializers.py +12 -10
- pulp_python/app/pypi/views.py +69 -54
- pulp_python/app/replica.py +3 -2
- pulp_python/app/serializers.py +192 -115
- pulp_python/app/settings.py +1 -1
- pulp_python/app/tasks/publish.py +24 -25
- pulp_python/app/tasks/sync.py +18 -32
- pulp_python/app/tasks/upload.py +13 -14
- pulp_python/app/urls.py +5 -5
- pulp_python/app/utils.py +38 -36
- pulp_python/app/viewsets.py +43 -46
- pulp_python/pytest_plugin.py +14 -5
- pulp_python/tests/functional/api/test_consume_content.py +0 -1
- pulp_python/tests/functional/api/test_crud_content_unit.py +8 -5
- pulp_python/tests/functional/api/test_crud_publications.py +9 -6
- pulp_python/tests/functional/api/test_crud_remotes.py +3 -2
- pulp_python/tests/functional/api/test_domains.py +10 -8
- pulp_python/tests/functional/api/test_download_content.py +2 -2
- pulp_python/tests/functional/api/test_export_import.py +7 -4
- pulp_python/tests/functional/api/test_full_mirror.py +4 -4
- pulp_python/tests/functional/api/test_pypi_apis.py +13 -18
- pulp_python/tests/functional/api/test_rbac.py +4 -2
- pulp_python/tests/functional/api/test_sync.py +28 -19
- pulp_python/tests/functional/constants.py +15 -33
- pulp_python/tests/functional/utils.py +15 -6
- {pulp_python-3.12.9.dist-info → pulp_python-3.12.10.dist-info}/METADATA +1 -1
- pulp_python-3.12.10.dist-info/RECORD +62 -0
- {pulp_python-3.12.9.dist-info → pulp_python-3.12.10.dist-info}/WHEEL +1 -1
- pulp_python-3.12.9.dist-info/RECORD +0 -62
- {pulp_python-3.12.9.dist-info → pulp_python-3.12.10.dist-info}/entry_points.txt +0 -0
- {pulp_python-3.12.9.dist-info → pulp_python-3.12.10.dist-info}/licenses/LICENSE +0 -0
- {pulp_python-3.12.9.dist-info → pulp_python-3.12.10.dist-info}/top_level.txt +0 -0
pulp_python/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
default_app_config =
|
|
1
|
+
default_app_config = "pulp_python.app.PulpPythonPluginAppConfig"
|
pulp_python/app/__init__.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
from gettext import gettext as _
|
|
2
|
+
|
|
1
3
|
from django.db.models.signals import post_migrate
|
|
4
|
+
|
|
2
5
|
from pulpcore.plugin import PulpPluginAppConfig
|
|
3
|
-
from gettext import gettext as _
|
|
4
6
|
|
|
5
7
|
|
|
6
8
|
class PulpPythonPluginAppConfig(PulpPluginAppConfig):
|
|
@@ -10,7 +12,7 @@ class PulpPythonPluginAppConfig(PulpPluginAppConfig):
|
|
|
10
12
|
|
|
11
13
|
name = "pulp_python.app"
|
|
12
14
|
label = "python"
|
|
13
|
-
version = "3.12.
|
|
15
|
+
version = "3.12.10"
|
|
14
16
|
python_package_name = "pulp-python"
|
|
15
17
|
domain_compatible = True
|
|
16
18
|
|
|
@@ -26,7 +28,7 @@ class PulpPythonPluginAppConfig(PulpPluginAppConfig):
|
|
|
26
28
|
|
|
27
29
|
# TODO: Remove this when https://github.com/pulp/pulpcore/issues/5500 is resolved
|
|
28
30
|
def _populate_pypi_access_policies(sender, apps, verbosity, **kwargs):
|
|
29
|
-
from pulp_python.app.pypi.views import PyPIView, SimpleView, UploadView
|
|
31
|
+
from pulp_python.app.pypi.views import MetadataView, PyPIView, SimpleView, UploadView
|
|
30
32
|
|
|
31
33
|
try:
|
|
32
34
|
AccessPolicy = apps.get_model("core", "AccessPolicy")
|
pulp_python/app/fields.py
CHANGED
pulp_python/app/modelresource.py
CHANGED
pulp_python/app/models.py
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
from logging import getLogger
|
|
2
|
+
from pathlib import PurePath
|
|
2
3
|
|
|
3
4
|
from aiohttp.web import json_response
|
|
5
|
+
from django.conf import settings
|
|
4
6
|
from django.contrib.postgres.fields import ArrayField
|
|
5
7
|
from django.core.exceptions import ObjectDoesNotExist
|
|
6
8
|
from django.db import models
|
|
7
|
-
|
|
9
|
+
|
|
8
10
|
from pulpcore.plugin.models import (
|
|
9
11
|
AutoAddObjPermsMixin,
|
|
10
12
|
Content,
|
|
11
|
-
Publication,
|
|
12
13
|
Distribution,
|
|
14
|
+
Publication,
|
|
13
15
|
Remote,
|
|
14
16
|
Repository,
|
|
15
17
|
)
|
|
18
|
+
from pulpcore.plugin.repo_version_utils import remove_duplicates, validate_repo_version
|
|
16
19
|
from pulpcore.plugin.responses import ArtifactResponse
|
|
20
|
+
from pulpcore.plugin.util import get_domain, get_domain_pk
|
|
17
21
|
|
|
18
|
-
from pathlib import PurePath
|
|
19
22
|
from .utils import (
|
|
23
|
+
PYPI_LAST_SERIAL,
|
|
24
|
+
PYPI_SERIAL_CONSTANT,
|
|
20
25
|
canonicalize_name,
|
|
21
26
|
get_project_metadata_from_artifact,
|
|
22
27
|
parse_project_metadata,
|
|
23
28
|
python_content_to_json,
|
|
24
|
-
PYPI_LAST_SERIAL,
|
|
25
|
-
PYPI_SERIAL_CONSTANT,
|
|
26
29
|
)
|
|
27
|
-
from pulpcore.plugin.repo_version_utils import remove_duplicates, validate_repo_version
|
|
28
|
-
from pulpcore.plugin.util import get_domain_pk, get_domain
|
|
29
30
|
|
|
30
31
|
log = getLogger(__name__)
|
|
31
32
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
from gettext import gettext as _
|
|
3
3
|
|
|
4
|
+
from django.db.utils import IntegrityError
|
|
4
5
|
from rest_framework import serializers
|
|
5
|
-
|
|
6
|
-
from pulp_python.app import fields
|
|
6
|
+
|
|
7
7
|
from pulpcore.plugin.models import Artifact
|
|
8
8
|
from pulpcore.plugin.util import get_domain
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
from pulp_python.app import fields
|
|
11
|
+
from pulp_python.app.utils import DIST_EXTENSIONS
|
|
10
12
|
|
|
11
13
|
log = logging.getLogger(__name__)
|
|
12
14
|
|
|
@@ -47,7 +49,7 @@ class PackageUploadSerializer(serializers.Serializer):
|
|
|
47
49
|
action = serializers.CharField(
|
|
48
50
|
help_text=_("Defaults to `file_upload`, don't change it or request will fail!"),
|
|
49
51
|
default="file_upload",
|
|
50
|
-
source=":action"
|
|
52
|
+
source=":action",
|
|
51
53
|
)
|
|
52
54
|
sha256_digest = serializers.CharField(
|
|
53
55
|
help_text=_("SHA256 of package to validate upload integrity."),
|
|
@@ -60,17 +62,17 @@ class PackageUploadSerializer(serializers.Serializer):
|
|
|
60
62
|
"""Validates the request."""
|
|
61
63
|
action = data.get(":action")
|
|
62
64
|
if action != "file_upload":
|
|
63
|
-
raise serializers.ValidationError(
|
|
64
|
-
_("We do not support the :action {}").format(action)
|
|
65
|
-
)
|
|
65
|
+
raise serializers.ValidationError(_("We do not support the :action {}").format(action))
|
|
66
66
|
file = data.get("content")
|
|
67
67
|
for ext, packagetype in DIST_EXTENSIONS.items():
|
|
68
68
|
if file.name.endswith(ext):
|
|
69
69
|
break
|
|
70
70
|
else:
|
|
71
|
-
raise serializers.ValidationError(
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
raise serializers.ValidationError(
|
|
72
|
+
_(
|
|
73
|
+
"Extension on {} is not a valid python extension "
|
|
74
|
+
"(.whl, .exe, .egg, .tar.gz, .tar.bz2, .zip)"
|
|
75
|
+
).format(file.name)
|
|
74
76
|
)
|
|
75
77
|
sha256 = data.get("sha256_digest")
|
|
76
78
|
digests = {"sha256": sha256} if sha256 else None
|
pulp_python/app/pypi/views.py
CHANGED
|
@@ -1,54 +1,53 @@
|
|
|
1
1
|
import logging
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from django.core.exceptions import ObjectDoesNotExist
|
|
7
|
-
from django.shortcuts import redirect
|
|
8
|
-
from datetime import datetime, timezone, timedelta
|
|
2
|
+
from datetime import datetime, timedelta, timezone
|
|
3
|
+
from itertools import chain
|
|
4
|
+
from pathlib import PurePath
|
|
5
|
+
from urllib.parse import urljoin, urlparse, urlunsplit
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
import requests
|
|
11
8
|
from django.contrib.sessions.models import Session
|
|
9
|
+
from django.core.exceptions import ObjectDoesNotExist
|
|
12
10
|
from django.db import transaction
|
|
13
11
|
from django.db.utils import DatabaseError
|
|
14
12
|
from django.http.response import (
|
|
15
13
|
Http404,
|
|
16
|
-
HttpResponseForbidden,
|
|
17
14
|
HttpResponseBadRequest,
|
|
18
|
-
|
|
15
|
+
HttpResponseForbidden,
|
|
16
|
+
StreamingHttpResponse,
|
|
19
17
|
)
|
|
18
|
+
from django.shortcuts import redirect
|
|
20
19
|
from drf_spectacular.utils import extend_schema
|
|
21
20
|
from dynaconf import settings
|
|
22
|
-
from itertools import chain
|
|
23
21
|
from packaging.utils import canonicalize_name
|
|
24
|
-
from urllib.parse import urljoin, urlparse, urlunsplit
|
|
25
|
-
from pathlib import PurePath
|
|
26
22
|
from pypi_simple.parse_stream import parse_links_stream_response
|
|
23
|
+
from rest_framework.response import Response
|
|
24
|
+
from rest_framework.reverse import reverse
|
|
25
|
+
from rest_framework.viewsets import ViewSet
|
|
27
26
|
|
|
28
|
-
from pulpcore.plugin.viewsets import OperationPostponedResponse
|
|
29
27
|
from pulpcore.plugin.tasking import dispatch
|
|
30
28
|
from pulpcore.plugin.util import get_domain
|
|
29
|
+
from pulpcore.plugin.viewsets import OperationPostponedResponse
|
|
30
|
+
|
|
31
|
+
from pulp_python.app import tasks
|
|
31
32
|
from pulp_python.app.models import (
|
|
32
33
|
PythonDistribution,
|
|
33
34
|
PythonPackageContent,
|
|
34
35
|
PythonPublication,
|
|
35
36
|
)
|
|
36
37
|
from pulp_python.app.pypi.serializers import (
|
|
37
|
-
SummarySerializer,
|
|
38
38
|
PackageMetadataSerializer,
|
|
39
39
|
PackageUploadSerializer,
|
|
40
|
-
PackageUploadTaskSerializer
|
|
40
|
+
PackageUploadTaskSerializer,
|
|
41
|
+
SummarySerializer,
|
|
41
42
|
)
|
|
42
43
|
from pulp_python.app.utils import (
|
|
43
|
-
write_simple_index,
|
|
44
|
-
write_simple_detail,
|
|
45
|
-
python_content_to_json,
|
|
46
44
|
PYPI_LAST_SERIAL,
|
|
47
45
|
PYPI_SERIAL_CONSTANT,
|
|
46
|
+
python_content_to_json,
|
|
47
|
+
write_simple_detail,
|
|
48
|
+
write_simple_index,
|
|
48
49
|
)
|
|
49
50
|
|
|
50
|
-
from pulp_python.app import tasks
|
|
51
|
-
|
|
52
51
|
log = logging.getLogger(__name__)
|
|
53
52
|
|
|
54
53
|
BASE_CONTENT_URL = urljoin(settings.CONTENT_ORIGIN, settings.CONTENT_PATH_PREFIX)
|
|
@@ -158,10 +157,15 @@ class PackageUploadMixin(PyPIMixin):
|
|
|
158
157
|
if settings.PYTHON_GROUP_UPLOADS:
|
|
159
158
|
return self.upload_package_group(repo, artifact, filename, request.session)
|
|
160
159
|
|
|
161
|
-
result = dispatch(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
160
|
+
result = dispatch(
|
|
161
|
+
tasks.upload,
|
|
162
|
+
exclusive_resources=[artifact, repo],
|
|
163
|
+
kwargs={
|
|
164
|
+
"artifact_sha256": artifact.sha256,
|
|
165
|
+
"filename": filename,
|
|
166
|
+
"repository_pk": str(repo.pk),
|
|
167
|
+
},
|
|
168
|
+
)
|
|
165
169
|
return OperationPostponedResponse(result, request)
|
|
166
170
|
|
|
167
171
|
def upload_package_group(self, repo, artifact, filename, session):
|
|
@@ -175,10 +179,10 @@ class PackageUploadMixin(PyPIMixin):
|
|
|
175
179
|
try:
|
|
176
180
|
with transaction.atomic():
|
|
177
181
|
sq.first()
|
|
178
|
-
current_start = datetime.fromisoformat(session[
|
|
182
|
+
current_start = datetime.fromisoformat(session["start"])
|
|
179
183
|
if current_start >= datetime.now(tz=timezone.utc):
|
|
180
|
-
session[
|
|
181
|
-
session[
|
|
184
|
+
session["artifacts"].append((str(artifact.sha256), filename))
|
|
185
|
+
session["start"] = str(start_time)
|
|
182
186
|
session.modified = False
|
|
183
187
|
session.save()
|
|
184
188
|
else:
|
|
@@ -191,14 +195,19 @@ class PackageUploadMixin(PyPIMixin):
|
|
|
191
195
|
|
|
192
196
|
def create_group_upload_task(self, cur_session, repository, artifact, filename, start_time):
|
|
193
197
|
"""Creates the actual task that adds the packages to the index."""
|
|
194
|
-
cur_session[
|
|
195
|
-
cur_session[
|
|
198
|
+
cur_session["start"] = str(start_time)
|
|
199
|
+
cur_session["artifacts"] = [(str(artifact.sha256), filename)]
|
|
196
200
|
cur_session.modified = False
|
|
197
201
|
cur_session.save()
|
|
198
|
-
result = dispatch(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
+
result = dispatch(
|
|
203
|
+
tasks.upload_group,
|
|
204
|
+
exclusive_resources=[artifact, repository],
|
|
205
|
+
kwargs={
|
|
206
|
+
"session_pk": str(cur_session.session_key),
|
|
207
|
+
"repository_pk": str(repository.pk),
|
|
208
|
+
},
|
|
209
|
+
)
|
|
210
|
+
return reverse("tasks-detail", args=[result.pk], request=None)
|
|
202
211
|
|
|
203
212
|
|
|
204
213
|
class SimpleView(PackageUploadMixin, ViewSet):
|
|
@@ -226,21 +235,22 @@ class SimpleView(PackageUploadMixin, ViewSet):
|
|
|
226
235
|
"""Gets the simple api html page for the index."""
|
|
227
236
|
repo_version, content = self.get_rvc()
|
|
228
237
|
if self.should_redirect(repo_version=repo_version):
|
|
229
|
-
return redirect(urljoin(self.base_content_url, f
|
|
230
|
-
names = content.order_by(
|
|
238
|
+
return redirect(urljoin(self.base_content_url, f"{path}/simple/"))
|
|
239
|
+
names = content.order_by("name").values_list("name", flat=True).distinct().iterator()
|
|
231
240
|
return StreamingHttpResponse(write_simple_index(names, streamed=True))
|
|
232
241
|
|
|
233
242
|
def pull_through_package_simple(self, package, path, remote):
|
|
234
243
|
"""Gets the package's simple page from remote."""
|
|
244
|
+
|
|
235
245
|
def parse_url(link):
|
|
236
246
|
parsed = urlparse(link.url)
|
|
237
|
-
digest, _, value = parsed.fragment.partition(
|
|
247
|
+
digest, _, value = parsed.fragment.partition("=")
|
|
238
248
|
stripped_url = urlunsplit(chain(parsed[:3], ("", "")))
|
|
239
|
-
redirect = f
|
|
249
|
+
redirect = f"{path}/{link.text}?redirect={stripped_url}"
|
|
240
250
|
d_url = urljoin(self.base_content_url, redirect)
|
|
241
|
-
return link.text, d_url, value if digest ==
|
|
251
|
+
return link.text, d_url, value if digest == "sha256" else ""
|
|
242
252
|
|
|
243
|
-
url = remote.get_remote_artifact_url(f
|
|
253
|
+
url = remote.get_remote_artifact_url(f"simple/{package}/")
|
|
244
254
|
kwargs = {}
|
|
245
255
|
if proxy_url := remote.proxy_url:
|
|
246
256
|
if remote.proxy_username or remote.proxy_password:
|
|
@@ -264,10 +274,10 @@ class SimpleView(PackageUploadMixin, ViewSet):
|
|
|
264
274
|
if not repo_ver or not content.filter(name__normalize=normalized).exists():
|
|
265
275
|
return self.pull_through_package_simple(normalized, path, self.distribution.remote)
|
|
266
276
|
if self.should_redirect(repo_version=repo_ver):
|
|
267
|
-
return redirect(urljoin(self.base_content_url, f
|
|
277
|
+
return redirect(urljoin(self.base_content_url, f"{path}/simple/{normalized}/"))
|
|
268
278
|
packages = (
|
|
269
279
|
content.filter(name__normalize=normalized)
|
|
270
|
-
.values_list(
|
|
280
|
+
.values_list("filename", "sha256", "name")
|
|
271
281
|
.iterator()
|
|
272
282
|
)
|
|
273
283
|
try:
|
|
@@ -277,12 +287,14 @@ class SimpleView(PackageUploadMixin, ViewSet):
|
|
|
277
287
|
else:
|
|
278
288
|
packages = chain([present], packages)
|
|
279
289
|
name = present[2]
|
|
280
|
-
releases = ((f, urljoin(self.base_content_url, f
|
|
290
|
+
releases = ((f, urljoin(self.base_content_url, f"{path}/{f}"), d) for f, d, _ in packages)
|
|
281
291
|
return StreamingHttpResponse(write_simple_detail(name, releases, streamed=True))
|
|
282
292
|
|
|
283
|
-
@extend_schema(
|
|
284
|
-
|
|
285
|
-
|
|
293
|
+
@extend_schema(
|
|
294
|
+
request=PackageUploadSerializer,
|
|
295
|
+
responses={200: PackageUploadTaskSerializer},
|
|
296
|
+
summary="Upload a package",
|
|
297
|
+
)
|
|
286
298
|
def create(self, request, path):
|
|
287
299
|
"""
|
|
288
300
|
Upload package to the index.
|
|
@@ -307,9 +319,11 @@ class MetadataView(PyPIMixin, ViewSet):
|
|
|
307
319
|
],
|
|
308
320
|
}
|
|
309
321
|
|
|
310
|
-
@extend_schema(
|
|
311
|
-
|
|
312
|
-
|
|
322
|
+
@extend_schema(
|
|
323
|
+
tags=["Pypi: Metadata"],
|
|
324
|
+
responses={200: PackageMetadataSerializer},
|
|
325
|
+
summary="Get package metadata",
|
|
326
|
+
)
|
|
313
327
|
def retrieve(self, request, path, meta):
|
|
314
328
|
"""
|
|
315
329
|
Retrieves the package's core-metadata specified by
|
|
@@ -355,8 +369,7 @@ class PyPIView(PyPIMixin, ViewSet):
|
|
|
355
369
|
],
|
|
356
370
|
}
|
|
357
371
|
|
|
358
|
-
@extend_schema(responses={200: SummarySerializer},
|
|
359
|
-
summary="Get index summary")
|
|
372
|
+
@extend_schema(responses={200: SummarySerializer}, summary="Get index summary")
|
|
360
373
|
def retrieve(self, request, path):
|
|
361
374
|
"""Gets package summary stats of index."""
|
|
362
375
|
repo_ver, content = self.get_rvc()
|
|
@@ -382,9 +395,11 @@ class UploadView(PackageUploadMixin, ViewSet):
|
|
|
382
395
|
],
|
|
383
396
|
}
|
|
384
397
|
|
|
385
|
-
@extend_schema(
|
|
386
|
-
|
|
387
|
-
|
|
398
|
+
@extend_schema(
|
|
399
|
+
request=PackageUploadSerializer,
|
|
400
|
+
responses={200: PackageUploadTaskSerializer},
|
|
401
|
+
summary="Upload a package",
|
|
402
|
+
)
|
|
388
403
|
def create(self, request, path):
|
|
389
404
|
"""
|
|
390
405
|
Upload package to the index.
|
pulp_python/app/replica.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
from pulpcore.plugin.replica import Replicator
|
|
2
|
-
|
|
3
1
|
from pulp_glue.python.context import (
|
|
4
2
|
PulpPythonDistributionContext,
|
|
5
3
|
PulpPythonPublicationContext,
|
|
6
4
|
PulpPythonRepositoryContext,
|
|
7
5
|
)
|
|
6
|
+
|
|
7
|
+
from pulpcore.plugin.replica import Replicator
|
|
8
|
+
|
|
8
9
|
from pulp_python.app.models import PythonDistribution, PythonRemote, PythonRepository
|
|
9
10
|
from pulp_python.app.tasks import sync as python_sync
|
|
10
11
|
|