From f554c397e47b18e025281c1efb08866e77671e0c Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 25 Jan 2017 11:14:26 +0100 Subject: [PATCH 01/17] Add ExtendPackageDirectories() and GAPInfo.PackageDirectories This is a first step towards allowing package directories to be specified independently from GAP root paths. --- doc/ref/files.xml | 10 ++++++++++ doc/ref/gappkg.xml | 1 + lib/package.gd | 26 +++++++++++++++++++++++++- lib/package.gi | 43 +++++++++++++++++++++++++++++++++++++++++-- lib/system.g | 1 + 5 files changed, 78 insertions(+), 3 deletions(-) diff --git a/doc/ref/files.xml b/doc/ref/files.xml index 4da8aca5af..f9de661086 100644 --- a/doc/ref/files.xml +++ b/doc/ref/files.xml @@ -100,6 +100,16 @@ for more information how to do this. + +
+GAP Package Directories +GAPInfo.PackagePaths + +TODO + +
+ +
Directories diff --git a/doc/ref/gappkg.xml b/doc/ref/gappkg.xml index 03751f2757..1fa68f75d5 100644 --- a/doc/ref/gappkg.xml +++ b/doc/ref/gappkg.xml @@ -96,6 +96,7 @@ that is they will be loaded automatically when &GAP; starts <#Include Label="SetPackagePath"> <#Include Label="ExtendRootDirectories"> +<#Include Label="ExtendPackageDirectories"> <#Include Label="DisplayPackageLoadingLog">
diff --git a/lib/package.gd b/lib/package.gd index 8136cc518d..4c51d3819d 100644 --- a/lib/package.gd +++ b/lib/package.gd @@ -859,7 +859,8 @@ DeclareGlobalFunction( "LoadPackage" ); ##

