Skip to content

Commit

Permalink
Switch to using Artifacts.toml for binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Apr 10, 2024
1 parent 7d6de73 commit 457801f
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 69 deletions.
32 changes: 32 additions & 0 deletions Artifacts.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[[PATHSolver]]
git-tree-sha1 = "ad0dc8bbf95cc578b4fdcd8343cf30ae787b9e23"
arch = "x86_64"
os = "linux"

[[PATHSolver.download]]
sha256 = "4010567a30a8cc0167f9fcaa44f24fc7bdb62345f55de9271f5616b6b2f7b20f"
url = "https://github.com/chkwon/PATHSolver.jl/releases/download/v5.0.3-path-binaries/x86_64-linux-gnu.tar.bz2"
[[PATHSolver]]
git-tree-sha1 = "25708f6f152ddbb1c4800f19b9c65ea9b6d8c27d"
arch = "x86_64"
os = "macos"

[[PATHSolver.download]]
sha256 = "49c27eb65d0fa6b18c051ad28809fbc0b5a436ff0cd4a8591c43f042c9140f69"
url = "https://github.com/chkwon/PATHSolver.jl/releases/download/v5.0.3-path-binaries/x86_64-apple-darwin.tar.bz2"
[[PATHSolver]]
git-tree-sha1 = "95592e56c188b48b217594bfbc4ffb774b7c7a9f"
arch = "aarch64"
os = "macos"

[[PATHSolver.download]]
sha256 = "b08c1c2f350edf806f67876caf8befd4736738f8f85cb9f4cf019d09fbc47dd5"
url = "https://github.com/chkwon/PATHSolver.jl/releases/download/v5.0.3-path-binaries/aarch64-apple-darwin.tar.bz2"
[[PATHSolver]]
git-tree-sha1 = "817a91944b44805dfdd817629eed4157b67e43b5"
arch = "x86_64"
os = "windows"

[[PATHSolver.download]]
sha256 = "e7d309770cb426ca190470ce638cdaa5bd702b448b11400d8ef3e94d8eef81a2"
url = "https://github.com/chkwon/PATHSolver.jl/releases/download/v5.0.3-path-binaries/x86_64-w64-mingw32.tar.bz2"
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ authors = ["Changhyun Kwon <[email protected]>", "Oscar Dowson <[email protected]
version = "1.7.4"

[deps]
DataDeps = "124859b0-ceae-595e-8997-d05f6a7a8dfe"
LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
DataDeps = "0.7"
LazyArtifacts = "1.6"
MathOptInterface = "1.19"
SparseArrays = "<0.0.1, 1.6"
Test = "<0.0.1, 1.6"
Expand Down
5 changes: 5 additions & 0 deletions binaries/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.tar.bz2
aarch64-apple-darwin
x86_64-apple-darwin
x86_64-linux-gnu
x86_64-w64-mingw32
5 changes: 5 additions & 0 deletions binaries/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[deps]
Inflate = "d25df0c9-e2be-5dd7-82c8-3ad0b3e990b9"
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
Tar = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
41 changes: 41 additions & 0 deletions binaries/script.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright (c) 2024 Oscar Dowson, and contributors
#
# Use of this source code is governed by an MIT-style license that can be found
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.

using Tar, Inflate, SHA, TOML

function get_artifact(data)
dir = "$(data.arch)-$(data.platform)"
filename = "$(dir).tar.bz2"
run(`tar -cjf $filename $dir`)
url = "https://github.com/chkwon/PATHSolver.jl/releases/download/v5.0.3-path-binaries/$filename"
ret = Dict(
"git-tree-sha1" => Tar.tree_hash(`gzcat $filename`),
"arch" => data.arch,
"os" => data.os,
"download" => Any[
Dict("sha256" => bytes2hex(open(sha256, filename)), "url" => url),
]
)
return ret
end

function main()
platforms = [
(os = "linux", arch = "x86_64", platform = "linux-gnu"),
(os = "macos", arch = "x86_64", platform = "apple-darwin"),
(os = "macos", arch = "aarch64", platform = "apple-darwin"),
(os = "windows", arch = "x86_64", platform = "w64-mingw32"),
]
output = Dict("PATHSolver" => get_artifact.(platforms))
open(joinpath(dirname(@__DIR__), "Artifacts.toml"), "w") do io
return TOML.print(io, output)
end
return
end

# julia --project=scripts scripts/update_artifacts.jl
#
# Update the Artifacts.toml file.
main()
79 changes: 12 additions & 67 deletions src/PATHSolver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,85 +5,30 @@

module PATHSolver

import DataDeps
import LazyArtifacts
import MathOptInterface as MOI
import SparseArrays

function __init__()
platform = if Sys.iswindows()
"windows"
function _get_artifact_path(filename)
root = LazyArtifacts.artifact"PATHSolver"
if Sys.iswindows()
return joinpath(root, "x86_64-w64-mingw32", "$filename.dll")
elseif Sys.isapple()
Sys.ARCH == :aarch64 ? "silicon" : "macos"
return joinpath(root, "$(Sys.ARCH)-apple-darwin", "$filename.dylib")
elseif Sys.islinux()
"linux"
return joinpath(root, "x86_64-linux-gnu", "$filename.so")
else
error("Unsupported platform.")
end
libpath = Dict(
"windows" => (
"path50.dll",
"e227d19109f56628fccfdfedd7ecbdfd1667a3c975dd1d16a160a69d374d5474",
),
"macos" => (
"libpath50.dylib",
"8787de93d21f49a46146ebe2ef5844d1c20a80f934a85f60164f9ddc670412f8",
),
"silicon" => (
"libpath50.silicon.dylib",
"4e667615180565062013ab50a3968bbeddf3e510a9cdbfc27aa685152742b637",
),
"linux" => (
"libpath50.so",
"8c36baaea0952729788ec8d964253305b04b0289a1d74ca5606862c9ddb8f2fd",
),
)
libpath_filename, libpath_sha256 = libpath[platform]
DataDeps.register(
DataDeps.DataDep(
"libpath50",
"The libpath50 binary from http://pages.cs.wisc.edu/~ferris",
"http://pages.cs.wisc.edu/~ferris/path/julia/$(libpath_filename)",
libpath_sha256,
),
)
lusol = Dict(
"windows" => (
"lusol.dll",
"2e1f0ed17914ddcf1b833898731ff4b85afab0cf914e0707dcff9e4e995cebd8",
),
"macos" => (
"liblusol.dylib",
"52d631fd3d753581c62d5b4b636e9cb3f8cc822738fe34c6879443d5b5092f12",
),
"silicon" => (
"liblusol.silicon.dylib",
"24113f8730cdaa567c70eee36209720e37ade6080dc62bfd5ee873da0357b88d",
),
"linux" => (
"liblusol.so",
"ca87167853cdac9d4697a51a588d13ed9a7c093219743efa1d250cb62ac3dcb7",
),
)
liblusol_filename, liblusol_sha256 = lusol[platform]
DataDeps.register(
DataDeps.DataDep(
"liblusol",
"The lusol binary for use with PATH from http://pages.cs.wisc.edu/~ferris",
"http://pages.cs.wisc.edu/~ferris/path/julia/$(liblusol_filename)",
liblusol_sha256,
),
)
end

function __init__()
if haskey(ENV, "PATH_JL_LOCATION")
global PATH_SOLVER = ENV["PATH_JL_LOCATION"]
global LUSOL_LIBRARY_PATH = ""
else
current = get(ENV, "DATADEPS_ALWAYS_ACCEPT", "false")
ENV["DATADEPS_ALWAYS_ACCEPT"] = "true"
global PATH_SOLVER =
joinpath(DataDeps.datadep"libpath50", libpath_filename)
global LUSOL_LIBRARY_PATH =
joinpath(DataDeps.datadep"liblusol", liblusol_filename)
ENV["DATADEPS_ALWAYS_ACCEPT"] = current
global PATH_SOLVER = _get_artifact_path("libpath")
global LUSOL_LIBRARY_PATH = _get_artifact_path("liblusol")
end
return
end
Expand Down

0 comments on commit 457801f

Please sign in to comment.