diff --git a/README.md b/README.md index 13a7152..dd49039 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,13 @@ You can install ECOS.jl through the Julia package manager: julia> Pkg.add("ECOS") ``` -ECOS.jl will automatically setup the ECOS solver itself: - - On Linux it will build from source - - On OS X it will download a binary via [Homebrew.jl]. - - On Windows it will download a binary. +ECOS.jl will automatically install and setup the ECOS solver itself using [BinaryProvider.jl](https://github.com/JuliaPackaging/BinaryProvider.jl). + +## Custom Installation + +After ECOS.jl is installed and built, you can replace the installed binary dependencies with custom builds by overwritting the binaries and libraries in ECOS.jl's `deps/usr` folder (e.g. in Julia v0.6 `$HOME/.julia/v0.6/ECOS/deps/usr`). + +Note that the custom binaries will not be overwritten by subsequent builds of the currently installed version of ECOS.jl. However, if ECOS.jl is updated and the update includes new BinaryProvider versions of the ECOS binaries, then the custom binaries will be overwritten by the new BinaryProvider versions. ## Usage diff --git a/REQUIRE b/REQUIRE index ad4e9f9..2c8fd00 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,6 +1,5 @@ julia 0.6 -BinDeps MathProgBase 0.5 0.8 MathOptInterface 0.6 0.7 -@osx Homebrew Compat 0.68 +BinaryProvider 0.3 \ No newline at end of file diff --git a/deps/.gitignore b/deps/.gitignore index a9ad096..898e5d8 100644 --- a/deps/.gitignore +++ b/deps/.gitignore @@ -1,4 +1,2 @@ deps.jl usr/ -downloads/ -src/ \ No newline at end of file diff --git a/deps/build.jl b/deps/build.jl index 0b250b4..af54ef3 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -1,48 +1,48 @@ -using BinDeps -using Compat - -@BinDeps.setup - -ecos = library_dependency("ecos", aliases=["libecos"]) - -if Compat.Sys.isapple() - using Homebrew - provides( Homebrew.HB, "ecos", ecos, os = :Darwin ) +using BinaryProvider # requires BinaryProvider 0.3.0 or later + +# Parse some basic command-line arguments +const verbose = "--verbose" in ARGS +const prefix = Prefix(get([a for a in ARGS if a != "--verbose"], 1, joinpath(@__DIR__, "usr"))) +products = [ + LibraryProduct(prefix, String["libecos"], :ecos), +] + +# Download binaries from hosted location +bin_prefix = "https://github.com/juan-pablo-vielma/ECOSBuilder/releases/download/v2.0.5-beta" + +# Listing of files generated by BinaryBuilder: +download_info = Dict( + Linux(:aarch64, :glibc) => ("$bin_prefix/ECOSBuilder.v2.0.5.aarch64-linux-gnu.tar.gz", "9e6279a971889df14eaa384c8138136c5918e1a3a97e913d1a23fb3e80d711a6"), + Linux(:aarch64, :musl) => ("$bin_prefix/ECOSBuilder.v2.0.5.aarch64-linux-musl.tar.gz", "afeb89f158dbcb506230e35e13ad63ab374a35f8b4ebe3ff4d1c604acb98e79f"), + Linux(:armv7l, :glibc, :eabihf) => ("$bin_prefix/ECOSBuilder.v2.0.5.arm-linux-gnueabihf.tar.gz", "2fd091c5581156acc1a135d7ad969563f4a356b2631b3d2f2e215c114960c98b"), + Linux(:armv7l, :musl, :eabihf) => ("$bin_prefix/ECOSBuilder.v2.0.5.arm-linux-musleabihf.tar.gz", "776ceedd12467a761354e73641dba4c0e0b34df9e5635360880e0d7f4c347c64"), + Linux(:i686, :glibc) => ("$bin_prefix/ECOSBuilder.v2.0.5.i686-linux-gnu.tar.gz", "2b622c881c0c0cb9a12f514a211512b8a0c2404c6e35f4817e0c590095a759aa"), + Linux(:i686, :musl) => ("$bin_prefix/ECOSBuilder.v2.0.5.i686-linux-musl.tar.gz", "0318aafa7457e0d1cb9a85e0938498457341d0050036ac24ab05b8f2d0ea7d4f"), + Windows(:i686) => ("$bin_prefix/ECOSBuilder.v2.0.5.i686-w64-mingw32.tar.gz", "2c5fba5caed62b5edc1199ebd62e702212197b916f6bab8f7ba30c2c16326117"), + Linux(:powerpc64le, :glibc) => ("$bin_prefix/ECOSBuilder.v2.0.5.powerpc64le-linux-gnu.tar.gz", "9d75f00a0bd9ba2aa917f073cb9544f4fb74f0cd711eeb5b06ab13efe70cf16a"), + MacOS(:x86_64) => ("$bin_prefix/ECOSBuilder.v2.0.5.x86_64-apple-darwin14.tar.gz", "617f20ee41dbbd34dd7f8cb4c8c5f84bf5e52646886880679d8c116de418fd29"), + Linux(:x86_64, :glibc) => ("$bin_prefix/ECOSBuilder.v2.0.5.x86_64-linux-gnu.tar.gz", "69ea265aab6701b9ce2b9c3b6d574bd88f1fd4640527a8d106385359abe88021"), + Linux(:x86_64, :musl) => ("$bin_prefix/ECOSBuilder.v2.0.5.x86_64-linux-musl.tar.gz", "52f6c0f3742e316eb15d5180cfa41c6a7985104745f7ede0bf0577087af97384"), + FreeBSD(:x86_64) => ("$bin_prefix/ECOSBuilder.v2.0.5.x86_64-unknown-freebsd11.1.tar.gz", "52f2167039d40115a92f428c81e81b3de000cece3756ea9bfcf12c07ef6bd9bc"), + Windows(:x86_64) => ("$bin_prefix/ECOSBuilder.v2.0.5.x86_64-w64-mingw32.tar.gz", "f38e30147d12bb06eab3517c314444ffaedf13f252947cb458bd34cddb73e481"), +) + +# Install unsatisfied or updated dependencies: +unsatisfied = any(!satisfied(p; verbose=verbose) for p in products) +if haskey(download_info, platform_key()) + url, tarball_hash = download_info[platform_key()] + # Check if this build.jl is providing new versions of the binaries, and + # if so, ovewrite the current binaries even if they were installed by the user + if unsatisfied || !isinstalled(url, tarball_hash; prefix=prefix) + # Download and install binaries + install(url, tarball_hash; prefix=prefix, force=true, verbose=verbose) + end +elseif unsatisfied + # If we don't have a BinaryProvider-compatible .tar.gz to download, complain. + # Alternatively, you could attempt to install from a separate provider, + # build from source or something even more ambitious here. + error("Your platform $(triplet(platform_key())) is not supported by this package!") end -version = "2.0.5" -win_version = "2.0.2" -provides(Sources, URI("https://github.com/ifa-ethz/ecos/archive/v$version.tar.gz"), - [ecos], os = :Unix, unpacked_dir="ecos-$version") - -prefix = joinpath(BinDeps.depsdir(ecos),"usr") -srcdir = joinpath(BinDeps.depsdir(ecos),"src","ecos-$version") - -provides(Binaries, URI("https://cache.julialang.org/https://bintray.com/artifact/download/tkelman/generic/ecos-$win_version.7z"), - [ecos], unpacked_dir="usr/bin$(Sys.WORD_SIZE)", os = :Windows, - SHA="b90254220a9a63cba08700f3664519d360f45d363454e5c107e6f30e144a60a1") - -# We'll keep this around for emergencies, but OSX users should be able to use Homebrew -provides(SimpleBuild, - (@build_steps begin - GetSources(ecos) - CreateDirectory(joinpath(prefix,"lib")) - FileRule(joinpath(prefix,"lib","libecos.dylib"),@build_steps begin - ChangeDirectory(srcdir) - `make shared` - `mv libecos.dylib $prefix/lib` - end) - end),[ecos], os = :Darwin) - -provides(SimpleBuild, - (@build_steps begin - GetSources(ecos) - CreateDirectory(joinpath(prefix,"lib")) - FileRule(joinpath(prefix,"lib","libecos.so"),@build_steps begin - ChangeDirectory(srcdir) - `make shared` - `mv libecos.so $prefix/lib` - end) - end),[ecos], os = :Unix) - -@BinDeps.install Dict(:ecos => :ecos) +# Write out a deps.jl file that will contain mappings for our products +write_deps_file(joinpath(@__DIR__, "deps.jl"), products, verbose=verbose) diff --git a/src/MPBWrapper.jl b/src/MPBWrapper.jl index ebae706..9400ffb 100644 --- a/src/MPBWrapper.jl +++ b/src/MPBWrapper.jl @@ -265,7 +265,7 @@ function MPB.loadproblem!(m::ECOSMathProgModel, c, A, b, constr_cones, var_cones for (cone,idxs) in constr_cones cone == :Free && error("Free cone constraints not handled") (cone == :SOC || cone == :ExpPrimal) && continue # Handle later - idxset = vec(collect(idxs))::Vector{Int} + idxset = vec(collect(idxs)) if cone == :Zero append!(eq_rows, idxset) continue @@ -331,7 +331,7 @@ function MPB.loadproblem!(m::ECOSMathProgModel, c, A, b, constr_cones, var_cones if cone == :SOC num_SOC_cones += 1 push!(SOC_conedims, length(idxs)) - idx_list = collect(idxs)::Vector{Int} + idx_list = collect(idxs) all_rows = vcat(all_rows, idx_list) end end diff --git a/test/MOIWrapper.jl b/test/MOIWrapper.jl index ae6cb64..4d6505d 100644 --- a/test/MOIWrapper.jl +++ b/test/MOIWrapper.jl @@ -25,13 +25,6 @@ end @testset "Continuous conic problems" begin exclude = ["sdp", "rootdet", "logdet"] - @static if Compat.Sys.iswindows() - # Test exp3 fails on Windows 32 and 64 bits because the windows - # binaries are out of date just like EXP3 fails with the MPB wrapper - # See https://github.com/JuliaOpt/ECOS.jl/issues/47 - push!(exclude, "exp3") - end - MOIT.contconictest(MOIB.GeoMean{Float64}(MOIB.RSOC{Float64}(optimizer)), config, exclude) end diff --git a/test/MPBWrapper.jl b/test/MPBWrapper.jl index ccf449c..0071aa0 100644 --- a/test/MPBWrapper.jl +++ b/test/MPBWrapper.jl @@ -24,15 +24,7 @@ end include(joinpath(MPB_test_path, "conicinterface.jl")) coniclineartest(ECOS.ECOSSolver(), duals=true) conicSOCtest(ECOS.ECOSSolver(), duals=true) - @static if !Compat.Sys.iswindows() - # Test EXP3 fails on Windows 32 and 64 bits because the windows - # binaries are out of date. There failure is: - # Expression: (-(y[2]) * log(-(y[2]) / y[4]) + y[2]) - y[3] ≤ tol - # Evaluated: 0.39942722775671957 ≤ 1.0e-6 - # See https://github.com/JuliaOpt/ECOS.jl/issues/47 - conicEXPtest(ECOS.ECOSSolver(), duals=true) - end - + conicEXPtest(ECOS.ECOSSolver(), duals=true) include(joinpath(MPB_test_path, "quadprog.jl")) socptest(ECOS.ECOSSolver()) end