Skip to content

BinaryBuilder #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Sep 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions deps/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
deps.jl
usr/
downloads/
src/
92 changes: 46 additions & 46 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 2 additions & 2 deletions src/MPBWrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions test/MOIWrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 1 addition & 9 deletions test/MPBWrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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