File tree Expand file tree Collapse file tree 6 files changed +16
-5
lines changed
Expand file tree Collapse file tree 6 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 1+ Added new setting PYPI_PATH_PREFIX to allow for customizing the path prefix for the PyPI API.
Original file line number Diff line number Diff line change 1313> This specifies the hostname where the PyPI API is served. It defaults to the fully qualified
1414> hostname of the system where the process is running. This needs to be adjusted if running behind
1515> a non local reverse proxy.
16+
17+ ## PYPI_PATH_PREFIX
18+
19+ > This specifies where the PyPI endpoints can be found at. It defaults to ` /pypi/ ` . The value is
20+ > used along with ` PYPI_API_HOSTNAME ` to generate the links to the PyPI endpoints and should start
21+ > and end in a slash.
Original file line number Diff line number Diff line change 5959
6060ORIGIN_HOST = settings .CONTENT_ORIGIN if settings .CONTENT_ORIGIN else settings .PYPI_API_HOSTNAME
6161BASE_CONTENT_URL = urljoin (ORIGIN_HOST , settings .CONTENT_PATH_PREFIX )
62- BASE_API_URL = urljoin (settings .PYPI_API_HOSTNAME , "pypi/" )
62+ BASE_API_URL = urljoin (settings .PYPI_API_HOSTNAME , settings . PYPI_PATH_PREFIX )
6363
6464PYPI_SIMPLE_V1_HTML = "application/vnd.pypi.simple.v1+html"
6565PYPI_SIMPLE_V1_JSON = "application/vnd.pypi.simple.v1+json"
Original file line number Diff line number Diff line change 99from rest_framework import serializers
1010from pypi_attestations import AttestationError
1111from pydantic import TypeAdapter , ValidationError
12+ from urllib .parse import urljoin
1213
1314from pulpcore .plugin import models as core_models
1415from pulpcore .plugin import serializers as core_serializers
3132)
3233
3334log = logging .getLogger (__name__ )
35+ PYPI_BASE_URL = urljoin (settings .PYPI_API_HOSTNAME , settings .PYPI_PATH_PREFIX )
3436
3537
3638@extend_schema_serializer (
@@ -92,8 +94,8 @@ class PythonDistributionSerializer(core_serializers.DistributionSerializer):
9294 def get_base_url (self , obj ):
9395 """Gets the base url."""
9496 if settings .DOMAIN_ENABLED :
95- return f"{ settings . PYPI_API_HOSTNAME } /pypi/ { get_domain ().name } /{ obj .base_path } /"
96- return f"{ settings . PYPI_API_HOSTNAME } /pypi/ { obj .base_path } /"
97+ return urljoin ( PYPI_BASE_URL , f"{ get_domain ().name } /{ obj .base_path } /" )
98+ return urljoin ( PYPI_BASE_URL , f"{ obj .base_path } /" )
9799
98100 class Meta :
99101 fields = core_serializers .DistributionSerializer .Meta .fields + (
Original file line number Diff line number Diff line change 22
33PYTHON_GROUP_UPLOADS = False
44PYPI_API_HOSTNAME = "https://" + socket .getfqdn ()
5+ PYPI_PATH_PREFIX = "/pypi/"
56
67DRF_ACCESS_POLICY = {
78 "dynaconf_merge_unique" : True ,
Original file line number Diff line number Diff line change 1010)
1111
1212if settings .DOMAIN_ENABLED :
13- PYPI_API_URL = "pypi /<slug:pulp_domain>/<path:path>/"
13+ PYPI_API_URL = "/<slug:pulp_domain>/<path:path>/"
1414else :
15- PYPI_API_URL = "pypi/<path:path>/"
15+ PYPI_API_URL = "/<path:path>/"
16+ PYPI_API_URL = settings .PYPI_PATH_PREFIX .strip ("/" ) + PYPI_API_URL
1617# TODO: Implement remaining PyPI endpoints
1718# path("project/", PackageProject.as_view()), # Endpoints to nicely see contents of index
1819# path("search/", PackageSearch.as_view()),
You can’t perform that action at this time.
0 commit comments