Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use pypi.io url instead of api, support update checksum for pypi, add doc #33

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions acbs/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion acbs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
36 changes: 19 additions & 17 deletions docs/source/appendix.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------------------------------
Expand Down
Loading