Skip to content

Commit

Permalink
Use BinaryWrapper to point GAP packages to singular/polymake executables
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Sep 27, 2024
1 parent a0aa36e commit 94fb5c3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ version = "1.2.0-DEV"
[deps]
AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
AlgebraicSolving = "66b61cbe-0446-4d5d-9090-1ff510639f9d"
BinaryWrappers = "f01c122e-0ea1-4f85-ad8f-907073ad7a9f"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
GAP = "c863536a-3901-11e9-33e7-d5cd0df7b904"
Hecke = "3e1990a7-5d81-5526-99ce-9ba3ff248f21"
Expand All @@ -27,6 +28,7 @@ cohomCalg_jll = "5558cf25-a90e-53b0-b813-cadaa3ae7ade"
[compat]
AbstractAlgebra = "0.43.1"
AlgebraicSolving = "0.7.0"
BinaryWrappers = "0.1"
Distributed = "1.6"
GAP = "0.11.3"
Hecke = "0.34.3"
Expand Down
36 changes: 36 additions & 0 deletions src/Oscar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ Hecke.@include_deprecated_bindings()

include("utils/utils.jl")

import BinaryWrappers

#const perl_binpath = BinaryWrappers.@generate_wrappers(Polymake.Perl_jll)
#const polymake_binpath = BinaryWrappers.@generate_wrappers(Polymake.polymake_jll)
const singular_binpath = BinaryWrappers.@generate_wrappers(Singular.Singular_jll)

# More helpful error message for users on Windows.
windows_error() = error("""
Expand Down Expand Up @@ -87,6 +93,36 @@ function __init__()
# `Julia.Oscar` if Oscar is loaded indirectly as a package dependency)
GAP.Globals.BindGlobal(GapObj("Oscar"), Oscar)

# ensure the GAP package 'singular' finds a Singular interpreter it can actually
# execute, by pointing it at the binary wrapper for the Singular in Singular_jll
GAP.Globals.sing_exec = GapObj(joinpath(singular_binpath, "Singular"))

# TODO: do the same for the GAP package 'polymaking' and polymake ; this is
# complicated by the fact that the `polymake` executable is just a perl
# script, which begins with `#!/usr/bin/env perl`. Hence the following
# doesn't work:
#
# GAP.Globals.POLYMAKE_COMMAND = GapObj(joinpath(polymake_binpath, "polymake"))
#
# ... as this ends up trying to use a system install version of Perl (which
# may not even exist). So we need to use the perl from our Perl_jll. E.g this
# works to launch polymake:
#
# import Oscar.Polymake: polymake_jll
# run(addenv(`$(polymake_jll.Perl_jll.perl()) $(polymake_jll.polymake_path)`,
# polymake_jll.JLLWrappers.LIBPATH_env=>polymake_jll.LIBPATH[]))
#
# But GAP needs a path to an executable and we can't tell it to set
# environment variables. So we either need to generate our own wrapper shell
# script; or someone needs to generalize BinaryWrappers to teach it to
# generate wrappers that set up environment variables based on one JLL
# (here: polymake_jll), but executes something from another (here: perl from
# Perl_jll).
#
# Since nobody has request anything using `polymaking` right now, we'll leave
# it at that for the moment (ideally any code using it would be rewritten to
# instead use our Julia-GAP and Julia-polymake bridges instead anyway).

# Up to now, hopefully the GAP packages listed below have not been loaded.
# We want newer versions of some GAP packages than the distributed ones.
# (But we do not complain if the installation fails.)
Expand Down

0 comments on commit 94fb5c3

Please sign in to comment.