Skip to content

Commit

Permalink
Remove banner code and instead use should_show_banner (#1027)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens authored Sep 12, 2024
1 parent c5766b7 commit d53926d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ authors = ["Thomas Breuer <[email protected]>", "Sebastian Gutsche <gutsch
version = "0.11.2"

[deps]
AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
Expand All @@ -22,6 +23,7 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Scratch = "6c6a2e73-6563-6170-7368-637461726353"

[compat]
AbstractAlgebra = "0.41.11, 0.42.1"
Artifacts = "1.6"
Compat = "4.4.0"
Downloads = "1.4.3"
Expand Down
23 changes: 3 additions & 20 deletions src/GAP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ if Sys.iswindows()
windows_error()
end

import AbstractAlgebra # for should_show_banner()

import GAP_jll: GAP_jll, libgap

GAP_jll.is_available() ||
Expand Down Expand Up @@ -260,26 +262,7 @@ function __init__()
end
end

# Check if were loaded from another package
# if VERSION < 1.7.*, only the "other" package will have the
# _tryrequire_from_serialized in the backtrace.
# if VERSION >= 1.8, also doing 'using Package' will have
# _tryrequire_from_serialized the backtrace.
#
# To still distinguish both scenarios, notice that
# 'using OtherPackage' will either have _tryrequire_from_serialized at least twice,
# or one with four arguments (hence five as the function name is the first argument)
# 'using Package' serialized will have a version with less arguments
bt = Base.process_backtrace(Base.backtrace())
filter!(sf -> sf[1].func === :_tryrequire_from_serialized, bt)
isinteractive_manual =
length(bt) == 0 || (length(bt) == 1 && length(only(bt)[1].linfo.specTypes.parameters) < 4)

# Respect the -q flag
isquiet = Bool(Base.JLOptions().quiet)

show_banner = !isquiet && isinteractive_manual && isinteractive() &&
!any(x->x.name in ["Oscar"], keys(Base.package_locks)) &&
show_banner = AbstractAlgebra.should_show_banner() &&
get(ENV, "GAP_PRINT_BANNER", "true") != "false"

if !show_banner
Expand Down
1 change: 1 addition & 0 deletions test/Aqua.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ using Aqua
@testset "Aqua.jl" begin
Aqua.test_all(
GAP;
ambiguities=false, # some from AbstractAlgebra.jl show up here
piracies=(GAP.use_jl_reinit_foreign_type() ? true : (treat_as_own=[GapObj],))
)
end

0 comments on commit d53926d

Please sign in to comment.