Skip to content

Commit c75586f

Browse files
authored
Merge pull request #5108 from google/julia/bins
Update ORToolsBinaries to 0.1.0
2 parents d30f5b4 + f03ab69 commit c75586f

File tree

3 files changed

+36
-13
lines changed

3 files changed

+36
-13
lines changed
File renamed without changes.

ortools/julia/ORToolsBinaries.jl/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ORToolsBinaries"
22
uuid = "594ad865-6a17-49ee-8f22-76ed020c7c08"
3-
version = "0.0.1"
3+
version = "0.1.0"
44

55
[deps]
66
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"

ortools/julia/ORToolsBinaries.jl/deps/build.jl

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ const TARGET_PACKAGES = Dict{String, String}(
2222

2323
const DEPS_DIR = @__DIR__
2424

25-
println("WARNING: if ORTools_jll provides binaries for your platform, prefer using them rather than this package.")
25+
println("WARNING: if ORTools_jll provides binaries for your platform, " *
26+
"prefer using them rather than this package.")
2627
println()
2728
println("Downloading and installing a precompiled version of OR-Tools...")
28-
println("BASE_URL: $BASE_URL, ORTOOLS_MINOR_VERSION: $ORTOOLS_MINOR_VERSION, ORTOOLS_PATCH_VERSION: $ORTOOLS_PATCH_VERSION")
29+
println("BASE_URL: $BASE_URL, ORTOOLS_MINOR_VERSION: " *
30+
"$ORTOOLS_MINOR_VERSION, ORTOOLS_PATCH_VERSION: " *
31+
"$ORTOOLS_PATCH_VERSION")
2932

3033
key = "unknown"
3134
if Sys.islinux()
@@ -54,36 +57,49 @@ elseif Sys.iswindows()
5457
end
5558
end
5659

57-
println("Sys.islinux: $(Sys.islinux()), Sys.isapple: $(Sys.isapple()), Sys.iswindows: $(Sys.iswindows()), Sys.ARCH: $(Sys.ARCH)")
60+
println("Sys.islinux: $(Sys.islinux()), Sys.isapple: $(Sys.isapple()), " *
61+
"Sys.iswindows: $(Sys.iswindows()), Sys.ARCH: $(Sys.ARCH)")
5862
println("Detected platform: $key")
5963
if !(key in keys(TARGET_PACKAGES))
60-
error("No package found for $key. Known packages: $(keys(TARGET_PACKAGES)). Maybe ORTools_jll contains a package for your platform.")
64+
error("No package found for $key. Known packages: " *
65+
"$(keys(TARGET_PACKAGES)). Maybe ORTools_jll contains a package " *
66+
"for your platform.")
6167
end
6268

6369
println("Downloading the following binary package:")
6470
println(TARGET_PACKAGES[key])
6571
package = Downloads.download(TARGET_PACKAGES[key])
66-
println("Package downloaded. Size: $(filesize(package)) bytes, i.e. roughly $(round(Int, filesize(package) / 1024 / 1024)) MiB")
72+
println("Package downloaded. Size: $(filesize(package)) bytes, i.e. roughly " *
73+
"$(round(Int, filesize(package) / 1024 / 1024)) MiB")
6774
println("Local path (temporary): $package")
6875

6976
dest_dir = joinpath(DEPS_DIR, "lib")
7077
if isdir(dest_dir)
7178
rm(dest_dir, recursive=true, force=true)
7279
end
7380
mkpath(dest_dir)
81+
println("Destination directory: $dest_dir")
7482

83+
# Extract the archives by picking only the shared libraries.
84+
# There are probably too many extracted files, but it will do for now.
7585
count_files = 0
7686
if endswith(TARGET_PACKAGES[key], ".zip")
7787
# Only for Windows. The ZIP archive contains a folder with the same name
7888
# as the archive itself. We only need the DLLs in the `bin` folder.
7989
zr = ZipArchives.ZipReader(read(package))
8090
for name in ZipArchives.zip_names(zr)
81-
if startswith(name, PACKAGE_FILE_NAME_WITHOUT_EXTENSION[key]) && endswith(name, ".dll")
91+
should_extract = (
92+
startswith(name, PACKAGE_FILE_NAME_WITHOUT_EXTENSION[key]) &&
93+
endswith(name, ".dll")
94+
)
95+
if should_extract
8296
filename = basename(name)
83-
println("Extracting: $filename (path in the ZIP archive: $name)")
84-
97+
dest_path = joinpath(dest_dir, filename)
98+
println("Extracting: $filename (path in the ZIP archive: $name; " *
99+
"destination path: $dest_path)")
100+
85101
ZipArchives.zip_openentry(zr, name) do io
86-
open(joinpath(dest_dir, filename), "w") do f
102+
open(dest_path, "w") do f
87103
write(f, io)
88104
end
89105
end
@@ -100,8 +116,8 @@ elseif endswith(TARGET_PACKAGES[key], ".tar.gz")
100116

101117
Tar.extract(tar_stream, dest_dir) do header
102118
name = header.path
103-
should_extract = startswith(name, PACKAGE_FILE_NAME_WITHOUT_EXTENSION[key]) &&
104-
(endswith(name, ".so") || endswith(name, ".dylib"))
119+
should_extract = endswith(name, ".so") || endswith(name, ".dylib") ||
120+
contains(name, ".so.")
105121
if should_extract
106122
println("Extracting: $(basename(name)) (path in TAR.GZ archive: $(name))")
107123
end
@@ -118,7 +134,14 @@ elseif endswith(TARGET_PACKAGES[key], ".tar.gz")
118134
end
119135

120136
# Clean up after flattening.
121-
rm(joinpath(dest_dir, PACKAGE_FILE_NAME_WITHOUT_EXTENSION[key]), recursive=true)
137+
tmp_dir_extraction = joinpath(
138+
dest_dir, PACKAGE_FILE_NAME_WITHOUT_EXTENSION[key])
139+
if !isdir(tmp_dir_extraction)
140+
tmp_dir_extraction = replace(
141+
tmp_dir_extraction, "amd64" => "x86_64")
142+
end
143+
println("Cleaning up temporary folder: $tmp_dir_extraction")
144+
rm(tmp_dir_extraction, recursive=true)
122145
else
123146
error("Assertion failed: archive type not supported. Please report the problem to the maintainers of OR-Tools.")
124147
end

0 commit comments

Comments
 (0)