From fb1a25ca03611290f3760d1c933b7585c6af1613 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vielma Date: Wed, 2 Jan 2019 23:53:42 -0300 Subject: [PATCH] Multi-GCC BinaryBuilder Binary Dependencies for Julia v0.7-v1.0 (#92) * BP * Update REQUIRE * Update REQUIRE * Update build.jl * update BinaryProvider requirement 0.5.3 * Update build.jl * Update build.jl * Update build.jl * Update REQUIRE * Update .travis.yml * Update appveyor.yml * Update README.md * Update README.md * Update Cbc.jl * Update build.jl * Update REQUIRE * Update .travis.yml * Update appveyor.yml * Update build.jl * style fixes and comments --- .travis.yml | 1 - README.md | 23 +++++---- REQUIRE | 6 +-- appveyor.yml | 7 --- deps/build.jl | 135 +++++++++++++++++++++++++++++++------------------- src/Cbc.jl | 3 ++ 6 files changed, 103 insertions(+), 72 deletions(-) diff --git a/.travis.yml b/.travis.yml index 33be222..1795d1a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ os: - linux - osx julia: - - 0.6 - 0.7 - 1.0 notifications: diff --git a/README.md b/README.md index 9e56fc3..f249f81 100644 --- a/README.md +++ b/README.md @@ -13,21 +13,26 @@ project.* [![Build Status](https://travis-ci.org/JuliaOpt/Cbc.jl.svg?branch=master)](https://travis-ci.org/JuliaOpt/Cbc.jl) -[![Cbc](http://pkg.julialang.org/badges/Cbc_0.6.svg)](http://pkg.julialang.org/?pkg=Cbc&ver=0.6) - ## Installation -The package is registered in `METADATA.jl` and so can be installed with -`Pkg.add`. +The package is registered in `METADATA.jl` and so can be installed with `Pkg.add`. + +``` +julia> import Pkg; Pkg.add("Cbc") +``` + +Cbc.jl will use [BinaryProvider.jl](https://github.com/JuliaPackaging/BinaryProvider.jl) to automatically install the Cbc binaries. This should work for both the official Julia binaries from `https://julialang.org/downloads/` and source-builds. + +## Custom Installation +To install custom built Clp binaries set the environmental variable `JULIA_CBC_LIBRARY_PATH` and call `import Pkg; Pkg.build("Cbc")`. For instance, if the libraries are installed in `/opt/lib` just call ```julia -julia> Pkg.add("Cbc") +ENV["JULIA_CBC_LIBRARY_PATH"] = "/opt/lib" +import Pkg; Pkg.build("Cbc") ``` +If you do not want BinaryProvider to download the default binaries on install set `JULIA_CBC_LIBRARY_PATH` before calling `import Pkg; Pkg.add("Cbc")`. -The supported platforms are Linux, OS X, and Windows. Binaries are provided for -Windows and OS X, and will be installed by default. On Linux, Cbc will be -automatically compiled from source. Ensure that a C++ compiler is installed -first; on Debian-based systems, install the ``build-essential`` package. +To switch back to the default binaries clear `JULIA_CBC_LIBRARY_PATH` and call `import Pkg; Pkg.build("Cbc")`. ### Using with **[MathProgBase]** diff --git a/REQUIRE b/REQUIRE index 57db9b5..7eabc22 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,7 +1,5 @@ -julia 0.6 -BinDeps +julia 0.7 MathProgBase 0.5.5 0.8 MathOptInterface 0.8 0.9 -@osx Homebrew -@windows WinRPM Compat 1.0 +BinaryProvider 0.5.3 diff --git a/appveyor.yml b/appveyor.yml index 0d3293a..7ec8c96 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,5 @@ environment: matrix: - - julia_version: 0.6 - julia_version: 0.7 - julia_version: 1.0 @@ -8,12 +7,6 @@ platform: - x86 # 32-bit - x64 # 64-bit -# See https://github.com/JuliaOpt/Cbc.jl/issues/56. -matrix: - allow_failures: - - julia_version: 0.7 - - julia_version: 1.0 - branches: only: - master diff --git a/deps/build.jl b/deps/build.jl index ffdf800..f1f6d2c 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -1,64 +1,97 @@ -using BinDeps -import Compat.Libdl -import Compat.Sys +using BinaryProvider # requires BinaryProvider 0.3.0 or later -@BinDeps.setup +# 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, ["libCbcSolver"], :libcbcsolver), + LibraryProduct(prefix, ["libCbc"], :libCbc), +] -function validate_clp(name,handle) - try - p = Libdl.dlsym(handle, :Clp_VersionMajor) - return p != C_NULL - catch - return false - end -end +# Download binaries from hosted location +bin_prefix = "https://github.com/JuliaOpt/CbcBuilder/releases/download/v2.9.9-1-static-parallel" -function validate_cbc(name,handle) - try - # Pre 2.8.12 doesn't have this defined - p = Libdl.dlsym(handle, :Cbc_setInitialSolution) - return p != C_NULL - catch - return false - end -end +# Listing of files generated by BinaryBuilder: +download_info = Dict( + Linux(:aarch64, libc=:glibc, compiler_abi=CompilerABI(:gcc4)) => ("$bin_prefix/CbcBuilder.v2.9.9.aarch64-linux-gnu-gcc4.tar.gz", "41a492db886312253fa86434790364132b97934a9706c02adef6e6d3fa856567"), + Linux(:aarch64, libc=:glibc, compiler_abi=CompilerABI(:gcc7)) => ("$bin_prefix/CbcBuilder.v2.9.9.aarch64-linux-gnu-gcc7.tar.gz", "2627fef08f83e9f0185e6f527b2a1fa64bd44c04525a08070e3cb3ca5beb5dad"), + Linux(:aarch64, libc=:glibc, compiler_abi=CompilerABI(:gcc8)) => ("$bin_prefix/CbcBuilder.v2.9.9.aarch64-linux-gnu-gcc8.tar.gz", "d7afc75ca388ff4537a4410a63870796dce9d3fda6f27b2e62324a01e1c16ce5"), + Linux(:armv7l, libc=:glibc, call_abi=:eabihf, compiler_abi=CompilerABI(:gcc4)) => ("$bin_prefix/CbcBuilder.v2.9.9.arm-linux-gnueabihf-gcc4.tar.gz", "2d609fec46296a37e6b70826221189292c386d8ed0f26ea943dc8df83e93cb7b"), + Linux(:armv7l, libc=:glibc, call_abi=:eabihf, compiler_abi=CompilerABI(:gcc7)) => ("$bin_prefix/CbcBuilder.v2.9.9.arm-linux-gnueabihf-gcc7.tar.gz", "9d9b878ed38b0fde0abd3bc5ca2538091b16bf96ad16481bb15efbdee157e745"), + Linux(:armv7l, libc=:glibc, call_abi=:eabihf, compiler_abi=CompilerABI(:gcc8)) => ("$bin_prefix/CbcBuilder.v2.9.9.arm-linux-gnueabihf-gcc8.tar.gz", "cb0d08bd69d21ca3891b1f300d4883b0f7c48511b8e70bfd0e7065037e331416"), + Linux(:i686, libc=:glibc, compiler_abi=CompilerABI(:gcc4)) => ("$bin_prefix/CbcBuilder.v2.9.9.i686-linux-gnu-gcc4.tar.gz", "b3e12c39b25da8d38d73c6d06f63a7dbf2b9f75dd7fc0856b1da303b136e2c0b"), + Linux(:i686, libc=:glibc, compiler_abi=CompilerABI(:gcc7)) => ("$bin_prefix/CbcBuilder.v2.9.9.i686-linux-gnu-gcc7.tar.gz", "d4e21a6102f3ca180fdbc3e1d8ad3a9f659b0b90719203898159f752acc8f97e"), + Linux(:i686, libc=:glibc, compiler_abi=CompilerABI(:gcc8)) => ("$bin_prefix/CbcBuilder.v2.9.9.i686-linux-gnu-gcc8.tar.gz", "a8cc70d6d1bc19dd0c8b45d279c41c46456a695d9368428af4a1e35558f26358"), + Windows(:i686, compiler_abi=CompilerABI(:gcc6)) => ("$bin_prefix/CbcBuilder.v2.9.9.i686-w64-mingw32-gcc6.tar.gz", "c8b6a7aa20e805e3bfdc40b0bc8f879ed2dc79d3a20d3a285f5572ee0e8c4182"), + Windows(:i686, compiler_abi=CompilerABI(:gcc7)) => ("$bin_prefix/CbcBuilder.v2.9.9.i686-w64-mingw32-gcc7.tar.gz", "f635753118f0a25c351710235214a7f087bfb2215ef038b2dbbcae4f7507f45b"), + Windows(:i686, compiler_abi=CompilerABI(:gcc8)) => ("$bin_prefix/CbcBuilder.v2.9.9.i686-w64-mingw32-gcc8.tar.gz", "7eed8c3e67583c0bea13f954fb88b5baaec060a10f6a3227761cb47ed03485cd"), + MacOS(:x86_64, compiler_abi=CompilerABI(:gcc4)) => ("$bin_prefix/CbcBuilder.v2.9.9.x86_64-apple-darwin14-gcc4.tar.gz", "720f9ce39fa2f2e4a2bb0324fedaded7ecc552abaa43ccf84c278649502c98b6"), + MacOS(:x86_64, compiler_abi=CompilerABI(:gcc7)) => ("$bin_prefix/CbcBuilder.v2.9.9.x86_64-apple-darwin14-gcc7.tar.gz", "9406a5666611584f05a606955dbb938607e9a1448a1ee0e51465c2bbffdd41c9"), + MacOS(:x86_64, compiler_abi=CompilerABI(:gcc8)) => ("$bin_prefix/CbcBuilder.v2.9.9.x86_64-apple-darwin14-gcc8.tar.gz", "87c99037bde52800a1f3061fc998275fc6bfec4c34613327f01cf8cee70b5bc5"), + Linux(:x86_64, libc=:glibc, compiler_abi=CompilerABI(:gcc4)) => ("$bin_prefix/CbcBuilder.v2.9.9.x86_64-linux-gnu-gcc4.tar.gz", "e41bc18ead7ee708b16d57177adc9c08651ca414d690c32d73040ae54756ed30"), + Linux(:x86_64, libc=:glibc, compiler_abi=CompilerABI(:gcc7)) => ("$bin_prefix/CbcBuilder.v2.9.9.x86_64-linux-gnu-gcc7.tar.gz", "006b92dade50a3c75420dc1bfb311e16584cd95210f790c6b1dcc19fc2fd9ae7"), + Linux(:x86_64, libc=:glibc, compiler_abi=CompilerABI(:gcc8)) => ("$bin_prefix/CbcBuilder.v2.9.9.x86_64-linux-gnu-gcc8.tar.gz", "b617514c16c61656ce878a4263cc86776e99944ffe1c57f1f402acd63c5722fb"), + Windows(:x86_64, compiler_abi=CompilerABI(:gcc6)) => ("$bin_prefix/CbcBuilder.v2.9.9.x86_64-w64-mingw32-gcc6.tar.gz", "23e25dd815acda60dfa44d2979448051bef5f0893af8d40939fa1d4613cf33bb"), + Windows(:x86_64, compiler_abi=CompilerABI(:gcc7)) => ("$bin_prefix/CbcBuilder.v2.9.9.x86_64-w64-mingw32-gcc7.tar.gz", "98e4e2089d530e17fa201124c9f68c26e5c79a8fa2dbff4919194c95a0ef2292"), + Windows(:x86_64, compiler_abi=CompilerABI(:gcc8)) => ("$bin_prefix/CbcBuilder.v2.9.9.x86_64-w64-mingw32-gcc8.tar.gz", "994410b63d842099f4b2beffed1a0b1da51832f416b23dd5f634e674b57429f7"), +) -if Sys.isunix() - libclp = library_dependency("libclp",aliases=["libClp"], validate=validate_clp) - libcbcsolver = library_dependency("libcbcsolver",aliases=["libCbcSolver"], validate=validate_cbc) -end -if Sys.iswindows() - using WinRPM - libclp = library_dependency("libclp",aliases=["libClp-1"], validate=validate_clp) - libcbcsolver = library_dependency("libcbcsolver",aliases=["libCbcSolver-3"], validate=validate_cbc) - provides(WinRPM.RPM, "Cbc", [libclp,libcbcsolver], os = :Windows) +# To fix gcc4 bug in Windows +# https://sourceforge.net/p/mingw-w64/bugs/727/ +this_platform = platform_key_abi() +if typeof(this_platform)==Windows && this_platform.compiler_abi.gcc_version == :gcc4 + this_platform = Windows(arch(this_platform), libc=libc(this_platform), compiler_abi=CompilerABI(:gcc6)) end -cbcname = "Cbc-2.9.8" -provides(Sources, URI("http://www.coin-or.org/download/source/Cbc/$cbcname.tgz"), - [libclp,libcbcsolver], os = :Unix) +# no dynamic dependencies until Pkg3 support for binaries +dependencies = [ +# "https://github.com/juan-pablo-vielma/CglBuilder/releases/download/v0.59.10-1/build_CglBuilder.v0.59.10.jl", +# "https://github.com/JuliaOpt/ClpBuilder/releases/download/v1.16.11-1/build_ClpBuilder.v1.16.11.jl", +# "https://github.com/juan-pablo-vielma/OsiBuilder/releases/download/v0.107.9-1/build_OsiBuilder.v0.107.9.jl", +# "https://github.com/juan-pablo-vielma/CoinUtilsBuilder/releases/download/v2.10.14-1/build_CoinUtilsBuilder.v2.10.14.jl", +# "https://github.com/juan-pablo-vielma/COINMumpsBuilder/releases/download/v1.6.0-1/build_COINMumpsBuilder.v1.6.0.jl", +# "https://github.com/juan-pablo-vielma/COINMetisBuilder/releases/download/v1.3.5-1/build_COINMetisBuilder.v1.3.5.jl", +# "https://github.com/juan-pablo-vielma/COINLapackBuilder/releases/download/v1.5.6-1/build_COINLapackBuilder.v1.5.6.jl", +# "https://github.com/juan-pablo-vielma/COINBLASBuilder/releases/download/v1.4.6-1/build_COINBLASBuilder.v1.4.6.jl", +# "https://github.com/juan-pablo-vielma/ASLBuilder/releases/download/v3.1.0-1/build_ASLBuilder.v3.1.0.jl" +] -if Sys.isapple() - using Homebrew - if Homebrew.installed("coinmp") # coinmp package is old and conflicts with cbc package - Homebrew.rm("coinmp") +custom_library = false +if haskey(ENV,"JULIA_CBC_LIBRARY_PATH") + custom_products = [LibraryProduct(ENV["JULIA_CBC_LIBRARY_PATH"],product.libnames,product.variable_name) for product in products] + if all(satisfied(p; verbose=verbose) for p in custom_products) + products = custom_products + custom_library = true + else + error("Could not install custom libraries from $(ENV["JULIA_CBC_LIBRARY_PATH"]).\nTo fall back to BinaryProvider call delete!(ENV,\"JULIA_CBC_LIBRARY_PATH\") and run build again.") end - provides( Homebrew.HB, "cbc", [libclp, libcbcsolver], os = :Darwin ) end -prefix=joinpath(BinDeps.depsdir(libclp),"usr") -patchdir=BinDeps.depsdir(libclp) -srcdir = joinpath(BinDeps.depsdir(libclp),"src",cbcname) +if !custom_library + # Install unsatisfied or updated dependencies: + unsatisfied = any(!satisfied(p; verbose=verbose) for p in products) + + dl_info = choose_download(download_info, this_platform) + if dl_info === nothing && unsatisfied + # If we don't have a 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 (\"$(Sys.MACHINE)\", parsed as \"$(triplet(platform_key_abi()))\") is not supported by this package!") + end -provides(SimpleBuild, - (@build_steps begin - GetSources(libclp) - @build_steps begin - ChangeDirectory(srcdir) - `./configure --prefix=$prefix --without-blas --without-lapack --enable-cbc-parallel` - `make install` - end - end),[libclp,libcbcsolver], os = :Unix) + # If we have a download, and we are unsatisfied (or the version we're + # trying to install is not itself installed) then load it up! + if unsatisfied || !isinstalled(dl_info...; prefix=prefix) + # Download and install binaries + # no dynamic dependencies until Pkg3 support for binaries + # for dependency in reverse(dependencies) # We do not check for already installed dependencies + # download(dependency,basename(dependency)) + # evalfile(basename(dependency)) + # end + install(dl_info...; prefix=prefix, force=true, verbose=verbose) + end + end -@BinDeps.install Dict(:libclp => :libclp, :libcbcsolver => :libcbcsolver) +# 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/Cbc.jl b/src/Cbc.jl index 3af4df8..3d0f838 100644 --- a/src/Cbc.jl +++ b/src/Cbc.jl @@ -1,6 +1,9 @@ __precompile__() module Cbc +# This 'using' is required to suppress a warning about Clp not having Libdl in its +# dependencies (Libdl is used by BinaryProvider), e.g.: bicycle1885/CodecZlib.jl#26. +using Libdl if isfile(joinpath(dirname(@__FILE__),"..","deps","deps.jl")) include("../deps/deps.jl")