Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove banner code and instead use should_show_banner #1027

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.1"

[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)) &&
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!any(x->x.name in ["Oscar"], keys(Base.package_locks))

This part is different from the banner hiding code in AA. So for Oscar, the current version works aswell. But not for other packages that have GAP as a dependency.

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
Loading