From d492cf3bb6bd42c731e2ca99a3673f6a939bddca Mon Sep 17 00:00:00 2001 From: Student Main Date: Fri, 18 Oct 2024 16:58:19 +0000 Subject: [PATCH 1/3] docs: add documentation for pypi --- docs/source/appendix.rst | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/docs/source/appendix.rst b/docs/source/appendix.rst index aa58880..6836d85 100644 --- a/docs/source/appendix.rst +++ b/docs/source/appendix.rst @@ -24,23 +24,25 @@ Supported VCS Acceptable Prefixes for ``SRCS`` -------------------------------- -+--------+------------------------------------+---------------------+-----------+ -| Prefix | Source Type | Auto deduction [1]_ | Notes | -+--------+------------------------------------+---------------------+-----------+ -| git | Git (VCS) | Yes | | -+--------+------------------------------------+---------------------+-----------+ -| hg | Mercurial (VCS) | No | | -+--------+------------------------------------+---------------------+-----------+ -| svn | Subversion (VCS) | No | | -+--------+------------------------------------+---------------------+-----------+ -| bzr | Baazar (VCS) | No | | -+--------+------------------------------------+---------------------+-----------+ -| fossil | Fossil (VCS) | No | | -+--------+------------------------------------+---------------------+-----------+ -| tbl | Tarball Archives (Remote Files) | Partial | [2]_ [4]_ | -+--------+------------------------------------+---------------------+-----------+ -| file | Opaque Binary Blobs (Remote Files) | No | [3]_ | -+--------+------------------------------------+---------------------+-----------+ ++--------+-----------------------------------------+---------------------+-----------+ +| Prefix | Source Type | Auto deduction [1]_ | Notes | ++--------+-----------------------------------------+---------------------+-----------+ +| git | Git (VCS) | Yes | | ++--------+-----------------------------------------+---------------------+-----------+ +| hg | Mercurial (VCS) | No | | ++--------+-----------------------------------------+---------------------+-----------+ +| svn | Subversion (VCS) | No | | ++--------+-----------------------------------------+---------------------+-----------+ +| bzr | Baazar (VCS) | No | | ++--------+-----------------------------------------+---------------------+-----------+ +| fossil | Fossil (VCS) | No | | ++--------+-----------------------------------------+---------------------+-----------+ +| tbl | Tarball Archives (Remote Files) | Partial | [2]_ [4]_ | ++--------+-----------------------------------------+---------------------+-----------+ +| file | Opaque Binary Blobs (Remote Files) | No | [3]_ | ++--------+-----------------------------------------+---------------------+-----------+ +| pypi | PyPI Package Source Code (Remote Files) | No | | ++--------+-----------------------------------------+---------------------+-----------+ Supported Checksum (Hashing) Algorithm -------------------------------------- From dc324dc506eb2986535023a12acbf731d0317cd6 Mon Sep 17 00:00:00 2001 From: Student Main Date: Fri, 18 Oct 2024 17:37:51 +0000 Subject: [PATCH 2/3] fix(acbs/utils.py): support update checksum for pypi --- acbs/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acbs/utils.py b/acbs/utils.py index 0281a3e..8c0e9e6 100644 --- a/acbs/utils.py +++ b/acbs/utils.py @@ -355,7 +355,7 @@ def calculate_checksum(o: ACBSSourceInfo): sums = [] formatter = ' ' if len(info) < 2 else ' \\\n ' for i in info: - if i.type in ('tarball', 'file'): + if i.type in ('tarball', 'file', 'pypi'): i = calculate_checksum(i) sums.append('::'.join(i.chksum)) else: From aad8b87275b77ec692c7f9a6b3804ac00a535474 Mon Sep 17 00:00:00 2001 From: Student Main Date: Wed, 23 Oct 2024 15:19:25 +0000 Subject: [PATCH 3/3] fetch: use pypi.io download url instead of query url with pypi.org api --- acbs/fetch.py | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/acbs/fetch.py b/acbs/fetch.py index dd03403..5d67918 100644 --- a/acbs/fetch.py +++ b/acbs/fetch.py @@ -131,25 +131,8 @@ def tarball_processor(package: ACBSPackageInfo, index: int, source_name: str) -> def pypi_fetch(info: ACBSSourceInfo, source_location: str, name: str) -> Optional[ACBSSourceInfo]: - # https://warehouse.pypa.io/api-reference/json.html#release - api = f"/pypi/{info.url}/{info.revision}/json" - logging.info(f"Querying PyPI API endpoint for source URL...") - conn = http.client.HTTPSConnection("pypi.org") - conn.request("GET", api) - response = conn.getresponse() - if response.status != 200: - logging.error(f"Got response {response.status}") - raise RuntimeError("Failed to query PyPI API endpoint") - result = json.load(response) - - actual_url = "" - for r in result["urls"]: - if r["packagetype"] == "sdist": - actual_url = r["url"] - break - if actual_url == "": - raise RuntimeError("Can't find source URL") - logging.info(f"Source URL is {actual_url}") + pfx = info.url[0] + actual_url = f"https://pypi.io/packages/source/{pfx}/{info.url}/{info.url}-{info.revision}.tar.gz" ext = guess_extension_name(actual_url) full_path = os.path.join(source_location, name + ext)