Skip to content

Commit

Permalink
Merge 37dd86d into 0eadb55
Browse files Browse the repository at this point in the history
  • Loading branch information
benlorenz committed Nov 8, 2021
2 parents 0eadb55 + 37dd86d commit 671c268
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 44 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Expand Up @@ -4,6 +4,7 @@ version = "0.8.0"

[deps]
AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
BinaryWrappers = "f01c122e-0ea1-4f85-ad8f-907073ad7a9f"
CxxWrap = "1f15a43c-97ca-5a2a-ae31-89f07a497df4"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Expand All @@ -18,6 +19,7 @@ libsingular_julia_jll = "ae4fbd8f-ecdb-54f8-bbce-35570499b30e"

[compat]
AbstractAlgebra = "0.22.0"
BinaryWrappers = "~0.1.1"
CxxWrap = "0.11"
Nemo = "0.27.0"
RandomExtensions = "0.4.2"
Expand Down
48 changes: 4 additions & 44 deletions src/setup.jl
@@ -1,55 +1,15 @@
module Setup

using Singular_jll
using lib4ti2_jll
import lib4ti2_jll
using BinaryWrappers

# add shell scripts that startup another julia for some lib4ti2 programs
function regenerate_4ti2_wrapper(binpath, wrapperpath)
mkpath("$wrapperpath")

if Sys.iswindows()
LIBPATH_env = "PATH"
elseif Sys.isapple()
LIBPATH_env = "DYLD_FALLBACK_LIBRARY_PATH"
else
LIBPATH_env = "LD_LIBRARY_PATH"
end

function force_symlink(p::AbstractString, np::AbstractString)
rm(np; force = true)
symlink(p, np)
end

for tool in ("4ti2gmp", "4ti2int32", "4ti2int64", "zsolve")
force_symlink(joinpath(binpath, tool), joinpath(wrapperpath, tool))
end

for tool in ("graver", "hilbert", "markov")
toolpath = joinpath(wrapperpath, tool)
write(toolpath, """
#!/bin/sh
export $(LIBPATH_env)="$(lib4ti2_jll.LIBPATH[])"
. $(binpath)/$(tool) "\$@"
""")
chmod(toolpath, 0o777)
end
end

#
# put the wrapper inside this package, but use different wrappers for each
# minor Julia version as those may get different versions of the various JLLs
#
# TODO/FIXME: don't write into the package directory; instead use a scratch space
# obtained via <https://github.com/JuliaPackaging/Scratch.jl> -- however, that
# requires Julia >= 1.5; so we can't use it until we drop support for Julia 1.3 & 1.4.
#
const wrapperpath = abspath(@__DIR__, "..", "bin", "v$(VERSION.major).$(VERSION.minor)")
@info "Regenerating 4ti2 wrappers in $(wrapperpath)"
regenerate_4ti2_wrapper(joinpath(lib4ti2_jll.find_artifact_dir(), "bin"), wrapperpath)
const lib4ti2_binpath = @generate_wrappers(lib4ti2_jll)

# make sure Singular can find the wrappers
function __init__()
ENV["PATH"] = wrapperpath * ":" * ENV["PATH"]
ENV["PATH"] = lib4ti2_binpath * ":" * ENV["PATH"]
end

#
Expand Down

0 comments on commit 671c268

Please sign in to comment.