|
1 |
| -using PyCall |
2 |
| -using Conda |
| 1 | +using BinaryProvider # requires BinaryProvider 0.3.0 or later |
3 | 2 |
|
4 |
| -const SPOT_DEV_URL = "https://gitlab.lrde.epita.fr/spot/spot/-/jobs/21743/artifacts/download" |
5 |
| -# const SPOT_DEV_URL = "https://gitlab.lrde.epita.fr/spot/spot/-/jobs/21303/artifacts/download" |
| 3 | +# Parse some basic command-line arguments |
| 4 | +const verbose = "--verbose" in ARGS |
| 5 | +const prefix = Prefix(get([a for a in ARGS if a != "--verbose"], 1, joinpath(@__DIR__, "usr"))) |
| 6 | +products = [ |
| 7 | + LibraryProduct(prefix, ["libspot"], :libspot), |
| 8 | +] |
6 | 9 |
|
7 |
| -const SPOT_VERSION = "spot-2.6.3.dev" |
8 |
| -const GCC_MAJOR_VERSION = parse(Int,Char(read(`g++ -dumpversion | cut -f1 -d.`)[1])) # get g++ major version |
| 10 | +if Sys.iswindows() |
| 11 | + using Pkg |
| 12 | + Pkg.add(PackageSpec(name="Cxx", rev="gn-patch-crash")) |
| 13 | +end |
| 14 | + |
| 15 | +# Download binaries from hosted location |
| 16 | +bin_prefix = "https://github.com/MaximeBouton/SpotBuilder/releases/download/v2.8.1" |
9 | 17 |
|
10 |
| -if !Sys.isunix() |
11 |
| - throw("Windows not supported") |
| 18 | +# Listing of files generated by BinaryBuilder: |
| 19 | +download_info = Dict( |
| 20 | + MacOS(:x86_64) => ("$bin_prefix/Spot.v2.8.1.x86_64-apple-darwin14.tar.gz", "de9236acab1975a06f218d2939f6c319fb0bc67546e89cdc5c85ef90be509cb4"), |
| 21 | + Linux(:x86_64, libc=:glibc, compiler_abi=CompilerABI(:gcc7)) => ("$bin_prefix/Spot.v2.8.1.x86_64-linux-gnu-gcc7.tar.gz", "2fd4429180f94e67284ae37704aa22bed357e2a356062f8af0cd39397a173f4c"), |
| 22 | + Linux(:x86_64, libc=:glibc, compiler_abi=CompilerABI(:gcc8)) => ("$bin_prefix/Spot.v2.8.1.x86_64-linux-gnu-gcc8.tar.gz", "7caaa648e059c354892a5503b30bf3b2d368469b4295f54564f8a212fa3e2893"), |
| 23 | + Windows(:x86_64, compiler_abi=CompilerABI(:gcc7)) => ("$bin_prefix/Spot.v2.8.1.x86_64-w64-mingw32-gcc7.tar.gz", "782f52898e81c51abd8930c34184a6f99d78e4a49e7a6c753b9eb0741e8bcdfc"), |
| 24 | + Windows(:x86_64, compiler_abi=CompilerABI(:gcc8)) => ("$bin_prefix/Spot.v2.8.1.x86_64-w64-mingw32-gcc8.tar.gz", "283473593d120f968366f85da52bd4341ac94715c49476adf9bdd1688b445411"), |
| 25 | +) |
| 26 | + |
| 27 | +# Install unsatisfied or updated dependencies: |
| 28 | +unsatisfied = any(!satisfied(p; verbose=verbose) for p in products) |
| 29 | +dl_info = choose_download(download_info, platform_key_abi()) |
| 30 | +if dl_info === nothing && unsatisfied |
| 31 | + # If we don't have a compatible .tar.gz to download, complain. |
| 32 | + # Alternatively, you could attempt to install from a separate provider, |
| 33 | + # build from source or something even more ambitious here. |
| 34 | + error("Your platform (\"$(Sys.MACHINE)\", parsed as \"$(triplet(platform_key_abi()))\") is not supported by this package!") |
12 | 35 | end
|
13 | 36 |
|
14 |
| -# borrowed from TensorFlow.jl |
15 |
| -if PyCall.conda |
16 |
| - println("Building Spot from source...") |
17 |
| - pyversion = PyCall.pyversion |
18 |
| - base = dirname(@__FILE__) |
19 |
| - println("Switching to directory $base") |
20 |
| - cd(base) |
21 |
| - isfile("$SPOT_VERSION.zip") ? nothing : run(`wget -O $SPOT_VERSION.zip $SPOT_DEV_URL`) |
22 |
| - run(`unzip $SPOT_VERSION.zip`) |
23 |
| - run(`rm $SPOT_VERSION.zip`) |
24 |
| - run(`tar -xzf $SPOT_VERSION.tar.gz`) # extract |
25 |
| - isdir("spot") ? mkdir("spot") : nothing |
26 |
| - cd(SPOT_VERSION) |
27 |
| - if GCC_MAJOR_VERSION < 5 |
28 |
| - println("g++ version must be at least 5.0.0") |
29 |
| - end |
30 |
| - run(`./configure CXX=g++-7 PYTHON=$(Conda.PYTHONDIR)/python --prefix $(joinpath(base, "spot"))`) |
31 |
| - run(`make`) |
32 |
| - run(`make install`) |
33 |
| - println(readdir(joinpath(base, "spot", "lib"))) |
34 |
| - @assert isdir(joinpath(base, "spot")) |
35 |
| - @assert isdir(joinpath(base, "spot", "lib", "python"*string(pyversion.major)*"."*string(pyversion.minor), "site-packages")) |
36 |
| - println("Python bindings located at: ", joinpath(base, "spot", "lib", "python"*string(pyversion.major)*"."*string(pyversion.minor), "site-packages")) |
37 |
| - println("build successful") |
38 |
| - println("Linking python bindings to Conda.jl") |
39 |
| - conda_path = joinpath(Conda.ROOTENV, "lib", "python"*string(pyversion.major)*"."*string(pyversion.minor), "site-packages") |
40 |
| - pythonspot = joinpath(base, "spot", "lib","python"*string(pyversion.major)*"."*string(pyversion.minor), "site-packages") |
41 |
| - cd(conda_path) |
42 |
| - run(`ln -sf $pythonspot/spot`) |
43 |
| - run(`ln -sf $pythonspot/_buddy.a`) |
44 |
| - run(`ln -sf $pythonspot/_buddy.la`) |
45 |
| - run(`ln -sf $pythonspot/_buddy.so`) |
46 |
| - run(`ln -sf $pythonspot/buddy.py`) |
47 |
| -else |
48 |
| - try |
49 |
| - pyimport("spot") |
50 |
| - catch ee |
51 |
| - typeof(ee) <: PyCall.PyError || rethrow(ee) |
52 |
| - error(""" |
53 |
| -Python Spot not installed |
54 |
| -Please either: |
55 |
| - - Rebuild PyCall to use Conda, by running in the julia REPL: |
56 |
| - - `ENV["PYTHON"]=""; Pkg.build("PyCall"); Pkg.build("Spot")` |
57 |
| - - Or install the python binding yourself: |
58 |
| - Install Spot from https://spot.lrde.epita.fr/install.html |
59 |
| - Find the python bindings in path/to/spot/lib/python3.x/site-packages |
60 |
| -""") |
61 |
| - end |
| 37 | +# If we have a download, and we are unsatisfied (or the version we're |
| 38 | +# trying to install is not itself installed) then load it up! |
| 39 | +if unsatisfied || !isinstalled(dl_info...; prefix=prefix) |
| 40 | + # Download and install binaries |
| 41 | + install(dl_info...; prefix=prefix, force=true, verbose=verbose) |
62 | 42 | end
|
| 43 | + |
| 44 | +# Write out a deps.jl file that will contain mappings for our products |
| 45 | +write_deps_file(joinpath(@__DIR__, "deps.jl"), products, verbose=verbose) |
0 commit comments