Skip to content

Instantly share code, notes, and snippets.

@pawamoy
Last active April 2, 2024 19:53
Show Gist options
  • Save pawamoy/4d573561a59197a97283ba8a31a27ded to your computer and use it in GitHub Desktop.
Save pawamoy/4d573561a59197a97283ba8a31a27ded to your computer and use it in GitHub Desktop.
Print funding URLs of installed Python packages
from importlib.metadata import distributions
funding_keywords = {"donate", "funding", "tidelift"}
def print_funding_urls():
for package in distributions():
funding_urls = []
for line in package.metadata.get_all("Project-URL", []):
title, url = line.split(", ", 1)
if title.lower() in funding_keywords:
funding_urls.append(url)
if funding_urls:
print(f"{package.metadata['Name']}: {', '.join(funding_urls)}")
if __name__ == "__main__":
print_funding_urls()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment