Skip to content

Instantly share code, notes, and snippets.

@bennuttall
Created June 23, 2025 10:09
Show Gist options
  • Select an option

  • Save bennuttall/ec13e0541d998614ac18bdb286fd77ca to your computer and use it in GitHub Desktop.

Select an option

Save bennuttall/ec13e0541d998614ac18bdb286fd77ca to your computer and use it in GitHub Desktop.
from pathlib import Path
import csv
import logging
from piwheels_wheel import Wheel # requires new version currently in PR
from piwheels.master.db import Database
db = Database("postgresql:///piwheels")
simple = Path("/home/piwheels/www/simple")
csv_file = Path("/home/piwheels/pip_deps.csv")
packages = db.get_all_packages()
for package in packages:
file_deps = []
package_dir = simple / package
files = db.get_package_files(package)
for file in files:
file_path = package_dir / file
if not file_path.exists():
logging.warning(f"File {file_path} does not exist, skipping")
continue
try:
wheel = Wheel(file_path)
except Exception as e:
logging.warning(f"Error processing {file}: {e}")
continue
pip_deps = wheel.pip_dependencies
if pip_deps:
file_deps.append((file, pip_deps))
if file_deps:
print(package)
with csv_file.open("a", newline="\n") as f:
writer = csv.writer(f)
for file, deps in file_deps:
for dep in deps:
writer.writerow((file, "pip", dep))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment