Skip to content

Commit

Permalink
change the handling of IncludeJuliaStartupFile (for Julia 1.10) (#1017
Browse files Browse the repository at this point in the history
)

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`.
  • Loading branch information
ThomasBreuer authored Jul 2, 2024
1 parent 8c2a8a8 commit efac892
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 88 deletions.
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
3 changes: 0 additions & 3 deletions pkg/JuliaInterface/gap/JuliaInterface.gd
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@
#! <URL><Link>https://github.com/oscar-system/GAP.jl</Link>
#! <LinkText>the &Julia; package <C>GAP.jl</C></LinkText></URL>,
#! hence it can be found there.
#!
#! @Section User preferences in the <Package>JuliaInterface</Package> package
#! @InsertChunk IncludeJuliaStartupFile

#! @Chapter Using &Julia; from &GAP;
#! @Section Filters for <Package>JuliaInterface</Package>
Expand Down
84 changes: 0 additions & 84 deletions pkg/JuliaInterface/init.g
Original file line number Diff line number Diff line change
Expand Up @@ -4,93 +4,9 @@
# Reading the declaration part of the package.
#

#! @BeginChunk IncludeJuliaStartupFile
#! <Subsection Label="subsect:IncludeJuliaStartupFile">
#! <Heading>User preference <C>IncludeJuliaStartupFile</C></Heading>
#! <Index Key="IncludeJuliaStartupFile"><C>IncludeJuliaStartupFile</C></Index>
#!
#! When one starts an interactive &Julia; session,
#! the &Julia; startup file <F>~/.julia/config/startup.jl</F> gets
#! included automatically by default,
#! see <URL><Link>https://docs.julialang.org/en/v1/stdlib/REPL</Link>
#! <LinkText>the section <Q>The Julia REPL</Q> in the &Julia; documentation</LinkText></URL>.
#! Hence the effects of this inclusion can be used in a &GAP; session
#! which one gets via the following input.
#! <Listing Type="Julia">using GAP; GAP.prompt()</Listing>
#! <P/>
#! However,
#! this &Julia; startup file is <E>not</E> included into &Julia; by default
#! when &GAP; gets started via the <F>gap.sh</F> script that is created
#! during the installation of &GAP; (controlled by &Julia;).
#! <P/>
#! The user preference <C>IncludeJuliaStartupFile</C> can be used to
#! force that the startup file gets included also in the latter situation,
#! as follows.
#! <P/>
#! If the value is <K>true</K> then the file
#! <F>~/.julia/config/startup.jl</F>
#! gets included into &Julia; after startup.
#! If the value is a nonempty string that is the name of a directory
#! then the <F>startup.jl</F> file in this directory gets included into
#! &Julia;.
#! Otherwise (this is the default) no <F>startup.jl</F> file will be
#! included automatically.
#! </Subsection>
#! @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" );
8 changes: 7 additions & 1 deletion src/setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit efac892

Please sign in to comment.