@@ -22,10 +22,13 @@ const TARGET_PACKAGES = Dict{String, String}(
2222
2323const 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." )
2627println ()
2728println (" 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
3033key = " unknown"
3134if Sys. islinux ()
@@ -54,36 +57,49 @@ elseif Sys.iswindows()
5457 end
5558end
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) " )
5862println (" Detected platform: $key " )
5963if ! (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." )
6167end
6268
6369println (" Downloading the following binary package:" )
6470println (TARGET_PACKAGES[key])
6571package = 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" )
6774println (" Local path (temporary): $package " )
6875
6976dest_dir = joinpath (DEPS_DIR, " lib" )
7077if isdir (dest_dir)
7178 rm (dest_dir, recursive= true , force= true )
7279end
7380mkpath (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.
7585count_files = 0
7686if 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 )
122145else
123146 error (" Assertion failed: archive type not supported. Please report the problem to the maintainers of OR-Tools." )
124147end
0 commit comments