Last active
December 8, 2025 19:09
-
-
Save henryiii/28784b468a4f69a920c6492d98251d64 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| # Regex to capture markers with comparison operators | |
| pattern = re.compile(r"\b([a-zA-Z0-9_]+)\s*(>=|<=|>|<)\s*['\"]?[^'\"\s]+['\"]?") | |
| def find_non_version_markers(line): | |
| marker = line.split(";", 1)[1].strip() | |
| if match := pattern.search(marker): | |
| # if not match.group(1).endswith(("_version", "_release")): | |
| if match.group(1).endswith("_release"): | |
| return True | |
| return False | |
| found = [] | |
| with open("requires_dist.txt", encoding="utf-8") as f: | |
| for line in f: | |
| line = line.strip() | |
| if ";" in line and find_non_version_markers(line): | |
| found.append(line) | |
| print(*found, sep="\n") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # /// script | |
| # dependencies = ["packaging"] | |
| # /// | |
| import sqlite3 | |
| from packaging.version import Version | |
| con = sqlite3.connect("pypi-data.sqlite") | |
| cur = con.cursor() | |
| rows = cur.execute(""" | |
| SELECT name, version, requires_dist | |
| FROM projects | |
| WHERE requires_dist LIKE '%platform_version%' | |
| """).fetchall() | |
| best = {} # name -> (name, version, requires_dist) | |
| for name, version, requires_dist in rows: | |
| if name not in best or Version(version) > Version(best[name][1]): | |
| best[name] = (name, version, requires_dist) | |
| # Convert dict → list for use | |
| results = list(best.values()) | |
| for r in results: | |
| print(*r) | |
| print() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import sqlite3 | |
| # connect to your database | |
| conn = sqlite3.connect("pypi-data.sqlite") | |
| cur = conn.cursor() | |
| # run the query | |
| cur.execute(""" | |
| SELECT requires_dist | |
| FROM projects | |
| WHERE requires_dist LIKE '%;%' | |
| """) | |
| values = {val for (value,) in cur for val in json.loads(value)} | |
| # write each value to a file, exactly as-is | |
| with open("requires_dist2.txt", "w", encoding="utf-8") as f: | |
| for value in values: | |
| f.write(value + "\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment