Spack can automatically remove unused specs#13534
Conversation
|
Example of use: $ spack find
==> 36 installed packages
-- linux-ubuntu18.04-broadwell / [email protected] ----------------------
[email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]
[email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]
[email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]
[email protected] [email protected] [email protected] [email protected] [email protected] [email protected]
[email protected] [email protected] [email protected] [email protected] [email protected] [email protected]
-- linux-ubuntu18.04-x86_64 / [email protected] -------------------------
[email protected] [email protected] [email protected]
$ spack autoremove
==> The following packages will be uninstalled:
-- linux-ubuntu18.04-broadwell / [email protected] ----------------------
vn47edz [email protected]%gcc
ki6nfw5 [email protected]%gcc
mrptssh [email protected]%gcc
fklde6b [email protected]%gcc
ubl6bgk [email protected]%gcc
b6pswuo [email protected]%gcc patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 +sigsegv
k3s2csy [email protected]%gcc +cpanm+shared+threads
5vmfbrq [email protected]%gcc
urdw22a [email protected]%gcc
==> Do you want to proceed? [y/N] y
==> Successfully uninstalled [email protected]%[email protected] arch=linux-ubuntu18.04-broadwell/mrptssh
==> Successfully uninstalled [email protected]%[email protected] arch=linux-ubuntu18.04-broadwell/ubl6bgk
==> Successfully uninstalled [email protected]%[email protected] arch=linux-ubuntu18.04-broadwell/5vmfbrq
==> Successfully uninstalled [email protected]%[email protected] arch=linux-ubuntu18.04-broadwell/vn47edz
==> Successfully uninstalled [email protected]%[email protected] arch=linux-ubuntu18.04-broadwell/ki6nfw5
==> Successfully uninstalled [email protected]%[email protected]+cpanm+shared+threads arch=linux-ubuntu18.04-broadwell/k3s2csy
==> Successfully uninstalled [email protected]%[email protected] patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 +sigsegv arch=linux-ubuntu18.04-broadwell/b6pswuo
==> Successfully uninstalled [email protected]%[email protected] arch=linux-ubuntu18.04-broadwell/fklde6b
==> Successfully uninstalled [email protected]%[email protected] arch=linux-ubuntu18.04-broadwell/urdw22a
$ spack find
==> 27 installed packages
-- linux-ubuntu18.04-broadwell / [email protected] ----------------------
[email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]
[email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]
[email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]
-- linux-ubuntu18.04-x86_64 / [email protected] -------------------------
[email protected] [email protected] [email protected] |
|
I need to check this PR copes well with environments, as it might not be the case. |
|
Some comments:
|
I have two reasons, even though I have to say that I don't feel strongly about this:
This PR started out like you suggest - see first commit. Factoring out a new command avoided me to check for error conditions among incompatible options of Even for the name of the command I am open to anything. I chose |
It removes anything with reference count equal to spack/lib/spack/spack/store.py Lines 129 to 150 in c296b13 If |
|
This is ready for a first review + test drive. The 80% coverage comes from the fact that there are functions requiring user interaction that are not covered - I'll try to check if there's any way to fake passing user input but I'm not so confident it exists. If anyone already knows it feel free to post 🙂 |
292a87c to
9d41f83
Compare
9d41f83 to
dd4c97d
Compare
dd4c97d to
f0864b0
Compare
This comment has been minimized.
This comment has been minimized.
|
@tgamblin I tried a few use cases moving in and out of environments. Preserving the root specs when doing garbage collection on the entire store seems highly unintuitive. The new behavior is currently to restrict garbage collection to the active environment, if any: $ # Outside of an environment
$ spack gc
==> The following packages will be uninstalled:
-- linux-ubuntu18.04-broadwell / [email protected] ----------------------
vn47edz [email protected] 6m3f2qn [email protected] ubl6bgk [email protected] pksawhz [email protected] urdw22a [email protected]
ki6nfw5 [email protected] fklde6b [email protected] b6pswuo [email protected] k3s2csy [email protected] lp5ya3t [email protected]
ylvgsov [email protected] 5omotir [email protected] leuzbbh [email protected] 5vmfbrq [email protected] 5bmv4tg [email protected]
$ # Inside an environment with only cmake and still to be installed
$ spack find
==> In environment /home/culpo/tmp/spack-issues/13534
==> Root specs
cmake
==> 0 installed packages
$ spack gc
==> Restricting the garbage collection to the "/home/culpo/tmp/spack-issues/13534" environment
==> The following packages will be uninstalled:
-- linux-ubuntu18.04-broadwell / [email protected] ----------------------
fklde6b [email protected] k3s2csy [email protected] 5vmfbrq [email protected] urdw22a [email protected]
==> Do you want to proceed? [y/N] |
3f6d094 to
a3724c4
Compare
fixes spack#4382 Added an option to spack uninstall that removes all unused specs i.e. build dependencies or transitive dependencies that are left in the store after the specs that pulled them in have been removed.
The command has been named 'spack autoremove' to follow the naming used for the same functionality by other widely known package managers i.e. yum and apt.
Following discussion there's more consensus around the latter name.
a3724c4 to
7aa4cd3
Compare
Rephrased a couple of sentences, added references to `spack find` and dependency types.
Since the new approach uses private attributes of the DB it has been coded as a method of that class rather than a freestanding function.
|
@tgamblin I think I addressed the comments in the review, let me know if there a more changes needed. |
fixes #4382
fixes #8291
This PR adds a new command called
spack autoremovespack gcthat removes all the specs that were necessary to build other specs but are currently unused. This includes build dependencies and implicit dependency of specs that have been already uninstalled.It provides a useful way to keep the environment clean after an upgrade or to minimize the size of installations within e.g. container images.
The nameautoremovehas been selected to be consistent with whatyumandaptuse for the same functionality.