Skip to content

Commit e897273

Browse files
authored
Merge pull request #8 from sisl/binarybuilder
[WIP] Use Cxx and BinaryBuilder
2 parents 408e862 + 752dcaf commit e897273

15 files changed

+1524
-681
lines changed

.travis.yml

Lines changed: 40 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,40 @@
1-
# Documentation: http://docs.travis-ci.com/user/languages/julia/
2-
language: julia
3-
os:
4-
- linux
5-
julia:
6-
- 1.0
7-
- 1.1
8-
- nightly
9-
10-
env:
11-
- CONDA_JL_VERSION="3" PYTHON=""
12-
13-
addons:
14-
apt:
15-
sources:
16-
- ubuntu-toolchain-r-test
17-
packages:
18-
- g++-7
19-
- python3-dev
20-
- clang-3.9
21-
- graphviz
22-
23-
matrix:
24-
allow_failures:
25-
- julia: nightly
26-
fast_finish: true
27-
28-
notifications:
29-
email: false
30-
before_script:
31-
- sudo apt-get -qq update
32-
- sudo apt-get install -y pdf2svg
33-
- sudo apt-get install -y texlive-latex-base
34-
- sudo apt-get install -y texlive-binaries
35-
- sudo apt-get install -y texlive-pictures
36-
- sudo apt-get install -y texlive-latex-extra
37-
- sudo pip install dot2tex
38-
# Every 30 seconds, look for the build log file. If it exists, then
39-
# start watching its contents and printing them to stdout as they
40-
# change. This has two effects:
41-
# 1. it avoids Travis timing out because the build outputs nothing
42-
# 2. it makes it more obvious what part of the build, if any, gets stuck
43-
- while sleep 3; do tail ~/build/sisl/Spot.jl/deps/build.log -f ; done &
44-
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 90
45-
script:
46-
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
47-
- julia --project --color=yes -e 'import Pkg; Pkg.build(); Pkg.test(coverage=true)'
48-
after_success:
49-
- julia --project -e 'import Pkg; Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
50-
- julia --project -e 'import Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
1+
2+
# Documentation: http://docs.travis-ci.com/user/languages/julia/
3+
language: julia
4+
os:
5+
- linux
6+
julia:
7+
- 1.2
8+
- nightly
9+
10+
addons:
11+
apt:
12+
sources:
13+
- ubuntu-toolchain-r-test
14+
packages:
15+
- g++-7
16+
- clang-3.9
17+
- graphviz
18+
19+
matrix:
20+
allow_failures:
21+
- julia: nightly
22+
fast_finish: true
23+
24+
notifications:
25+
email: false
26+
before_script:
27+
- sudo apt-get -qq update
28+
- sudo apt-get install -y pdf2svg
29+
- sudo apt-get install -y texlive-latex-base
30+
- sudo apt-get install -y texlive-binaries
31+
- sudo apt-get install -y texlive-pictures
32+
- sudo apt-get install -y texlive-latex-extra
33+
- sudo pip install dot2tex
34+
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 90
35+
script:
36+
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
37+
- julia --project --color=yes -e 'import Pkg; Pkg.build(); Pkg.test(coverage=true)'
38+
after_success:
39+
- julia --project -e 'import Pkg; Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
40+
- julia --project -e 'import Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'

Project.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@ repo = "https://github.com/sisl/Spot.jl"
44
version = "0.0.0"
55

66
[deps]
7-
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
7+
BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
8+
Cxx = "a0b5b9ef-44b7-5148-a2d1-f6db19f3c3d2"
9+
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
10+
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
811
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
912
MetaGraphs = "626554b9-1ddb-594c-aa3c-2596fe9399a5"
1013
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
11-
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
14+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
1215
TikzPictures = "37f6aa50-8035-52d0-81c2-5a1d08754b2d"
1316

1417
[extras]
1518
NBInclude = "0db19996-df87-5ea3-a455-e3a50d440464"
1619
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1720

1821
[targets]
19-
test = ["NBInclude", "Test"]
22+
test = ["NBInclude", "Test"]

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
[![CodeCov](https://codecov.io/gh/sisl/Spot.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/sisl/Spot.jl)
55
[![Coveralls](https://coveralls.io/repos/github/sisl/Spot.jl/badge.svg?branch=master)](https://coveralls.io/github/sisl/Spot.jl?branch=master)
66

7-
This package provides Julia bindings to the [Spot](https://spot.lrde.epita.fr/index.html) library for LTL and automata manipulation.
8-
It requires the python bindings of spot to be correctly installed and accessible via [PyCall.jl](https://github.com/JuliaPy/PyCall.jl)
7+
This package provides Julia bindings to the [Spot](https://spot.lrde.epita.fr/index.html) library for LTL and automata manipulation. It relies on [Cxx.jl](https://github.com/JuliaInterop/Cxx.jl) to interface julia with the Spot c++ library.
8+
9+
If you wish to use `PyCall` instead and interact with the spot python bindings you should checkout the branch `pycall` (linux only).
910

1011
## Installation
1112

12-
For the rendering, Spot requires [GraphViz](https://graphviz.gitlab.io/) and [dot2tex](https://dot2tex.readthedocs.io/en/latest/index.html) to be installed.
13+
For the rendering, Spot requires [GraphViz](https://graphviz.gitlab.io/) and [dot2tex](https://dot2tex.readthedocs.io/en/latest/index.html) to be installed. In addition, the precompile binaries require `gcc` 7 or 8 (not needed for Mac).
1314

1415
```julia
1516
using Pkg; Pkg.add("https://github.com/sisl/Spot.jl")
1617
```
1718

18-
Python dependencies:
19-
- IPython (for visualization in jupyter notebook)
19+
**Windows support:** The registered version of Cxx.jl is currently broken for Windows. However, the branch `gn-patch-crash` is working for now. The build script should checkout the right branch. Otherwise run `] add Cxx#gn-patch-crash` in the julia environment where you wish to install Spot.
2020

2121
## Usage
2222

@@ -46,11 +46,11 @@ a = translate(translator, ltl)
4646

4747
A basic tutorial is available in [docs/spot_basic_tutorial.ipynb](https://github.com/sisl/Spot.jl/blob/master/docs/spot_basic_tutorial.ipynb)
4848

49+
### Notes
4950

50-
## TODOs
51-
52-
- [ ] Use CXXWrap.jl to avoid relying on a third language (python) and automatically import all the spot functions.
53-
- [ ] Try using BinaryBuilder. A first experiment was not successful, the path to `libspot.so` in the python bindings is wrong.
51+
Right now, the wrapping of all the c++ functions present in `libspot` is not automatic.
52+
Every function can be called using the Cxx interface.
53+
If you need to wrap a function that has not been wrapped yet, feel free to submit a Pull Request.
5454

5555
## Acknowledgement
5656

deps/build.jl

Lines changed: 39 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,45 @@
1-
using PyCall
2-
using Conda
1+
using BinaryProvider # requires BinaryProvider 0.3.0 or later
32

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+
]
69

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"
917

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!")
1235
end
1336

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)
6242
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

Comments
 (0)