Skip to content

Commit 068ad79

Browse files
committed
Add support for relative URLs to packages
pypi.org returns absolute URLs, but some servers might return relative ones.
1 parent 22abd87 commit 068ad79

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.py[co]
22
/.coverage
3+
/cache
34
/dist

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ test:
77

88
.PHONY: start-dev
99
start-dev:
10-
PYPI_BROWSER_DEBUG=1 poetry run uvicorn --reload --port 5000 pypi_browser.app:app
10+
PYPI_BROWSER_DEBUG=1 PYPI_BROWSER_PACKAGE_CACHE_PATH=$(CURDIR)/cache poetry run uvicorn --reload --port 5000 pypi_browser.app:app

pypi_browser/pypi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import itertools
55
import os.path
66
import typing
7+
import urllib.parse
78

89
import aiofiles.os
910
import httpx
@@ -83,7 +84,7 @@ async def downloaded_file_path(config: PyPIConfig, package: str, filename: str)
8384
# matching file.
8485
for file_ in itertools.chain.from_iterable(metadata['releases'].values()):
8586
if file_['filename'] == filename:
86-
url = file_['url']
87+
url = urllib.parse.urljoin(config.pypi_url, file_['url'])
8788
break
8889
else:
8990
raise CannotFindFileError(package, filename)

0 commit comments

Comments
 (0)