From efac892dc29e14645646ed8a1202b4bef497899c Mon Sep 17 00:00:00 2001 From: Thomas Breuer Date: Tue, 2 Jul 2024 16:30:15 +0200 Subject: [PATCH] change the handling of `IncludeJuliaStartupFile` (for Julia 1.10) (#1017) remove the GAP user preference `IncludeJuliaStartupFile`, do not try to include the Julia startup file from GAP, instead use an environment variable in the situation that GAP gets started via `gap.sh`. --- CHANGES.md | 8 +++ pkg/JuliaInterface/gap/JuliaInterface.gd | 3 - pkg/JuliaInterface/init.g | 84 ------------------------ src/setup.jl | 8 ++- 4 files changed, 15 insertions(+), 88 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 2f92437ee..6fac8b9c6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,13 @@ # Changes in GAP.jl +- Remove the GAP user preference `IncludeJuliaStartupFile` + that was used to control whether `~/.julia/config/startup.jl` + gets included by Julia when GAP is started together with Julia + via a `gap.sh` script. + In this situation, one can now use the environment variable + `JULIA_STARTUP_FILE_IN_GAP`; + if its value is `yes` then the startup file gets included, otherwise not. + ## Version 0.11.1 (released 2024-06-06) - Optimize conversion from `UInt` to `GapObj` diff --git a/pkg/JuliaInterface/gap/JuliaInterface.gd b/pkg/JuliaInterface/gap/JuliaInterface.gd index 777fe2ded..bdd5c6cc4 100644 --- a/pkg/JuliaInterface/gap/JuliaInterface.gd +++ b/pkg/JuliaInterface/gap/JuliaInterface.gd @@ -86,9 +86,6 @@ #! https://github.com/oscar-system/GAP.jl #! the &Julia; package GAP.jl, #! hence it can be found there. -#! -#! @Section User preferences in the JuliaInterface package -#! @InsertChunk IncludeJuliaStartupFile #! @Chapter Using &Julia; from ⪆ #! @Section Filters for JuliaInterface diff --git a/pkg/JuliaInterface/init.g b/pkg/JuliaInterface/init.g index c53e98aca..bf91cc98c 100644 --- a/pkg/JuliaInterface/init.g +++ b/pkg/JuliaInterface/init.g @@ -4,93 +4,9 @@ # Reading the declaration part of the package. # -#! @BeginChunk IncludeJuliaStartupFile -#! -#! User preference IncludeJuliaStartupFile -#! IncludeJuliaStartupFile -#! -#! When one starts an interactive &Julia; session, -#! the &Julia; startup file ~/.julia/config/startup.jl gets -#! included automatically by default, -#! see https://docs.julialang.org/en/v1/stdlib/REPL -#! the section The Julia REPL in the &Julia; documentation. -#! Hence the effects of this inclusion can be used in a ⪆ session -#! which one gets via the following input. -#! using GAP; GAP.prompt() -#!

-#! However, -#! this &Julia; startup file is not included into &Julia; by default -#! when ⪆ gets started via the gap.sh script that is created -#! during the installation of ⪆ (controlled by &Julia;). -#!

-#! The user preference IncludeJuliaStartupFile can be used to -#! force that the startup file gets included also in the latter situation, -#! as follows. -#!

-#! If the value is true then the file -#! ~/.julia/config/startup.jl -#! gets included into &Julia; after startup. -#! If the value is a nonempty string that is the name of a directory -#! then the startup.jl file in this directory gets included into -#! &Julia;. -#! Otherwise (this is the default) no startup.jl file will be -#! included automatically. -#! -#! @EndChunk IncludeJuliaStartupFile -## -DeclareUserPreference( rec( - package:= "JuliaInterface", - name:= "IncludeJuliaStartupFile", - description:= [ - "If the value is 'true' then the file '~/.julia/config/startup.jl'", - "gets included into Julia after startup.", - "If the value is a nonempty string that is the name of a directory", - "then the 'startup.jl' file in this directory gets imported into", - "Julia.", - "Otherwise no 'startup.jl' file will be imported automatically,", - "since apparently 'libjulia' does not import such a file.", - ], - default:= "", - ) ); - LoadDynamicModule(_path_JuliaInterface_so); Unbind(_path_JuliaInterface_so); - -## -## Import the 'startup.jl' file if wanted. -## -CallFuncList( function() - local dir, filename, res; - - if JuliaEvalString( "Int64(Base.JLOptions().startupfile)" ) <> 2 then - # Julia has already read the file, do not read it again. - return; - fi; - - dir:= UserPreference( "JuliaInterface", "IncludeJuliaStartupFile" ); - if dir = true then - filename:= Filename( DirectoryHome(), ".julia/config/startup.jl" ); - elif IsString( dir ) and dir <> "" then - filename:= Filename( Directory( dir ), "startup.jl" ); - else - return; - fi; - - if IsReadableFile( filename ) then - res:= JuliaEvalString( - Concatenation( "try include( \"", filename, "\" ); ", - "; return true; catch e; return e; end" ) ); - if res = true then - return; - fi; - fi; - - Info( InfoWarning, 1, - "The file '", filename, "' cannot be included by Julia." ); - end, [] ); - - ReadPackage( "JuliaInterface", "gap/JuliaInterface.gd"); ReadPackage( "JuliaInterface", "gap/convert.gd" ); diff --git a/src/setup.jl b/src/setup.jl index 1b52a5ce7..8b829c125 100644 --- a/src/setup.jl +++ b/src/setup.jl @@ -286,7 +286,13 @@ function create_gap_sh(dstdir::String) # But you can always instead load this file as if it was a .jl file via any # other Julia executable. #= - exec $(joinpath(Sys.BINDIR, Base.julia_exename())) --startup-file=no --project=$(dstdir) -i -- "$(gap_sh_path)" "\$@" + if [ "\$JULIA_STARTUP_FILE_IN_GAP" = "yes" ] + then + READ_STARTUP_FILE="yes" + else + READ_STARTUP_FILE="no" + fi + exec $(joinpath(Sys.BINDIR, Base.julia_exename())) --startup-file=\$READ_STARTUP_FILE --project=$(dstdir) -i -- "$(gap_sh_path)" "\$@" =# # pass command line arguments to GAP.jl via a small hack