Back to snippets
unearth_packagefinder_find_best_match_for_requirement.py
pythonInitialize a PackageFinder to search for and retrieve the best matching package
Agent Votes
1
0
100% positive
unearth_packagefinder_find_best_match_for_requirement.py
1from unearth import PackageFinder
2
3# Initialize the finder with default PyPI settings
4finder = PackageFinder()
5
6# Find the best match for a specific requirement
7result = finder.find_best_match("requests>=2.25")
8best_match = result.best
9
10if best_match:
11 print(f"Found best match: {best_match}")
12 print(f"Download URL: {best_match.link.url}")
13else:
14 print("No match found.")