-
Notifications
You must be signed in to change notification settings - Fork 160
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
Support several package instances with same version #3668
Conversation
Yes, in older GAP versions, two paths in However, I actually always thought that the intention behind the code in |
lib/package.gi
Outdated
# We are not allowed to call | ||
# `InstalledPackageVersion', `TestPackageAvailability' etc. | ||
info:= PackageInfo( name ); | ||
if IsBound( GAPInfo.PackagesLoaded.( name ) ) then | ||
# The package is already loaded. | ||
version:= GAPInfo.PackagesLoaded.( name )[2]; | ||
ppath:= GAPInfo.PackagesLoaded.( name )[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does ppath stand for? "package path"? I first thought it was a typo. So, optional suggestion: revert to path
, or use a more expressive name, like pkg_path
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted the code of DirectoriesPackageLibrary
and DirectoriesPackagePrograms
to be similar, and path
was already used in one of them.
I can choose another variable name, but I think this discussion is not useful.
lib/package.gi
Outdated
version:= info[1].Version; | ||
# Take the installed package with the highest version | ||
# that has been found first in the root paths. | ||
ppath:= info[1].InstallationPath; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, that's a semantical change now, isn't it? Before we took all packages with the same version, and for each took its path. Now, you only take the first one, and ignore the rest.
Is that intentional? Why? Also, is this covered by the PR description? Maybe it is, but I don't quite understand all in there, either. E.g. what does this mean:
DirectoriesPackagePrograms and DirectoriesPackageLibrary now search according to the installation path, not to the version number
I think this confused me because "search" is ambiguous here. When reading that comment, I am thinking about loading packages, and then "search" immediately leads me to think about "searching the pkg dirs in the GAP roots for PackageInfo.g files".
Anyway, I really had to look at the code to understand what is going on, and even now, I am not sure I fully understand. I need to look at that code in a wider context, I think (i.e., open up the file, and read)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand the comment.
The list info
contains all info records for the package in question, sorted by decreasing version number (and in the new version, where several records for the same version can exist, also sorted according to the ordering of the root paths where they were found).
In the old version, we fetch the version number and later look up the (unique) info record with this version number in order to fetch its path.
In the new version, we fetch the path directly.
(Perhaps the reason for the confusion is the for
loop in the old version, which did not find more than one entry to add because there was only one package for the given version.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the confusion is: why is there only one record for each given version? My (apparently wrong) impression was that the plan with this patch was to add all copies of a given package we find to our records, even those with identical version; but keep them sorted in the order we find them; and then when looking for binaries, we search all copies of the latest version. But it seems I misunderstood the intentions here?
And I still think that the phrase "search according to the installation path" is completely unclear. You now wrote "sorted according to the ordering of the root paths where they were found" which makes much more senes to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fingolfin Thanks for the explanations.
As I had written in the description, the idea is to admit instances of a package with the same version numbers, in the sense that the package is regarded as loadable if there is one instance which is loadable.
This means in particular that it is not supported to "distribute the parts of a package to different root directories", for example to have a valid package binary only in one directory, some GAP functions of the package only in a second directory, and some package data only in a third directory.
(Concerning the test failure due to decreased coverage:
The coverage decreases when one removes some useless but covered code lines.
And when one changes or moves an uncovered line then apparently this counts as the introduction of a new uncovered line.
Very helpful.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The coverage failure does not block merging, only actual test suite failures do (this is configured in the "branch protection rules"). The PR status says "Merging is blocked" not because of the "failing" coverage, but because there is no approving review yet.
@fingolfin Concerning the remark
Multiple instances of the same version of a package were not supported up to now, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR and the explanations, this looks fine to me, now that I understand better what the intentions here are :-).
- `AddPackageInfos` does no longer ignore package installations for which one instance with the same version number has already been found. - `InitializePackagesInfoRecords` sorts the info records stably, in order to achieve that the loadable instance gets chosen in the first possible root directory. - `DirectoriesPackagePrograms` and `DirectoriesPackageLibrary` now search according to the installation path, not to the version number. These changes are intended to fix issue gap-system#3663.
- changed the documentation of `DirectoriesPackagePrograms` and `DirectoriesPackageLibrary`, such that it is clear that one gets either no directory or just one - fixed the (not testable) manual example for `DirectoriesPackagePrograms` - and beautified the name of a local variable
fe1bd68
to
df57dd8
Compare
Thanks to both of you @ThomasBreuer @fingolfin. |
AddPackageInfos
does no longer ignore package installations for which one instance with the same version number has already been found.InitializePackagesInfoRecords
sorts the info records stably, in order to achieve that the loadable instance gets chosen in the first possible root directory.DirectoriesPackagePrograms
andDirectoriesPackageLibrary
now search according to the installation path, not to the version number.This pull request is intended to fix issue #3663.
Two related questions:
DirectoriesPackagePrograms
shows an output of length larger than 1.AddPackageInfos
contains aFIXME
comment that mentions the (closed) issue Immutable GAPInfo.PackagesInfo records: Problems forJuliaInterface
andfloat
#2568. Should we remove theFIXME
, or shouldMakeImmutable
perhaps be called in general, not just in theIsHPCGAP
situation?Text for release notes
If several instances of a package, with the same version number, are available in the root directories, and if the first such instance cannot be loaded (because a compiled module is missing or does not fit) then the other instances are considered for being loaded.
In earlier versions, only the first instance of a given package version was considered.