Skip to content

Commit

Permalink
Use AbstractAlgebra.should_show_banner (fix #797) (#799)
Browse files Browse the repository at this point in the history
  • Loading branch information
hannes14 authored Apr 29, 2024
1 parent abbc236 commit 77f437f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ lib4ti2_jll = "1493ae25-0f90-5c0e-a06c-8c5077d6d66f"
libsingular_julia_jll = "ae4fbd8f-ecdb-54f8-bbce-35570499b30e"

[compat]
AbstractAlgebra = "0.40"
AbstractAlgebra = "0.40.8"
BinaryWrappers = "~0.1.1"
CxxWrap = "0.14"
Libdl = "1.6"
Expand Down
31 changes: 4 additions & 27 deletions src/Singular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,35 +170,12 @@ function __init__()
merge!(mapping_types_reversed, Dict( i[2] => i[1] for i in libSingular.get_type_mapper() ))
merge!(casting_functions, create_casting_functions())

# 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 and --banner flag
allowbanner = Base.JLOptions().banner != 0

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

singular_version_nr=Singular.libSingular.version()
ver = digits(singular_version_nr, base = 10)
svn = "$(ver[4]).$(ver[3]).$(ver[2])"
if ver[1] > 0
svn *= "p$(ver[1])"
end
if show_banner
svn = "$(ver[5]).$(ver[4]).$(ver[3])"
svn *= "p$(ver[2])$(ver[1])"

if AbstractAlgebra.should_show_banner() && get(ENV, "SINGULAR_PRINT_BANNER", "true") != "false"
println("""Singular.jl, based on
SINGULAR /
A Computer Algebra System for Polynomial Computations / Singular.jl: $VERSION_NUMBER
Expand Down

0 comments on commit 77f437f

Please sign in to comment.