Merge pull request #119126 from fabaff/pycomfoconnect
[NixPkgs.git] / pkgs / development / compilers / julia / update-1.5.py
blobe37f37d456bf703396bd883ba5e239a1461e2c96
1 #!/usr/bin/env nix-shell
2 #!nix-shell -i python3 -p python3 python3Packages.requests
4 import os
5 import re
6 import requests
7 import subprocess
9 latest = requests.get("https://api.github.com/repos/JuliaLang/julia/releases/latest").json()["tag_name"]
10 assert latest[0] == "v"
11 major, minor, patch = latest[1:].split(".")
12 assert major == "1"
13 # When a new minor version comes out we'll have to refactor/copy this update script.
14 assert minor == "5"
16 sha256 = subprocess.check_output(["nix-prefetch-url", "--unpack", f"https://github.com/JuliaLang/julia/releases/download/v{major}.{minor}.{patch}/julia-{major}.{minor}.{patch}-full.tar.gz"], text=True).strip()
18 nix_path = os.path.join(os.path.dirname(__file__), "1.5.nix")
19 nix0 = open(nix_path, "r").read()
20 nix1 = re.sub("maintenanceVersion = \".*\";", f"maintenanceVersion = \"{patch}\";", nix0)
21 nix2 = re.sub("src_sha256 = \".*\";", f"src_sha256 = \"{sha256}\";", nix1)
22 open(nix_path, "w").write(nix2)