Skip to content

Fix download statistics #706

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
20 changes: 10 additions & 10 deletions pythonbuild/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import urllib.request
import zipfile

import github
import yaml
import zstandard

Expand Down Expand Up @@ -653,21 +654,20 @@ def validate_python_json(info, extension_modules):


def release_download_statistics(mode="by_asset"):
with urllib.request.urlopen(
"https://api.github.com/repos/astral-sh/python-build-standalone/releases"
) as fh:
data = json.load(fh)

by_tag = collections.Counter()
by_build = collections.Counter()
by_build_install_only = collections.Counter()

for release in data:
tag = release["tag_name"]
# Default paging settings time out. Reduce page size as a workaround.
gh = github.Github(per_page=5)

repo = gh.get_repo("astral-sh/python-build-standalone")
for release in repo.get_releases():
tag = release.tag_name

for asset in release["assets"]:
name = asset["name"]
count = asset["download_count"]
for asset in release.assets:
name = asset.name
count = asset.download_count

by_tag[tag] += count

Expand Down
1 change: 1 addition & 0 deletions requirements.dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

ruff
mypy
PyGithub
types-jsonschema
types-PyYAML
types-jinja2
Loading
Loading