@@ -79,24 +79,24 @@ def CURLBIN :=
7979 -- change file name if we ever need a more recent version to trigger re-download
8080 IO.CACHEDIR / s! "curl-{ CURLVERSION} "
8181
82- /-- leantar version at https://github.com/digama0/leangz -/
83- def LEANTARVERSION :=
84- "0.1.17"
85-
8682def EXE := if System.Platform.isWindows then ".exe" else ""
8783
88- def LEANTARBIN :=
89- -- change file name if we ever need a more recent version to trigger re-download
90- IO.CACHEDIR / s! "leantar-{ LEANTARVERSION}{ EXE} "
91-
9284def LAKEPACKAGESDIR : FilePath :=
9385 ".lake" / "packages"
9486
9587def getCurl : IO String := do
9688 return if (← CURLBIN.pathExists) then CURLBIN.toString else "curl"
9789
98- def getLeanTar : IO String := do
99- return if (← LEANTARBIN.pathExists) then LEANTARBIN.toString else "leantar"
90+ /-- Path to the `leantar` binary bundled with the Lean toolchain.
91+ This has been bundled since `nightly-2026-03-09` (lean4#12822). -/
92+ private initialize leantarSysrootBin : String ← do
93+ let out ← IO.Process.output { cmd := "lean" , args := #["--print-prefix" ] }
94+ if out.exitCode == 0 then
95+ let path : FilePath := out.stdout.trimAscii.toString / "bin" / s! "leantar{ EXE} "
96+ if ← path.pathExists then return path.toString
97+ throw <| IO.userError "leantar not found in Lean sysroot. This toolchain may predate nightly-2026-03-09."
98+
99+ def getLeanTar : IO String := return leantarSysrootBin
100100
101101/-- Spawn a `leantar` process for decompression, writing the given JSON config to its stdin.
102102 Returns the process exit code. -/
@@ -238,45 +238,6 @@ def validateCurl : IO Bool := do
238238 | _ => throw <| IO.userError "Invalidly formatted version of `curl`"
239239 | _ => throw <| IO.userError "Invalidly formatted response from `curl --version`"
240240
241- def Version := Nat × Nat × Nat
242- deriving Inhabited, DecidableEq
243-
244- instance : Ord Version := let _ := @lexOrd; lexOrd
245- instance : LE Version := leOfOrd
246-
247- def parseVersion (s : String) : Option Version := do
248- let [maj, min, patch] := s.trimAscii.toString.splitOn "." | none
249- some (← String.toNat? maj, ← String.toNat? min, ← String.toNat? patch)
250-
251- def validateLeanTar : IO Unit := do
252- if (← LEANTARBIN.pathExists) then return
253- if let some version ← some <$> runCmd "leantar" #["--version" ] <|> pure none then
254- let "leantar" :: v :: _ := version.splitOn " "
255- | throw <| IO.userError "Invalidly formatted response from `leantar --version`"
256- let some v := parseVersion v | throw <| IO.userError "Invalidly formatted version of `leantar`"
257- -- currently we need exactly one version of leantar, change this to reflect compatibility
258- if v = (parseVersion LEANTARVERSION).get! then return
259- let win := System.Platform.getIsWindows ()
260- let target ← if win then
261- pure "x86_64-pc-windows-msvc"
262- else
263- let mut arch ← (·.trimAscii.copy) <$> runCmd "uname" #["-m" ] false
264- if arch = "arm64" then arch := "aarch64"
265- unless arch ∈ ["x86_64" , "aarch64" ] do
266- throw <| IO.userError s! "unsupported architecture { arch} "
267- pure <|
268- if System.Platform.getIsOSX () then s! "{ arch} -apple-darwin"
269- else s! "{ arch} -unknown-linux-musl"
270- IO.println s! "installing leantar { LEANTARVERSION} "
271- IO.FS.createDirAll IO.CACHEDIR
272- let ext := if win then "zip" else "tar.gz"
273- let _ ← runCmd "curl" (stderrAsErr := false ) #[
274- s! "https://github.com/digama0/leangz/releases/download/v{ LEANTARVERSION} /leantar-v{ LEANTARVERSION} -{ target} .{ ext} " ,
275- "-L" , "-o" , s! "{ LEANTARBIN} .{ ext} " ]
276- let _ ← runCmd "tar" #["-xf" , s! "{ LEANTARBIN} .{ ext} " ,
277- "-C" , IO.CACHEDIR.toString, "--strip-components=1" ]
278- IO.FS.rename (IO.CACHEDIR / s! "leantar{ EXE} " ).toString LEANTARBIN.toString
279-
280241/-- Recursively gets all files from a directory with a certain extension -/
281242partial def getFilesWithExtension
282243 (fp : FilePath) (extension : String) (acc : Array FilePath := #[]) :
0 commit comments