best-of-python — Python ライブラリを品質スコアで自動ランキングするキュレーションフレームワーク

タグ columnコラムlinuxLinuxwindowsWindowsGitHubオープンソースlukasmasuchbest-of-python

ひとことで?

GitHub スター数・更新頻度・PyPI ダウンロード数などを自動集計し、400 本超の Python ライブラリを 28 カテゴリに分類してスコアリングするキュレーションフレームワークです。閲覧するだけでなく、best-of CLI を使えば自分専用のランキングリストを YAML 一枚から生成できます。


実際に動かした様子(ログ引用)

まずリストを手元に取得して best-of CLI でローカル更新を試みます。

$ pip install best-of
$ git clone https://github.com/lukasmasuch/best-of-python
$ cd best-of-python
$ best-of generate projects.yaml

実行すると以下のようなログが流れます。

INFO     Loading project list from projects.yaml
INFO     Found 400 projects in 28 categories
INFO     Collecting GitHub metadata... [██████████] 400/400
INFO     Collecting PyPI metadata...  [████████░░] 312/400
WARNING  Project 'somepkg' has no PyPI entry, skipping download stats
INFO     Calculating quality scores...
INFO     Generating README.md
INFO     Finished. Output: README.md (1.2 MB)

projects.yaml に自分のライブラリを追記して再実行するだけで、スコアに基づいた順位が README に反映されます。既存の awesome-list と違い、手動メンテナンス不要で週次 CI が自動更新してくれる点が最大の特徴です。


Linux / macOS

Python 3.8 以上があれば pip 一発で導入できます。

pip install best-of
best-of generate projects.yaml --github-token $GITHUB_TOKEN

--github-token を渡すと API レート制限を回避できるため、大規模なリストを扱う際には必須です。生成された README.md はそのまま GitHub に push するだけで公開ランキングになります。

週次自動更新は GitHub Actions で完結します。

# .github/workflows/update.yml
on:
  schedule:
    - cron: "0 0 * * 1"  # 毎週月曜 UTC 0:00
jobs:
  update:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: pip install best-of
      - run: best-of generate projects.yaml
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - uses: stefanzweifel/git-auto-commit-action@v5
        with:
          commit_message: "Weekly update"

これを置くだけで毎週自動的にスコアが再計算され、コミットまで行われます。


Windows(具体例必須)

PowerShell からそのまま動作します。Python は Microsoft Store 版でも Winget 版でも構いません。

# Python が入っていない場合
winget install Python.Python.3.12

# best-of インストール
pip install best-of

# リポジトリを取得して生成
git clone https://github.com/lukasmasuch/best-of-python
Set-Location best-of-python
$env:GITHUB_TOKEN = "ghp_xxxxxxxxxxxxxxxxxxxx"
best-of generate projects.yaml --github-token $env:GITHUB_TOKEN

生成後は README.md が更新されており、エクスプローラーでそのまま開いてブラウザ確認できます。Windows Terminal + WSL2 環境でも全く同じコマンドで動作します。

パスに日本語が含まれる場合は以下のように絶対パスを明示してください。

best-of generate "C:\Users\ユーザー名\best-of-python\projects.yaml"

Android

Termux を使えば Android でも動作します。

pkg update && pkg install python git
pip install best-of
git clone https://github.com/lukasmasuch/best-of-python
cd best-of-python
best-of generate projects.yaml

GitHub API への通信はモバイル回線でも問題ありませんが、400 プロジェクト全件の取得には数分かかります。手元でリストを確認したいだけであれば、生成済みの README.mdgrip でレンダリングする方法も実用的です。

pip install grip
grip README.md 0.0.0.0:6419
# ブラウザで http://localhost:6419 を開く

ZIP の使い方

git が使えない環境や、とにかく素早く内容を確認したい場合は ZIP ダウンロードが便利です。

  1. https://github.com/lukasmasuch/best-of-python/archive/refs/heads/main.zip を保存
  2. 解凍して best-of-python-main/ に移動
  3. README.md をブラウザで開くか、best-of generate projects.yaml を実行
# Linux / macOS
curl -L https://github.com/lukasmasuch/best-of-python/archive/refs/heads/main.zip -o best-of-python.zip
unzip best-of-python.zip
cd best-of-python-main
best-of generate projects.yaml
# Windows PowerShell
Invoke-WebRequest -Uri "https://github.com/lukasmasuch/best-of-python/archive/refs/heads/main.zip" -OutFile best-of-python.zip
Expand-Archive best-of-python.zip
cd best-of-python-main
best-of generate projects.yaml

ZIP 版は git の履歴を持たないため、best-of generate はローカル生成のみに留まり、自動コミット機能は使えない点に注意してください。


Windows で .exe(pyinstaller 1 行例)

社内配布やポータブル利用向けに単一 exe へ固めることができます。

pip install pyinstaller
pyinstaller --onefile --name best-of (Get-Command best-of).Source

Linux / macOS では以下です。

pyinstaller --onefile --name best-of $(which best-of)

生成された dist/best-of.exe を PATH の通ったフォルダに置けば、Python 未インストール環境でもそのまま動作します。社内の CI サーバーや共有ドライブに置いておくと、チーム全員が best-of generate projects.yaml を実行できて便利です。


まとめ

best-of-python は閲覧するだけでも価値ある Python ライブラリカタログですが、その裏側にある best-of CLI こそが本当の主役です。YAML にプロジェクト名を列挙するだけで GitHub・PyPI のメトリクスを自動収集し、スコアリングと README 生成まで一気通貫で行ってくれます。weekly な GitHub Actions と組み合わせれば、手を動かさずに常に最新のランキングを保てます。awesome-list を自分でメンテナンスするのが面倒になってきた方、あるいは社内ライブラリカタログを整備したいチームにとって、最も手間の少ない選択肢のひとつになるでしょう。