## See for a way to force the loading of a ## prescribed package version. -## See also for a method of adding +## See also and +## for methods of adding ## directories containing packages after &GAP; has been started. ## ## <#/GAPDoc> @@ -947,6 +948,29 @@ DeclareGlobalFunction( "SetPackagePath" ); ## DeclareGlobalFunction( "ExtendRootDirectories" ); + +############################################################################# +## +#F ExtendPackageDirectories( ) +## +## <#GAPDoc Label="ExtendPackageDirectories"> +## +## +## +## +## Let paths be a list of strings that denote paths to intended +## &GAP; package directories (see ). +## The function adds these paths to +## the global list GAPInfo.PackagePaths and calls the initialization of +## available &GAP; packages, +## such that later calls to will find the &GAP; +## packages that are contained in the directories given by paths. +## +## +## <#/GAPDoc> +## +DeclareGlobalFunction( "ExtendPackageDirectories" ); + ############################################################################# ## #F InstalledPackageVersion( ) diff --git a/lib/package.gi b/lib/package.gi index e7780524bf..94f570d060 100644 --- a/lib/package.gi +++ b/lib/package.gi @@ -300,8 +300,17 @@ InstallGlobalFunction( InitializePackagesInfoRecords, function( arg ) LogPackageLoadingMessage( PACKAGE_DEBUG, "entering InitializePackagesInfoRecords", "GAP" ); + + # add any new pkg directories to the list pkgdirs:= DirectoriesLibrary( "pkg" ); - if pkgdirs = fail then + if pkgdirs <> fail then + pkgdirs:= Filtered( pkgdirs, dir -> not dir in GAPInfo.PackageDirectories ); + if not IsEmpty(pkgdirs) then + APPEND_LIST_INTR( GAPInfo.PackageDirectories, pkgdirs ); + fi; + fi; + + if IsEmpty(GAPInfo.PackageDirectories) then LogPackageLoadingMessage( PACKAGE_DEBUG, "exit InitializePackagesInfoRecords (no pkg directories found)", "GAP" ); @@ -327,7 +336,7 @@ InstallGlobalFunction( InitializePackagesInfoRecords, function( arg ) # Loop over the package directories, # remove the packages listed in `NOAUTO' files from GAP's suggested # packages, and unite the information for the directories. - for pkgdir in pkgdirs do + for pkgdir in GAPInfo.PackageDirectories do if IsBound( GAPInfo.ExcludeFromAutoload ) then UniteSet( GAPInfo.ExcludeFromAutoload, @@ -1936,6 +1945,7 @@ InstallGlobalFunction( ExtendRootDirectories, function( rootpaths ) local i; rootpaths:= Filtered( rootpaths, path -> not path in GAPInfo.RootPaths ); + # TODO: validate the paths??? if not IsEmpty( rootpaths ) then # 'DirectoriesLibrary' concatenates root paths with directory names. for i in [ 1 .. Length( rootpaths ) ] do @@ -1958,6 +1968,35 @@ InstallGlobalFunction( ExtendRootDirectories, function( rootpaths ) end ); +############################################################################# +## +#F ExtendPackageDirectories( ) +## +InstallGlobalFunction( ExtendPackageDirectories, function( paths_or_dirs ) + local p, changed; + changed:= false; + for p in paths_or_dirs do + if IsString( p ) then + p:= Directory( p ); + elif not IsDirectory( p ) then + Error("input must be a list of path strings or directory objects"); + fi; + if not p in GAPInfo.PackageDirectories then + Add( GAPInfo.PackageDirectories, p ); + changed:= true; + fi; + od; + if changed then + # Reread the package information. + if IsBound( GAPInfo.PackagesInfoInitialized ) and + GAPInfo.PackagesInfoInitialized = true then + GAPInfo.PackagesInfoInitialized:= false; + InitializePackagesInfoRecords(); + fi; + fi; + end ); + + ############################################################################# ## #F InstalledPackageVersion( ) diff --git a/lib/system.g b/lib/system.g index d79aca2008..d63219bce8 100644 --- a/lib/system.g +++ b/lib/system.g @@ -302,6 +302,7 @@ CallAndInstallPostRestore( function() # paths GAPInfo.RootPaths:= GAPInfo.KernelInfo.GAP_ROOT_PATHS; + GAPInfo.PackageDirectories := []; if IsBound(GAPInfo.SystemEnvironment.HOME) then GAPInfo.UserHome := GAPInfo.SystemEnvironment.HOME; else From ddb1d992f0710022b3eb753e53f0b6ce710fffed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Tue, 17 Dec 2024 17:04:02 +0100 Subject: [PATCH 02/17] Make name consistent --- doc/ref/files.xml | 2 +- lib/package.gd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ref/files.xml b/doc/ref/files.xml index f9de661086..93d4d9c696 100644 --- a/doc/ref/files.xml +++ b/doc/ref/files.xml @@ -103,7 +103,7 @@ for more information how to do this.

GAP Package Directories -GAPInfo.PackagePaths +GAPInfo.PackageDirectories TODO diff --git a/lib/package.gd b/lib/package.gd index 4c51d3819d..cc1de684f0 100644 --- a/lib/package.gd +++ b/lib/package.gd @@ -961,7 +961,7 @@ DeclareGlobalFunction( "ExtendRootDirectories" ); ## Let paths be a list of strings that denote paths to intended ## &GAP; package directories (see ). ## The function adds these paths to -## the global list GAPInfo.PackagePaths and calls the initialization of +## the global list GAPInfo.PackageDirectories and calls the initialization of ## available &GAP; packages, ## such that later calls to will find the &GAP; ## packages that are contained in the directories given by paths. From 99e7acba1891ff2d353103a0cd1762dfad5f5e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Tue, 17 Dec 2024 17:09:11 +0100 Subject: [PATCH 03/17] Add doc for `GAPInfo.PackageDirectories` --- doc/ref/files.xml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/ref/files.xml b/doc/ref/files.xml index 93d4d9c696..23b97eb803 100644 --- a/doc/ref/files.xml +++ b/doc/ref/files.xml @@ -81,10 +81,6 @@ directories. For example when &GAP; wants to read its library file GAPInfo.RootPaths until it finds the path of an existing file. The first file found this way is read.

-Furthermore, &GAP; looks for available packages by examining the -subdirectories pkg/ in each of the directories in -GAPInfo.RootPaths. -

