pulp-python 3.11.8__py3-none-any.whl → 3.11.9__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 +1 -1
- pulp_python/app/fields.py +1 -1
- pulp_python/app/modelresource.py +1 -0
- pulp_python/app/models.py +6 -5
- pulp_python/app/pypi/serializers.py +12 -10
- pulp_python/app/pypi/views.py +70 -55
- 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 +11 -12
- pulp_python/app/urls.py +6 -6
- pulp_python/app/utils.py +38 -36
- pulp_python/app/viewsets.py +42 -44
- pulp_python/tests/functional/api/test_auto_publish.py +5 -3
- pulp_python/tests/functional/api/test_consume_content.py +9 -11
- pulp_python/tests/functional/api/test_crud_content_unit.py +17 -22
- pulp_python/tests/functional/api/test_crud_publications.py +13 -15
- pulp_python/tests/functional/api/test_crud_remotes.py +11 -14
- pulp_python/tests/functional/api/test_download_content.py +10 -17
- pulp_python/tests/functional/api/test_export_import.py +7 -8
- pulp_python/tests/functional/api/test_full_mirror.py +21 -19
- pulp_python/tests/functional/api/test_pypi_apis.py +23 -27
- pulp_python/tests/functional/api/test_sync.py +41 -58
- pulp_python/tests/functional/conftest.py +14 -4
- pulp_python/tests/functional/constants.py +25 -39
- pulp_python/tests/functional/utils.py +34 -22
- pulp_python/tests/upgrade/post/test_publish.py +11 -10
- pulp_python/tests/upgrade/pre/test_publish.py +12 -11
- {pulp_python-3.11.8.dist-info → pulp_python-3.11.9.dist-info}/METADATA +1 -1
- pulp_python-3.11.9.dist-info/RECORD +61 -0
- {pulp_python-3.11.8.dist-info → pulp_python-3.11.9.dist-info}/WHEEL +1 -1
- pulp_python-3.11.8.dist-info/RECORD +0 -61
- {pulp_python-3.11.8.dist-info → pulp_python-3.11.9.dist-info}/entry_points.txt +0 -0
- {pulp_python-3.11.8.dist-info → pulp_python-3.11.9.dist-info}/licenses/LICENSE +0 -0
- {pulp_python-3.11.8.dist-info → pulp_python-3.11.9.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
pulp_python/app/fields.py
CHANGED
pulp_python/app/modelresource.py
CHANGED
pulp_python/app/models.py
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
from logging import getLogger
|
|
2
|
+
from pathlib import PurePath
|
|
2
3
|
|
|
3
4
|
from aiohttp.web import json_response
|
|
4
5
|
from django.contrib.postgres.fields import ArrayField
|
|
5
6
|
from django.core.exceptions import ObjectDoesNotExist
|
|
6
7
|
from django.db import models
|
|
8
|
+
|
|
7
9
|
from pulpcore.plugin.models import (
|
|
8
10
|
Content,
|
|
9
|
-
Publication,
|
|
10
11
|
Distribution,
|
|
12
|
+
Publication,
|
|
11
13
|
Remote,
|
|
12
14
|
Repository,
|
|
13
15
|
)
|
|
16
|
+
from pulpcore.plugin.repo_version_utils import remove_duplicates, validate_repo_version
|
|
14
17
|
from pulpcore.plugin.responses import ArtifactResponse
|
|
15
18
|
from pulpcore.plugin.util import get_domain
|
|
16
19
|
|
|
17
|
-
from pathlib import PurePath
|
|
18
20
|
from .utils import (
|
|
21
|
+
PYPI_LAST_SERIAL,
|
|
22
|
+
PYPI_SERIAL_CONSTANT,
|
|
19
23
|
canonicalize_name,
|
|
20
24
|
get_project_metadata_from_artifact,
|
|
21
25
|
parse_project_metadata,
|
|
22
26
|
python_content_to_json,
|
|
23
|
-
PYPI_LAST_SERIAL,
|
|
24
|
-
PYPI_SERIAL_CONSTANT,
|
|
25
27
|
)
|
|
26
|
-
from pulpcore.plugin.repo_version_utils import remove_duplicates, validate_repo_version
|
|
27
28
|
|
|
28
29
|
log = getLogger(__name__)
|
|
29
30
|
|
|
@@ -1,11 +1,13 @@
|
|
|
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
|
+
|
|
9
|
+
from pulp_python.app import fields
|
|
10
|
+
from pulp_python.app.utils import DIST_EXTENSIONS
|
|
9
11
|
|
|
10
12
|
log = logging.getLogger(__name__)
|
|
11
13
|
|
|
@@ -46,7 +48,7 @@ class PackageUploadSerializer(serializers.Serializer):
|
|
|
46
48
|
action = serializers.CharField(
|
|
47
49
|
help_text=_("Defaults to `file_upload`, don't change it or request will fail!"),
|
|
48
50
|
default="file_upload",
|
|
49
|
-
source=":action"
|
|
51
|
+
source=":action",
|
|
50
52
|
)
|
|
51
53
|
sha256_digest = serializers.CharField(
|
|
52
54
|
help_text=_("SHA256 of package to validate upload integrity."),
|
|
@@ -59,17 +61,17 @@ class PackageUploadSerializer(serializers.Serializer):
|
|
|
59
61
|
"""Validates the request."""
|
|
60
62
|
action = data.get(":action")
|
|
61
63
|
if action != "file_upload":
|
|
62
|
-
raise serializers.ValidationError(
|
|
63
|
-
_("We do not support the :action {}").format(action)
|
|
64
|
-
)
|
|
64
|
+
raise serializers.ValidationError(_("We do not support the :action {}").format(action))
|
|
65
65
|
file = data.get("content")
|
|
66
66
|
for ext, packagetype in DIST_EXTENSIONS.items():
|
|
67
67
|
if file.name.endswith(ext):
|
|
68
68
|
break
|
|
69
69
|
else:
|
|
70
|
-
raise serializers.ValidationError(
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
raise serializers.ValidationError(
|
|
71
|
+
_(
|
|
72
|
+
"Extension on {} is not a valid python extension "
|
|
73
|
+
"(.whl, .exe, .egg, .tar.gz, .tar.bz2, .zip)"
|
|
74
|
+
).format(file.name)
|
|
73
75
|
)
|
|
74
76
|
sha256 = data.get("sha256_digest")
|
|
75
77
|
digests = {"sha256": sha256} if sha256 else None
|
pulp_python/app/pypi/views.py
CHANGED
|
@@ -1,53 +1,52 @@
|
|
|
1
1
|
import logging
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from rest_framework.permissions import IsAuthenticatedOrReadOnly
|
|
7
|
-
from django.core.exceptions import ObjectDoesNotExist
|
|
8
|
-
from django.shortcuts import redirect
|
|
9
|
-
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
|
|
10
6
|
|
|
11
|
-
|
|
7
|
+
import requests
|
|
12
8
|
from django.contrib.sessions.models import Session
|
|
9
|
+
from django.core.exceptions import ObjectDoesNotExist
|
|
13
10
|
from django.db import transaction
|
|
14
11
|
from django.db.utils import DatabaseError
|
|
15
12
|
from django.http.response import (
|
|
16
13
|
Http404,
|
|
17
|
-
HttpResponseForbidden,
|
|
18
14
|
HttpResponseBadRequest,
|
|
19
|
-
|
|
15
|
+
HttpResponseForbidden,
|
|
16
|
+
StreamingHttpResponse,
|
|
20
17
|
)
|
|
18
|
+
from django.shortcuts import redirect
|
|
21
19
|
from drf_spectacular.utils import extend_schema
|
|
22
20
|
from dynaconf import settings
|
|
23
|
-
from itertools import chain
|
|
24
21
|
from packaging.utils import canonicalize_name
|
|
25
|
-
from urllib.parse import urljoin, urlparse, urlunsplit
|
|
26
|
-
from pathlib import PurePath
|
|
27
22
|
from pypi_simple.parse_stream import parse_links_stream_response
|
|
23
|
+
from rest_framework.permissions import IsAuthenticatedOrReadOnly
|
|
24
|
+
from rest_framework.response import Response
|
|
25
|
+
from rest_framework.reverse import reverse
|
|
26
|
+
from rest_framework.viewsets import ViewSet
|
|
28
27
|
|
|
29
28
|
from pulpcore.plugin.tasking import dispatch
|
|
29
|
+
|
|
30
|
+
from pulp_python.app import tasks
|
|
30
31
|
from pulp_python.app.models import (
|
|
31
32
|
PythonDistribution,
|
|
32
33
|
PythonPackageContent,
|
|
33
34
|
PythonPublication,
|
|
34
35
|
)
|
|
35
36
|
from pulp_python.app.pypi.serializers import (
|
|
36
|
-
SummarySerializer,
|
|
37
37
|
PackageMetadataSerializer,
|
|
38
38
|
PackageUploadSerializer,
|
|
39
|
-
PackageUploadTaskSerializer
|
|
39
|
+
PackageUploadTaskSerializer,
|
|
40
|
+
SummarySerializer,
|
|
40
41
|
)
|
|
41
42
|
from pulp_python.app.utils import (
|
|
42
|
-
write_simple_index,
|
|
43
|
-
write_simple_detail,
|
|
44
|
-
python_content_to_json,
|
|
45
43
|
PYPI_LAST_SERIAL,
|
|
46
44
|
PYPI_SERIAL_CONSTANT,
|
|
45
|
+
python_content_to_json,
|
|
46
|
+
write_simple_detail,
|
|
47
|
+
write_simple_index,
|
|
47
48
|
)
|
|
48
49
|
|
|
49
|
-
from pulp_python.app import tasks
|
|
50
|
-
|
|
51
50
|
log = logging.getLogger(__name__)
|
|
52
51
|
|
|
53
52
|
BASE_CONTENT_URL = urljoin(settings.CONTENT_ORIGIN, settings.CONTENT_PATH_PREFIX)
|
|
@@ -133,11 +132,16 @@ class PackageUploadMixin(PyPIMixin):
|
|
|
133
132
|
if settings.PYTHON_GROUP_UPLOADS:
|
|
134
133
|
return self.upload_package_group(repo, artifact, filename, request.session)
|
|
135
134
|
|
|
136
|
-
result = dispatch(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
result = dispatch(
|
|
136
|
+
tasks.upload,
|
|
137
|
+
exclusive_resources=[artifact, repo],
|
|
138
|
+
kwargs={
|
|
139
|
+
"artifact_sha256": artifact.sha256,
|
|
140
|
+
"filename": filename,
|
|
141
|
+
"repository_pk": str(repo.pk),
|
|
142
|
+
},
|
|
143
|
+
)
|
|
144
|
+
return Response(data={"task": reverse("tasks-detail", args=[result.pk], request=None)})
|
|
141
145
|
|
|
142
146
|
def upload_package_group(self, repo, artifact, filename, session):
|
|
143
147
|
"""Steps 4 & 5, spawns tasks to add packages to index."""
|
|
@@ -150,10 +154,10 @@ class PackageUploadMixin(PyPIMixin):
|
|
|
150
154
|
try:
|
|
151
155
|
with transaction.atomic():
|
|
152
156
|
sq.first()
|
|
153
|
-
current_start = datetime.fromisoformat(session[
|
|
157
|
+
current_start = datetime.fromisoformat(session["start"])
|
|
154
158
|
if current_start >= datetime.now(tz=timezone.utc):
|
|
155
|
-
session[
|
|
156
|
-
session[
|
|
159
|
+
session["artifacts"].append((str(artifact.sha256), filename))
|
|
160
|
+
session["start"] = str(start_time)
|
|
157
161
|
session.modified = False
|
|
158
162
|
session.save()
|
|
159
163
|
else:
|
|
@@ -166,14 +170,19 @@ class PackageUploadMixin(PyPIMixin):
|
|
|
166
170
|
|
|
167
171
|
def create_group_upload_task(self, cur_session, repository, artifact, filename, start_time):
|
|
168
172
|
"""Creates the actual task that adds the packages to the index."""
|
|
169
|
-
cur_session[
|
|
170
|
-
cur_session[
|
|
173
|
+
cur_session["start"] = str(start_time)
|
|
174
|
+
cur_session["artifacts"] = [(str(artifact.sha256), filename)]
|
|
171
175
|
cur_session.modified = False
|
|
172
176
|
cur_session.save()
|
|
173
|
-
result = dispatch(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
+
result = dispatch(
|
|
178
|
+
tasks.upload_group,
|
|
179
|
+
exclusive_resources=[artifact, repository],
|
|
180
|
+
kwargs={
|
|
181
|
+
"session_pk": str(cur_session.session_key),
|
|
182
|
+
"repository_pk": str(repository.pk),
|
|
183
|
+
},
|
|
184
|
+
)
|
|
185
|
+
return reverse("tasks-detail", args=[result.pk], request=None)
|
|
177
186
|
|
|
178
187
|
|
|
179
188
|
class SimpleView(ViewSet, PackageUploadMixin):
|
|
@@ -186,21 +195,22 @@ class SimpleView(ViewSet, PackageUploadMixin):
|
|
|
186
195
|
"""Gets the simple api html page for the index."""
|
|
187
196
|
distro, repo_version, content = self.get_drvc(path)
|
|
188
197
|
if self.should_redirect(distro, repo_version=repo_version):
|
|
189
|
-
return redirect(urljoin(BASE_CONTENT_URL, f
|
|
190
|
-
names = content.order_by(
|
|
198
|
+
return redirect(urljoin(BASE_CONTENT_URL, f"{path}/simple/"))
|
|
199
|
+
names = content.order_by("name").values_list("name", flat=True).distinct().iterator()
|
|
191
200
|
return StreamingHttpResponse(write_simple_index(names, streamed=True))
|
|
192
201
|
|
|
193
202
|
def pull_through_package_simple(self, package, path, remote):
|
|
194
203
|
"""Gets the package's simple page from remote."""
|
|
204
|
+
|
|
195
205
|
def parse_url(link):
|
|
196
206
|
parsed = urlparse(link.url)
|
|
197
|
-
digest, _, value = parsed.fragment.partition(
|
|
207
|
+
digest, _, value = parsed.fragment.partition("=")
|
|
198
208
|
stripped_url = urlunsplit(chain(parsed[:3], ("", "")))
|
|
199
|
-
redirect = f
|
|
209
|
+
redirect = f"{path}/{link.text}?redirect={stripped_url}"
|
|
200
210
|
d_url = urljoin(BASE_CONTENT_URL, redirect)
|
|
201
|
-
return link.text, d_url, value if digest ==
|
|
211
|
+
return link.text, d_url, value if digest == "sha256" else ""
|
|
202
212
|
|
|
203
|
-
url = remote.get_remote_artifact_url(f
|
|
213
|
+
url = remote.get_remote_artifact_url(f"simple/{package}/")
|
|
204
214
|
kwargs = {}
|
|
205
215
|
if proxy_url := remote.proxy_url:
|
|
206
216
|
if remote.proxy_username or remote.proxy_password:
|
|
@@ -224,10 +234,10 @@ class SimpleView(ViewSet, PackageUploadMixin):
|
|
|
224
234
|
if not repo_ver or not content.filter(name__normalize=normalized).exists():
|
|
225
235
|
return self.pull_through_package_simple(normalized, path, distro.remote)
|
|
226
236
|
if self.should_redirect(distro, repo_version=repo_ver):
|
|
227
|
-
return redirect(urljoin(BASE_CONTENT_URL, f
|
|
237
|
+
return redirect(urljoin(BASE_CONTENT_URL, f"{path}/simple/{normalized}/"))
|
|
228
238
|
packages = (
|
|
229
239
|
content.filter(name__normalize=normalized)
|
|
230
|
-
.values_list(
|
|
240
|
+
.values_list("filename", "sha256", "name")
|
|
231
241
|
.iterator()
|
|
232
242
|
)
|
|
233
243
|
try:
|
|
@@ -237,12 +247,14 @@ class SimpleView(ViewSet, PackageUploadMixin):
|
|
|
237
247
|
else:
|
|
238
248
|
packages = chain([present], packages)
|
|
239
249
|
name = present[2]
|
|
240
|
-
releases = ((f, urljoin(BASE_CONTENT_URL, f
|
|
250
|
+
releases = ((f, urljoin(BASE_CONTENT_URL, f"{path}/{f}"), d) for f, d, _ in packages)
|
|
241
251
|
return StreamingHttpResponse(write_simple_detail(name, releases, streamed=True))
|
|
242
252
|
|
|
243
|
-
@extend_schema(
|
|
244
|
-
|
|
245
|
-
|
|
253
|
+
@extend_schema(
|
|
254
|
+
request=PackageUploadSerializer,
|
|
255
|
+
responses={200: PackageUploadTaskSerializer},
|
|
256
|
+
summary="Upload a package",
|
|
257
|
+
)
|
|
246
258
|
def create(self, request, path):
|
|
247
259
|
"""
|
|
248
260
|
Upload package to the index.
|
|
@@ -259,9 +271,11 @@ class MetadataView(ViewSet, PyPIMixin):
|
|
|
259
271
|
authentication_classes = []
|
|
260
272
|
permission_classes = []
|
|
261
273
|
|
|
262
|
-
@extend_schema(
|
|
263
|
-
|
|
264
|
-
|
|
274
|
+
@extend_schema(
|
|
275
|
+
tags=["Pypi: Metadata"],
|
|
276
|
+
responses={200: PackageMetadataSerializer},
|
|
277
|
+
summary="Get package metadata",
|
|
278
|
+
)
|
|
265
279
|
def retrieve(self, request, path, meta):
|
|
266
280
|
"""
|
|
267
281
|
Retrieves the package's core-metadata specified by
|
|
@@ -294,8 +308,7 @@ class PyPIView(ViewSet, PyPIMixin):
|
|
|
294
308
|
authentication_classes = []
|
|
295
309
|
permission_classes = []
|
|
296
310
|
|
|
297
|
-
@extend_schema(responses={200: SummarySerializer},
|
|
298
|
-
summary="Get index summary")
|
|
311
|
+
@extend_schema(responses={200: SummarySerializer}, summary="Get index summary")
|
|
299
312
|
def retrieve(self, request, path):
|
|
300
313
|
"""Gets package summary stats of index."""
|
|
301
314
|
distro, repo_ver, content = self.get_drvc(path)
|
|
@@ -309,9 +322,11 @@ class PyPIView(ViewSet, PyPIMixin):
|
|
|
309
322
|
class UploadView(ViewSet, PackageUploadMixin):
|
|
310
323
|
"""View for the `/legacy` upload endpoint."""
|
|
311
324
|
|
|
312
|
-
@extend_schema(
|
|
313
|
-
|
|
314
|
-
|
|
325
|
+
@extend_schema(
|
|
326
|
+
request=PackageUploadSerializer,
|
|
327
|
+
responses={200: PackageUploadTaskSerializer},
|
|
328
|
+
summary="Upload a package",
|
|
329
|
+
)
|
|
315
330
|
def create(self, request, path):
|
|
316
331
|
"""
|
|
317
332
|
Upload package to the index.
|