common-inputs.scm 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. (use-modules (gnu packages)
  2. (guix packages)
  3. (ice-9 match)
  4. (srfi srfi-1)
  5. (srfi srfi-26))
  6. (define* (package-all-inputs package #:key transitive?)
  7. (filter
  8. package? ;eliminate origin objects
  9. (map (match-lambda
  10. ((name package output ...)
  11. package))
  12. (delete-duplicates
  13. (remove null?
  14. (if transitive?
  15. (append (package-transitive-inputs package)
  16. (package-transitive-native-inputs package)
  17. (package-transitive-propagated-inputs package))
  18. (append (package-inputs package)
  19. (package-native-inputs package)
  20. (package-propagated-inputs package))))))))
  21. (define* (common-inputs packages #:key transitive?)
  22. (apply lset-intersection eq?
  23. (map (cut package-all-inputs <> #:transitive? transitive?)
  24. packages)))
  25. (define* (common-inputs-count packages #:key transitive?)
  26. (let* ((package-sets (map (cut package-all-inputs <> #:transitive? transitive?)
  27. packages))
  28. (packages (concatenate package-sets))
  29. (unique-packages (delete-duplicates packages)))
  30. (sort (fold (lambda (p result)
  31. (cons (cons p (count (cut eq? p <>) packages))
  32. result))
  33. '()
  34. unique-packages)
  35. (lambda (x y)
  36. (> (cdr x) (cdr y))))))
  37. (define* (pp-inputs-count inputs-count #:key (max-count 20))
  38. (let* ((inputs-count* (take inputs-count max-count))
  39. (names (map package-name (map car inputs-count*)))
  40. (min-width (apply max (map (lambda (name)
  41. (string-length name))
  42. names)))
  43. (fmt (format #f "~~~da\t~~d~%" min-width)))
  44. (for-each (match-lambda
  45. ((package . count)
  46. (format #t fmt (package-name package) count)))
  47. inputs-count*)))
  48. ;;; Example
  49. ;;;
  50. ;;; Try to find which common input package is most likely to affect a group of
  51. ;;; failing packages.
  52. ;;;
  53. ;;; The Guix build output was:
  54. ;; build of /gnu/store/qrwzykhz6n34vazfww95cxf38b1m11p6-weasyprint-51.drv
  55. ;; failed View build log at
  56. ;; '/var/log/guix/drvs/qr/wzykhz6n34vazfww95cxf38b1m11p6-weasyprint-51.drv.bz2'.
  57. ;; guix build: error: build of
  58. ;; `/gnu/store/0aqwliclll4yyl9y689fcz7lp2cks9w5-python-matplotlib-documentation-3.1.2.drv',
  59. ;; `/gnu/store/4l3f8karc2xya4lkpajv2c25qaah933q-freecad-0.18.4.drv',
  60. ;; `/gnu/store/5cvj1qh7v4vmhvgbzflm21d0g7pvvkhh-python-ipython-documentation-7.9.0.drv',
  61. ;; `/gnu/store/bgmci6ahcizr4dypv85hal603kaj8wy4-pplacer-1.1.alpha19.drv',
  62. ;; `/gnu/store/dn8rfa0zwg8n2mkvg7sa9zminzsq2llr-clipper-2.0.drv',
  63. ;; `/gnu/store/j7ipa3fh4ybvprgznc5i9nb3lq8y1ahb-python-numpy-documentation-1.17.3.drv',
  64. ;; `/gnu/store/lfv227c76rwnblg18if00db4j81qmdfj-python-faiss-1.5.0.drv',
  65. ;; `/gnu/store/qrwzykhz6n34vazfww95cxf38b1m11p6-weasyprint-51.drv',
  66. ;; `/gnu/store/zh4mcz5c9bggvnpx3nl6k2n8im3fdzkg-python-pari-jupyter-1.3.2.drv'
  67. ;; failed
  68. (define (try-example)
  69. (let ((packages (map specification->package
  70. '("python-matplotlib-documentation"
  71. "python-ipython-documentation"
  72. "clipper"
  73. "python-numpy-documentation"
  74. "python-faiss"
  75. "python-pari-jupyter"))))
  76. (format #t "Common transitive inputs: ~a~%~%"
  77. (map package-name (common-inputs packages #:transitive? #t)))
  78. (format #t "Common inputs count:~%")
  79. (pp-inputs-count (common-inputs-count packages))))
  80. ;; =>
  81. ;; Common transitive inputs: (python-six zlib)
  82. ;; Common inputs count:
  83. ;; python-matplotlib 5
  84. ;; python-numpy 4
  85. ;; pkg-config 3
  86. ;; texinfo 3
  87. ;; python-ipykernel 3
  88. ;; python-numpydoc 3
  89. ;; python-sphinx 3
  90. ;; python-cython 2
  91. ;; python-pytest 2
  92. ;; python-mock 2
  93. ;; python-ipython 2
  94. ;; readline 1
  95. ;; pari-gp 1
  96. ;; python-tinycss2 1
  97. ;; python-pyphen 1
  98. ;; python-html5lib 1
  99. ;; python-cssselect2 1
  100. ;; python-cffi 1
  101. ;; python-cairosvg 1
  102. ;; python-cairocffi 1
  103. ;;; This suggests python-matplotlib or python-numpy might have something to do
  104. ;;; with it, and that 3 or 4 of these failures are likely unrelated.