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 support for the deprecated OtherPackagesLoadedInAdvance in PackageInfo.g #5912

Merged
merged 1 commit into from
Jan 22, 2025
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
76 changes: 4 additions & 72 deletions lib/package.gi
Original file line number Diff line number Diff line change
Expand Up @@ -689,12 +689,12 @@ InstallGlobalFunction( DisplayPackageLoadingLog, function( arg )
##
InstallGlobalFunction( PackageAvailabilityInfo,
function( name, version, record, suggested, checkall )
local comp, loadinfo, InvalidStrongDependencies, Name, equal, pair,
local comp, loadinfo, Name, equal, pair,
currversion, inforec, skip, msg, dep, currloadinfo, GAPequal,
record_local, wght, pos, needed, test, name2, testpair;

# Initialize the dependency info.
for comp in [ "AlreadyHandled", "Dependencies", "StrongDependencies",
for comp in [ "AlreadyHandled", "Dependencies",
"InstallationPaths", "Weights" ] do
if not IsBound( record.( comp ) ) then
record.( comp ):= [];
Expand All @@ -713,41 +713,6 @@ InstallGlobalFunction( PackageAvailabilityInfo,
loadinfo.versions:= [];
loadinfo.comment:= "";

InvalidStrongDependencies:= function( dependencies, weights,
strong_dependencies, loadinfo )
local result, order, pair, cycle;

result:= false;
if not IsEmpty( strong_dependencies ) then
order:= LinearOrderByPartialWeakOrder( dependencies, weights ).cycles;
for pair in strong_dependencies do
for cycle in order do
if IsSubset( cycle, pair ) then
# This condition was imposed by some
# `OtherPackagesLoadedInAdvance' component.
LogPackageLoadingMessage( PACKAGE_INFO,
[ Concatenation( "PackageAvailabilityInfo: package '",
pair[1], "'" ),
Concatenation( "shall be loaded before package '", name,
"' but must be" ),
"in the same load cycle, due to other dependencies" ],
Name );
Append( loadinfo.comment,
Concatenation( "package '", pair[1],
"' shall be loaded before package '", name,
"' but must be in the same load cycle, ",
"due to other dependencies, " ) );
result:= true;
if not checkall then
return result;
fi;
fi;
od;
od;
fi;
return result;
end;

Name:= name;
name:= LowercaseString( name );
equal:= "";
Expand Down Expand Up @@ -934,15 +899,9 @@ InstallGlobalFunction( PackageAvailabilityInfo,
# If the GAP library is not yet loaded then assign
# weight 0 to all packages that may be loaded before the GAP library,
# and weight 1 to those that need the GAP library to be loaded
# in advance.
# The latter means that either another package or the GAP library
# itself is forced to be loaded in advance,
# for example because the current package has no `read.g' file.
# in advance because they have no `read.g' file.
if Filename( [ Directory( inforec.InstallationPath ) ], "read.g" )
= fail or
( not IsBound( GAPInfo.LibraryLoaded ) and
IsBound( dep.OtherPackagesLoadedInAdvance ) and
not IsEmpty( dep.OtherPackagesLoadedInAdvance ) ) then
= fail and not IsBound( GAPInfo.LibraryLoaded ) then
wght:= 1;
else
wght:= 0;
Expand All @@ -956,12 +915,6 @@ InstallGlobalFunction( PackageAvailabilityInfo,

# Check the dependencies of this package version.
needed:= [];
if IsBound( dep.OtherPackagesLoadedInAdvance ) then
Append( record_local.StrongDependencies,
List( dep.OtherPackagesLoadedInAdvance,
x -> [ LowercaseString( x[1] ), name ] ) );
Append( needed, dep.OtherPackagesLoadedInAdvance );
fi;
if IsBound( dep.NeededOtherPackages ) then
Append( needed, dep.NeededOtherPackages );
fi;
Expand Down Expand Up @@ -1013,17 +966,6 @@ InstallGlobalFunction( PackageAvailabilityInfo,
skip:= true;
fi;

if InvalidStrongDependencies( record_local.Dependencies,
record_local.Weights, record_local.StrongDependencies, currloadinfo ) then
# This package version cannot be loaded due to conditions
# imposed by `OtherPackagesLoadedInAdvance' components.
# (Log messages are added inside the function.)
if not checkall then
continue;
fi;
skip:= true;
fi;

# All checks for this version have been performed.
# Go to the next installed version if some check failed.
if skip then
Expand All @@ -1037,7 +979,6 @@ InstallGlobalFunction( PackageAvailabilityInfo,
[ name, [ inforec.InstallationPath, inforec.Version,
inforec.PackageName, false ] ] );
record.Dependencies:= record_local.Dependencies;
record.StrongDependencies:= record_local.StrongDependencies;
record.AlreadyHandled:= record_local.AlreadyHandled;
record.Weights:= record_local.Weights;

Expand All @@ -1059,18 +1000,9 @@ InstallGlobalFunction( PackageAvailabilityInfo,
suggested, checkall );
if test <> true then
Add( record_local.Dependencies, [ name2, name ] );
if IsString( test ) then
if InvalidStrongDependencies( record_local.Dependencies,
record_local.Weights,
record_local.StrongDependencies,
rec( comment:= "" ) ) then
test:= false;
fi;
fi;
if test <> false then
record.InstallationPaths:= record_local.InstallationPaths;
record.Dependencies:= record_local.Dependencies;
record.StrongDependencies:= record_local.StrongDependencies;
record.AlreadyHandled:= record_local.AlreadyHandled;
record.Weights:= record_local.Weights;
fi;
Expand Down
33 changes: 9 additions & 24 deletions tst/testinstall/package.tst
Original file line number Diff line number Diff line change
Expand Up @@ -770,43 +770,28 @@ consider package mockpkg
comment: the AvailabilityTest function returned false,

# Try to load the package with not satisfied dependencies.
gap> GAPInfo.PackagesInfo.mockpkg2:= [
> rec( PackageName := "mockpkg2", Version:= "0.0",
> AvailabilityTest:= ReturnTrue,
> InstallationPath:= GAPInfo.PackagesInfo.gapdoc[1].InstallationPath,
> Dependencies:= rec( OtherPackagesLoadedInAdvance:= [ [ "mockpkg", "" ] ] ) ) ];;
gap> info.Dependencies.OtherPackagesLoadedInAdvance:= [ [ "mockpkg2", "" ] ];;
gap> info.Dependencies.NeededOtherPackages:= [ [ "mockpkg", "=0.0" ] ];;
gap> loadinfo:= rec();;
gap> LoadPackage( "mockpkg" : LoadInfo:= loadinfo );
fail
gap> loadinfo;
rec( comment := "", name := "mockpkg",
versions :=
[
rec(
comment := "package 'mockpkg2' shall be loaded before package 'mockpk\
g' but must be in the same load cycle, due to other dependencies, ",
rec( comment := "",
dependencies :=
[
rec( comment := "", name := "mockpkg2",
versions :=
[
rec( comment := "",
dependencies :=
[
rec( comment := "", name := "mockpkg",
versions := [ ] ) ], version := "0.0" ) ]
) ], version := "0.1" ) ] )
rec(
comment := "for package 'mockpkg', version 0.1 is assumed on \
an outer level, but version =0.0 is required here", name := "mockpkg",
versions := [ ] ) ], version := "0.1" ) ] )
gap> eval_loadinfo( loadinfo );;
consider package mockpkg
consider version 0.1:
comment: package 'mockpkg2' shall be loaded before package 'mockpkg' but m\
ust be in the same load cycle, due to other dependencies,
dependencies:
consider package mockpkg2
consider version 0.0:
dependencies:
consider package mockpkg
consider package mockpkg
comment: for package 'mockpkg', version 0.1 is assumed on an outer lev\
el, but version =0.0 is required here
gap> Unbind( info.Dependencies.OtherPackagesLoadedInAdvance );
gap> Unbind( GAPInfo.PackagesInfo.mockpkg2 );
gap> info.Dependencies.NeededOtherPackages:= [ [ "gapdoc", "=0.0" ] ];;
Expand Down
Loading