-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add options to debug package manager #931
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,14 @@ function init_packagemanager() | |
# put the new method in the first position | ||
meths = Globals.Download_Methods | ||
Wrappers.Add(meths, GapObj(r, recursive=true), 1) | ||
|
||
# monkey patch PackageManager so that we can disable removal of | ||
# package directories for debugging purposes | ||
orig_PKGMAN_RemoveDir = Globals.PKGMAN_RemoveDir | ||
replace_global!(:PKGMAN_RemoveDir, function(dir) | ||
Globals.ValueOption(GapObj("debug")) == true && return | ||
orig_PKGMAN_RemoveDir(dir) | ||
end) | ||
end | ||
end | ||
|
||
|
@@ -186,6 +194,7 @@ end | |
""" | ||
install(spec::String, version::String = ""; | ||
interactive::Bool = true, quiet::Bool = false, | ||
debug::Bool = false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Of course this should also be documented; I'll do that once we settled on what final form this should have. |
||
pkgdir::AbstractString = GAP.Packages.DEFAULT_PKGDIR[]) | ||
|
||
Download and install the GAP package given by `spec` into the `pkgdir` | ||
|
@@ -213,28 +222,30 @@ For details, please refer to its documentation. | |
""" | ||
function install(spec::String, version::String = ""; | ||
interactive::Bool = true, quiet::Bool = false, | ||
debug::Bool = false, | ||
pkgdir::AbstractString = DEFAULT_PKGDIR[]) | ||
# point PackageManager to the given pkg dir | ||
Globals.PKGMAN_CustomPackageDir = GapObj(pkgdir) | ||
mkpath(pkgdir) | ||
|
||
if quiet | ||
if quiet || debug | ||
oldlevel = Wrappers.InfoLevel(Globals.InfoPackageManager) | ||
Wrappers.SetInfoLevel(Globals.InfoPackageManager, 0) | ||
Wrappers.SetInfoLevel(Globals.InfoPackageManager, quiet ? 0 : 3) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if it might not be better to separate So one idea would be to also add
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My viewpoint was that PackageManager's default info level is reasonable (otherwise this level should be changed there) but that there are situations where we want to suppress all info messages, for example if a package installation is triggered by the request to load a package. This is why There is of course no problem with the viewpoint that one should be able to set the info level in each single function call. I do not see why this is helpful here, but it is surely a "conceptual" feature which is currently not supported by PackageManager (Note that by default, the functions from Debugging is something different, the current proposal for |
||
end | ||
if version == "" | ||
res = Wrappers.InstallPackage(GapObj(spec), interactive) | ||
res = Globals.InstallPackage(GapObj(spec), interactive; debug) | ||
else | ||
res = Wrappers.InstallPackage(GapObj(spec), GapObj(version), interactive) | ||
res = Globals.InstallPackage(GapObj(spec), GapObj(version), interactive; debug) | ||
end | ||
if quiet | ||
if quiet || debug | ||
Wrappers.SetInfoLevel(Globals.InfoPackageManager, oldlevel) | ||
end | ||
return res | ||
end | ||
|
||
""" | ||
update(spec::String; interactive::Bool = true, quiet::Bool = false, | ||
debug::Bool = false, | ||
pkgdir::AbstractString = GAP.Packages.DEFAULT_PKGDIR[]) | ||
|
||
Update the GAP package given by `spec` that is installed in the | ||
|
@@ -253,19 +264,20 @@ prevent `PackageManager` from prompting the user for input interactively. | |
For details, please refer to its documentation. | ||
""" | ||
function update(spec::String; interactive::Bool = true, quiet::Bool = false, | ||
debug::Bool = false, | ||
pkgdir::AbstractString = DEFAULT_PKGDIR[]) | ||
# point PackageManager to the given pkg dir | ||
Globals.PKGMAN_CustomPackageDir = GapObj(pkgdir) | ||
mkpath(pkgdir) | ||
|
||
if quiet | ||
if quiet || debug | ||
oldlevel = Wrappers.InfoLevel(Globals.InfoPackageManager) | ||
Wrappers.SetInfoLevel(Globals.InfoPackageManager, 0) | ||
res = Wrappers.UpdatePackage(GapObj(spec), interactive) | ||
Wrappers.SetInfoLevel(Globals.InfoPackageManager, quiet ? 0 : 3) | ||
res = Globals.UpdatePackage(GapObj(spec), interactive; debug) | ||
Wrappers.SetInfoLevel(Globals.InfoPackageManager, oldlevel) | ||
return res | ||
else | ||
return Wrappers.UpdatePackage(GapObj(spec), interactive) | ||
return Globals.UpdatePackage(GapObj(spec), interactive) | ||
end | ||
end | ||
# note that the updated version cannot be used in the current GAP session, | ||
|
@@ -274,6 +286,7 @@ end | |
|
||
""" | ||
remove(spec::String; interactive::Bool = true, quiet::Bool = false, | ||
debug::Bool = false, | ||
pkgdir::AbstractString = GAP.Packages.DEFAULT_PKGDIR[]) | ||
|
||
Remove the GAP package with name `spec` that is installed in the | ||
|
@@ -288,19 +301,20 @@ prevent `PackageManager` from prompting the user for input interactively. | |
For details, please refer to its documentation. | ||
""" | ||
function remove(spec::String; interactive::Bool = true, quiet::Bool = false, | ||
debug::Bool = false, | ||
pkgdir::AbstractString = DEFAULT_PKGDIR[]) | ||
# point PackageManager to the given pkg dir | ||
Globals.PKGMAN_CustomPackageDir = GapObj(pkgdir) | ||
mkpath(pkgdir) | ||
|
||
if quiet | ||
if quiet || debug | ||
oldlevel = Wrappers.InfoLevel(Globals.InfoPackageManager) | ||
Wrappers.SetInfoLevel(Globals.InfoPackageManager, 0) | ||
res = Wrappers.RemovePackage(GapObj(spec), interactive) | ||
Wrappers.SetInfoLevel(Globals.InfoPackageManager, quiet ? 0 : 3) | ||
res = Globals.RemovePackage(GapObj(spec), interactive; debug) | ||
Wrappers.SetInfoLevel(Globals.InfoPackageManager, oldlevel) | ||
return res | ||
else | ||
return Wrappers.RemovePackage(GapObj(spec), interactive) | ||
return Globals.RemovePackage(GapObj(spec), interactive) | ||
end | ||
end | ||
|
||
|
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.
Of course we can remove this hack once we are using a PackageManager release with gap-packages/PackageManager#119 or something equivalent in it