The root directories are specified via one or several of the -l paths command line options, see . Furthermore, by default &GAP; automatically prepends a user specific &GAP; root @@ -105,7 +101,15 @@ for more information how to do this. GAP Package Directories GAPInfo.PackageDirectories -TODO +When &GAP; is started it determines a list of directories potentially +containing packages called the &GAP; package directories. +In a running &GAP; session this list can be found in GAPInfo.PackageDirectories. +

+Every subdirectory pkg/ in a &GAP; root directory is automatically +added to this list. +

+&GAP; looks for available packages by examining each of the directories in +GAPInfo.PackageDirectories.

From e473f8e066c989252fd1e21f9b440c2a933d3b5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Wed, 18 Dec 2024 12:04:29 +0100 Subject: [PATCH 04/17] Add cmd line arg --- lib/package.gi | 9 ++++++++- lib/system.g | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/package.gi b/lib/package.gi index 94f570d060..3b27a3ece5 100644 --- a/lib/package.gi +++ b/lib/package.gi @@ -286,7 +286,7 @@ end ); ## In earlier versions, this function had an argument; now we ignore it. ## InstallGlobalFunction( InitializePackagesInfoRecords, function( arg ) - local pkgdirs, pkgdir, ignore, name, files, record, r; + local pkgdirs, pkgdir, pkgdirstrs, ignore, name, files, record, r; if IsBound( GAPInfo.PackagesInfoInitialized ) and GAPInfo.PackagesInfoInitialized = true then @@ -301,6 +301,13 @@ InstallGlobalFunction( InitializePackagesInfoRecords, function( arg ) LogPackageLoadingMessage( PACKAGE_DEBUG, "entering InitializePackagesInfoRecords", "GAP" ); + # the first time this is called, add the cmd line args to the list + if IsEmpty(GAPInfo.PackageDirectories) then + for pkgdirstrs in GAPInfo.CommandLineOptions.packagedirs do + pkgdirs:= List( SplitString( pkgdirstrs, ";" ), Directory); + APPEND_LIST_INTR( GAPInfo.PackageDirectories, pkgdirs ); + od; + fi; # add any new pkg directories to the list pkgdirs:= DirectoriesLibrary( "pkg" ); if pkgdirs <> fail then diff --git a/lib/system.g b/lib/system.g index d63219bce8..f9bb0f3b35 100644 --- a/lib/system.g +++ b/lib/system.g @@ -95,6 +95,9 @@ BIND_GLOBAL( "GAPInfo", rec( "directories to the end/start of existing list", "of root paths" ] ), rec( short:= "r", default := false, help := ["disable/enable user GAP root dir", "GAPInfo.UserGapRoot"] ), + rec( long := "packagedirs", default := [], arg := "", + help := [ "set or modify the GAP directory paths", + "Directories are separated using ';'." ] ), , rec( section:= ["Loading:"] ), rec( short:= "A", default := false, help := ["disable/enable autoloading of suggested", "GAP packages"] ), From 19b6e5a365a862bdda7e88ba0b5f29210af0207e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 20 Dec 2024 11:00:16 +0100 Subject: [PATCH 05/17] Improve documentation --- doc/ref/files.xml | 12 ++++++++++-- doc/ref/run.xml | 21 +++++++++++++++++++++ lib/package.gi | 1 - lib/system.g | 2 +- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/doc/ref/files.xml b/doc/ref/files.xml index 23b97eb803..0041579312 100644 --- a/doc/ref/files.xml +++ b/doc/ref/files.xml @@ -81,6 +81,10 @@ directories. For example when &GAP; wants to read its library file GAPInfo.RootPaths until it finds the path of an existing file. The first file found this way is read.

+Subdirectories pkg/ in each of the directories in GAPInfo.RootPaths +appear in GAPInfo.PackageDirectories (see ), +which controls where &GAP; looks for available packages. +

The root directories are specified via one or several of the -l paths command line options, see . Furthermore, by default &GAP; automatically prepends a user specific &GAP; root @@ -91,6 +95,8 @@ This directory can be used to tell &GAP; about personal preferences, to always load some additional code, to install additional packages, or to overwrite some &GAP; files. See for more information how to do this. +After &GAP; has been started , one can add additional root directories +via the function .

@@ -106,11 +112,13 @@ containing packages called the &GAP; package directories. In a running &GAP; session this list can be found in GAPInfo.PackageDirectories.

Every subdirectory pkg/ in a &GAP; root directory is automatically -added to this list. +added to this list. Further package directories can be specified via one or several of the +-/packagedirs paths command line options, see , +or after &GAP; has been started via the function .

&GAP; looks for available packages by examining each of the directories in GAPInfo.PackageDirectories. - +The root directories are specified diff --git a/doc/ref/run.xml b/doc/ref/run.xml index 1036832c75..53e4924eec 100644 --- a/doc/ref/run.xml +++ b/doc/ref/run.xml @@ -260,6 +260,27 @@ It is not possible to use &GAP; without the library files, so you must not ignore this warning. You should leave &GAP; and start it again, specifying the correct root path using the -l option. +-L +-l path_list + +can be used to add paths to &GAP;'s list of package directories +(see ). +The list always contains all subdirectories pkg/ in a &GAP; root directory. +

+path_list should be a list of directories separated by semicolons. +No whitespace is permitted before or after a semicolon, and the first and +last character of path_list may not be a semicolon. +After &GAP; has completed its startup procedure and +displays the prompt, the list of package directories can be seen in the +variable GAPInfo.PackageDirectories, +see . +

+Usually this option is used inside a startup script to specify +where additional &GAP; packages are located on the system. +The -l option can also be used by individual users to tell &GAP; +about additional &GAP; packages, without the need to setup a complete root +directory structure. + -M -M diff --git a/lib/package.gi b/lib/package.gi index 3b27a3ece5..d394843f48 100644 --- a/lib/package.gi +++ b/lib/package.gi @@ -1952,7 +1952,6 @@ InstallGlobalFunction( ExtendRootDirectories, function( rootpaths ) local i; rootpaths:= Filtered( rootpaths, path -> not path in GAPInfo.RootPaths ); - # TODO: validate the paths??? if not IsEmpty( rootpaths ) then # 'DirectoriesLibrary' concatenates root paths with directory names. for i in [ 1 .. Length( rootpaths ) ] do diff --git a/lib/system.g b/lib/system.g index f9bb0f3b35..d3c5e5b110 100644 --- a/lib/system.g +++ b/lib/system.g @@ -96,7 +96,7 @@ BIND_GLOBAL( "GAPInfo", rec( "of root paths" ] ), rec( short:= "r", default := false, help := ["disable/enable user GAP root dir", "GAPInfo.UserGapRoot"] ), rec( long := "packagedirs", default := [], arg := "", - help := [ "set or modify the GAP directory paths", + help := [ "add additional GAP directory paths", "Directories are separated using ';'." ] ), , rec( section:= ["Loading:"] ), From 3ea581c253355f3bf04ec89531cf62e93c790193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 20 Dec 2024 11:12:02 +0100 Subject: [PATCH 06/17] Add missing duplicate filter --- lib/package.gi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/package.gi b/lib/package.gi index d394843f48..3827d40007 100644 --- a/lib/package.gi +++ b/lib/package.gi @@ -304,8 +304,12 @@ InstallGlobalFunction( InitializePackagesInfoRecords, function( arg ) # the first time this is called, add the cmd line args to the list if IsEmpty(GAPInfo.PackageDirectories) then for pkgdirstrs in GAPInfo.CommandLineOptions.packagedirs do - pkgdirs:= List( SplitString( pkgdirstrs, ";" ), Directory); - APPEND_LIST_INTR( GAPInfo.PackageDirectories, pkgdirs ); + pkgdirs:= List( SplitString( pkgdirstrs, ";" ), Directory ); + for pkgdir in pkgdirs do + if not pkgdir in GAPInfo.PackageDirectories then + Add( GAPInfo.PackageDirectories, pkgdir ); + fi; + od; od; fi; # add any new pkg directories to the list From 8ac81400ac381144e7f9e9276b0bc14f5a9617f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 20 Dec 2024 11:29:33 +0100 Subject: [PATCH 07/17] Apply suggestions from code review Co-authored-by: Max Horn Co-authored-by: Thomas Breuer --- doc/ref/files.xml | 7 +++---- doc/ref/run.xml | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/doc/ref/files.xml b/doc/ref/files.xml index 0041579312..b1c303239e 100644 --- a/doc/ref/files.xml +++ b/doc/ref/files.xml @@ -95,7 +95,7 @@ This directory can be used to tell &GAP; about personal preferences, to always load some additional code, to install additional packages, or to overwrite some &GAP; files. See for more information how to do this. -After &GAP; has been started , one can add additional root directories +After &GAP; has been started, one can add additional root directories via the function .

@@ -112,13 +112,12 @@ containing packages called the &GAP; package directories. In a running &GAP; session this list can be found in GAPInfo.PackageDirectories.

Every subdirectory pkg/ in a &GAP; root directory is automatically -added to this list. Further package directories can be specified via one or several of the --/packagedirs paths command line options, see , +added to this list. Further package directories can be specified via one or several +--packagedirs paths command line options, see , or after &GAP; has been started via the function .

&GAP; looks for available packages by examining each of the directories in GAPInfo.PackageDirectories. -The root directories are specified diff --git a/doc/ref/run.xml b/doc/ref/run.xml index 53e4924eec..bda36b9eff 100644 --- a/doc/ref/run.xml +++ b/doc/ref/run.xml @@ -260,8 +260,8 @@ It is not possible to use &GAP; without the library files, so you must not ignore this warning. You should leave &GAP; and start it again, specifying the correct root path using the -l option. --L --l path_list +--packagedirs +--packagedirs path_list can be used to add paths to &GAP;'s list of package directories (see ). @@ -277,7 +277,7 @@ see .

Usually this option is used inside a startup script to specify where additional &GAP; packages are located on the system. -The -l option can also be used by individual users to tell &GAP; +The --packagedirs option can also be used by individual users to tell &GAP; about additional &GAP; packages, without the need to setup a complete root directory structure. From 427a717c34cbf2ce698ef85b79171d36e8fbb840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 20 Dec 2024 11:32:49 +0100 Subject: [PATCH 08/17] Update doc/ref/run.xml Co-authored-by: Max Horn --- doc/ref/run.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ref/run.xml b/doc/ref/run.xml index bda36b9eff..e0c9aec5fe 100644 --- a/doc/ref/run.xml +++ b/doc/ref/run.xml @@ -278,7 +278,7 @@ see . Usually this option is used inside a startup script to specify where additional &GAP; packages are located on the system. The --packagedirs option can also be used by individual users to tell &GAP; -about additional &GAP; packages, without the need to setup a complete root +about additional &GAP; packages, without the need to set up a complete root directory structure. -M From 3343bb87ced577983ce365a63a67b8e08d30c3db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Sat, 21 Dec 2024 17:08:44 +0100 Subject: [PATCH 09/17] Add special case for pointing to a pkg instead of a pkgdir --- lib/package.gi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/package.gi b/lib/package.gi index 3827d40007..019c088d00 100644 --- a/lib/package.gi +++ b/lib/package.gi @@ -355,6 +355,10 @@ InstallGlobalFunction( InitializePackagesInfoRecords, function( arg ) LowercaseString ) ); fi; + # pkgdir may be a package instead of a package directory + files := FindPackageInfosInSubdirectories( pkgdir, "" ); + AddPackageInfos( files, pkgdir, ignore ); + # Loop over subdirectories of this package directory. for name in Set( DirectoryContents( Filename( pkgdir, "" ) ) ) do From b831fbcadc606348e2256d6d180b12d000efd401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Sat, 21 Dec 2024 17:09:53 +0100 Subject: [PATCH 10/17] Add test (removes test for `ExtendRootDirectories`) --- tst/testinstall/package.tst | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/tst/testinstall/package.tst b/tst/testinstall/package.tst index cd364a81b4..10e515fc9c 100644 --- a/tst/testinstall/package.tst +++ b/tst/testinstall/package.tst @@ -1,4 +1,4 @@ -#@local entry,equ,pair,sml,oldTermEncoding,pkginfo,info,tmp_dir,mockpkgpath,old_warning_level,p,n,filename,IsDateFormatValid,loadinfo,eval_loadinfo +#@local entry,equ,pair,sml,oldTermEncoding,pkginfo,info,mockpkgpath,old_warning_level,p,n,filename,IsDateFormatValid,loadinfo,eval_loadinfo gap> START_TEST("package.tst"); # CompareVersionNumbers( , [, \"equal\"] ) @@ -380,17 +380,9 @@ false gap> IsPackageLoaded("mockpkg", ">=2.0"); false -# load mockpkg via a symlink in a directory called `pkg` -# so we can test ExtendRootDirectories below -# first create a temporary directory for all of this -gap> tmp_dir := DirectoryTemporary( );; - -# create a subdirectory `/pkg` -gap> Exec( Concatenation( "mkdir -p ", Filename( tmp_dir, "/pkg" ) ) ); - -# make `/pkg/mockpkg` a symlink to `tst/mockpkg` -gap> Exec( Concatenation( "ln -sfn ", Filename( DirectoriesLibrary("tst/mockpkg"), "" )," ", Filename( tmp_dir, "pkg/mockpkg" ) ) ); -gap> mockpkgpath := Directory( Filename( tmp_dir, "pkg/mockpkg" ) );; +# load mockpkg first via SetPackagePath and later via +# ExtendPackageDirectories +gap> mockpkgpath := DirectoriesLibrary("tst/mockpkg")[1];; gap> ValidatePackageInfo(Filename(mockpkgpath, "PackageInfo.g")); true @@ -635,12 +627,8 @@ false gap> IsPackageLoaded("mockpkg", ">=2.0"); false -# now add the temporary directory created above as a new root directory -gap> filename:= ShallowCopy( Filename( tmp_dir, "" ) );; -gap> while EndsWith( filename, "/" ) do Remove( filename ); od; -gap> ExtendRootDirectories( [ filename ] ); -gap> ForAll( GAPInfo.RootPaths, x -> EndsWith( x, "/" ) ); -true +# now add the directory with mockpkgpath as a new package directory +gap> ExtendPackageDirectories( [ mockpkgpath ] ); # make sure that the newly discovered installation path matches # the path from which mockpkg was loaded above @@ -649,8 +637,7 @@ gap> Last( GAPInfo.PackagesInfo.mockpkg ).InstallationPath = true # -gap> SetPackagePath( "mockpkg", Filename( tmp_dir, "pkg/mockpkg" ) ); -gap> SetPackagePath( "mockpkg", Filename( tmp_dir, "pkg/mockpkg/" ) ); +gap> SetPackagePath( "mockpkg", Filename( mockpkgpath, "" ) ); gap> SetPackagePath( "mockpkg", "/some/other/directory" ); Error, another version of package mockpkg is already loaded From 22b0ef93ae94f287f5afaea73080bd0f8fb74b23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Sat, 21 Dec 2024 17:13:44 +0100 Subject: [PATCH 11/17] Add order to docs --- doc/ref/files.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/ref/files.xml b/doc/ref/files.xml index b1c303239e..59a52547a3 100644 --- a/doc/ref/files.xml +++ b/doc/ref/files.xml @@ -115,6 +115,10 @@ Every subdirectory pkg/ in a &GAP; root directory is automatically added to this list. Further package directories can be specified via one or several --packagedirs paths command line options, see , or after &GAP; has been started via the function . +The order of the directories in GAPInfo.PackageDirectories is as follows: +first the package directories specified via the command line option --packagedirs , +then the subdirectories of the &GAP; root directories that were known at startup in the +same order, and finally the directories added after &GAP; has been started.

&GAP; looks for available packages by examining each of the directories in GAPInfo.PackageDirectories. From acd18adc799b05c96bfd095b94be9cc28e865ca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Mon, 23 Dec 2024 16:58:17 +0100 Subject: [PATCH 12/17] Update doc/ref/run.xml Co-authored-by: Lukas Schnelle <33157020+schnellecom@users.noreply.github.com> --- doc/ref/run.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ref/run.xml b/doc/ref/run.xml index e0c9aec5fe..d3f465ee31 100644 --- a/doc/ref/run.xml +++ b/doc/ref/run.xml @@ -270,8 +270,8 @@ The list always contains all subdirectories pkg/ in a &GAP; root director path_list should be a list of directories separated by semicolons. No whitespace is permitted before or after a semicolon, and the first and last character of path_list may not be a semicolon. -After &GAP; has completed its startup procedure and -displays the prompt, the list of package directories can be seen in the +After &GAP; has completed its startup procedure and +displays the prompt, the list of package directories can be seen in the variable GAPInfo.PackageDirectories, see .

From 7daec4dd67b65be69b8c7e69ab6857193a260829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 3 Jan 2025 16:48:10 +0100 Subject: [PATCH 13/17] Adapt `testmockpkg` in `ci.sh` to use `--packagedirs` --- dev/ci.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dev/ci.sh b/dev/ci.sh index f61e93b349..a39c816d21 100755 --- a/dev/ci.sh +++ b/dev/ci.sh @@ -99,11 +99,9 @@ testmockpkg () { cd "$mockpkg_dir" echo_and_run ./configure "$gaproot" echo_and_run $MAKE V=1 - # trick to make it easy to load the package in GAP - rm -f pkg && ln -sf . pkg # try to load the kernel extension cd "$gaproot" - echo_and_run $gap -A -l "$mockpkg_dir;" "$mockpkg_dir/tst/testall.g" + echo_and_run $gap -A --packagedirs "$mockpkg_dir" "$mockpkg_dir/tst/testall.g" } From dafdb122e28b8f0562a879bd1e74efb2c4e17042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Sat, 4 Jan 2025 13:24:53 +0100 Subject: [PATCH 14/17] Fix handling of pkdirs that directly contain a package --- lib/package.gi | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/package.gi b/lib/package.gi index 019c088d00..2c5f1b1199 100644 --- a/lib/package.gi +++ b/lib/package.gi @@ -286,7 +286,7 @@ end ); ## In earlier versions, this function had an argument; now we ignore it. ## InstallGlobalFunction( InitializePackagesInfoRecords, function( arg ) - local pkgdirs, pkgdir, pkgdirstrs, ignore, name, files, record, r; + local pkgdirs, pkgdir, pkgdirstrs, ignore, name, file, files, record, r; if IsBound( GAPInfo.PackagesInfoInitialized ) and GAPInfo.PackagesInfoInitialized = true then @@ -356,18 +356,20 @@ InstallGlobalFunction( InitializePackagesInfoRecords, function( arg ) fi; # pkgdir may be a package instead of a package directory - files := FindPackageInfosInSubdirectories( pkgdir, "" ); - AddPackageInfos( files, pkgdir, ignore ); - - # Loop over subdirectories of this package directory. - for name in Set( DirectoryContents( Filename( pkgdir, "" ) ) ) do + file:= Filename( [ pkgdir ], "PackageInfo.g" ); + if file <> fail then + AddPackageInfos( [ [ file, "" ] ], pkgdir, ignore ); + else + # Loop over subdirectories of this package directory. + for name in Set( DirectoryContents( Filename( pkgdir, "" ) ) ) do - ## Get all package dirs - files := FindPackageInfosInSubdirectories( pkgdir, name ); + ## Get all package dirs + files := FindPackageInfosInSubdirectories( pkgdir, name ); - AddPackageInfos( files, pkgdir, ignore ); + AddPackageInfos( files, pkgdir, ignore ); - od; + od; + fi; od; # Sort the available info records by their version numbers. From 1108b817526d06c606c6b680d1f560a7039b8f18 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 6 Jan 2025 13:37:41 +0100 Subject: [PATCH 15/17] Apply suggestions from code review --- doc/ref/files.xml | 12 ++++++------ doc/ref/run.xml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/ref/files.xml b/doc/ref/files.xml index 59a52547a3..75cb5f68b3 100644 --- a/doc/ref/files.xml +++ b/doc/ref/files.xml @@ -81,8 +81,8 @@ directories. For example when &GAP; wants to read its library file GAPInfo.RootPaths until it finds the path of an existing file. The first file found this way is read.

-Subdirectories pkg/ in each of the directories in GAPInfo.RootPaths -appear in GAPInfo.PackageDirectories (see ), +Any subdirectories named pkg/ in one of the directories in GAPInfo.RootPaths +are added to GAPInfo.PackageDirectories (see ), which controls where &GAP; looks for available packages.

The root directories are specified via one or several of the @@ -108,16 +108,16 @@ via the function . GAPInfo.PackageDirectories When &GAP; is started it determines a list of directories potentially -containing packages called the &GAP; package directories. +containing packages. We refer to these as the &GAP; package directories. In a running &GAP; session this list can be found in GAPInfo.PackageDirectories.

-Every subdirectory pkg/ in a &GAP; root directory is automatically +Every subdirectory pkg in a &GAP; root directory is automatically added to this list. Further package directories can be specified via one or several --packagedirs paths command line options, see , or after &GAP; has been started via the function . The order of the directories in GAPInfo.PackageDirectories is as follows: -first the package directories specified via the command line option --packagedirs , -then the subdirectories of the &GAP; root directories that were known at startup in the +first the package directories specified via the command line option --packagedirs, +then the subdirectories pkg of the &GAP; root directories that were known at startup in the same order, and finally the directories added after &GAP; has been started.

&GAP; looks for available packages by examining each of the directories in diff --git a/doc/ref/run.xml b/doc/ref/run.xml index d3f465ee31..c59bfe4a93 100644 --- a/doc/ref/run.xml +++ b/doc/ref/run.xml @@ -265,7 +265,7 @@ specifying the correct root path using the -l option. can be used to add paths to &GAP;'s list of package directories (see ). -The list always contains all subdirectories pkg/ in a &GAP; root directory. +The list always contains all subdirectories pkg in a &GAP; root directory.

path_list should be a list of directories separated by semicolons. No whitespace is permitted before or after a semicolon, and the first and From 41fb61ba7d8e621aad68a3c010d03f791fbee150 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 6 Jan 2025 13:43:49 +0100 Subject: [PATCH 16/17] Apply suggestions from code review --- lib/package.gi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/package.gi b/lib/package.gi index 2c5f1b1199..dfd9f16b07 100644 --- a/lib/package.gi +++ b/lib/package.gi @@ -317,7 +317,7 @@ InstallGlobalFunction( InitializePackagesInfoRecords, function( arg ) if pkgdirs <> fail then pkgdirs:= Filtered( pkgdirs, dir -> not dir in GAPInfo.PackageDirectories ); if not IsEmpty(pkgdirs) then - APPEND_LIST_INTR( GAPInfo.PackageDirectories, pkgdirs ); + Append( GAPInfo.PackageDirectories, pkgdirs ); fi; fi; @@ -356,12 +356,12 @@ InstallGlobalFunction( InitializePackagesInfoRecords, function( arg ) fi; # pkgdir may be a package instead of a package directory - file:= Filename( [ pkgdir ], "PackageInfo.g" ); + file:= Filename( pkgdir, "PackageInfo.g" ); if file <> fail then AddPackageInfos( [ [ file, "" ] ], pkgdir, ignore ); else # Loop over subdirectories of this package directory. - for name in Set( DirectoryContents( Filename( pkgdir, "" ) ) ) do + for name in Set( DirectoryContents( pkgdir ) ) do ## Get all package dirs files := FindPackageInfosInSubdirectories( pkgdir, name ); From 99be4d3e418f3fba10f15c4ba53d07282a7c6a84 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 6 Jan 2025 14:00:47 +0100 Subject: [PATCH 17/17] oops --- lib/package.gi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/package.gi b/lib/package.gi index dfd9f16b07..0a0068a7d6 100644 --- a/lib/package.gi +++ b/lib/package.gi @@ -356,7 +356,7 @@ InstallGlobalFunction( InitializePackagesInfoRecords, function( arg ) fi; # pkgdir may be a package instead of a package directory - file:= Filename( pkgdir, "PackageInfo.g" ); + file:= Filename( [ pkgdir ], "PackageInfo.g" ); if file <> fail then AddPackageInfos( [ [ file, "" ] ], pkgdir, ignore ); else