Created
October 19, 2025 12:31
-
-
Save LCamel/866c38f861bca12460c000947bd4275f to your computer and use it in GitHub Desktop.
find hls by ghc version
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
| #!/usr/bin/env python3 | |
| # % python3 hls.py 9.8.4 | grep -i Unknown | |
| # "2.10.0.0", "A_64", "Linux_UnknownLinux" | |
| # "2.10.0.0", "A_ARM64", "Linux_UnknownLinux" | |
| # "2.11.0.0", "A_64", "Linux_UnknownLinux" | |
| # "2.11.0.0", "A_ARM64", "Linux_UnknownLinux" | |
| import sys | |
| import json | |
| import urllib.request | |
| def main(): | |
| if len(sys.argv) != 2: | |
| print("Usage: python find_hls_for_ghc.py <ghc_version>") | |
| print("Example: python find_hls_for_ghc.py 9.12.2") | |
| sys.exit(1) | |
| ghc_version = sys.argv[1] | |
| url = "https://raw.githubusercontent.com/haskell/ghcup-metadata/master/hls-metadata-0.0.1.json" | |
| try: | |
| with urllib.request.urlopen(url) as response: | |
| data = json.loads(response.read()) | |
| except Exception as e: | |
| print(f"Error fetching data: {e}", file=sys.stderr) | |
| sys.exit(1) | |
| # keep JSON order | |
| for hls_version, archs in data.items(): | |
| for arch, dists in archs.items(): | |
| for dist, ghc_versions in dists.items(): | |
| if ghc_version in ghc_versions: | |
| print(f'"{hls_version}", "{arch}", "{dist}"') | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment