all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Hartmut Goebel <h.goebel@crazy-compilers.com>
To: guix-devel@gnu.org
Subject: [WIP 7/8] guix: Add lint-checker for packages which should be no inputs at all.
Date: Mon, 10 Oct 2016 16:57:18 +0200	[thread overview]
Message-ID: <1476111439-20812-8-git-send-email-h.goebel@crazy-compilers.com> (raw)
In-Reply-To: <1476111439-20812-1-git-send-email-h.goebel@crazy-compilers.com>

Also refactor some common code into a new function.

Examples for these pacakges are python(2)-setuptools and python(2)-pip, which
are installed together with python itself.

* guix/scripts/lint.scm (warn-if-package-has-input): New procedure.
  (check-inputs-should-be-native package): Use it; rename and clean-up
  variables. (check-inputs-should-not-be-an-input-at-all): New procedure.
  (%checkers) Add it.
* doc/guix.texi (Python Modules): Document it.
* tests/lint.scm: ("inputs: python-setuptools should not be an input at all
  (input)", "inputs: python-setuptools should not be an input at all
  (native-input)" "inputs: python-setuptools should not be an input at all
  (propagated-input)"): Add tests.
---
 doc/guix.texi         |  3 ++-
 guix/scripts/lint.scm | 63 ++++++++++++++++++++++++++++++++++++---------------
 tests/lint.scm        | 34 +++++++++++++++++++++++++++
 3 files changed, 81 insertions(+), 19 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 92a827a..fa5b89e 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12257,7 +12257,8 @@ described above.
 
 We currently package Python 2 with @code{setuptools} and @code{pip}
 installed like Python 3.4 has per default.  Thus you don't need to
-specify either of these as an input.
+specify either of these as an input.  @command{guix lint} will warn you
+if you do.
 
 @node Perl Modules
 @subsection Perl Modules
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index b3ec6d6..042c679 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015, 2016 Mathieu Lirzin <mthl@gnu.org>
 ;;; Copyright © 2016 Danny Milosavljevic <dannym+a@scratchpost.org>
+;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -59,6 +60,7 @@
   #:export (guix-lint
             check-description-style
             check-inputs-should-be-native
+            check-inputs-should-not-be-an-input-at-all
             check-patch-file-names
             check-synopsis-style
             check-derivation
@@ -213,34 +215,55 @@ by two spaces; possible infraction~p at ~{~a~^, ~}")
                       (format #f (_ "invalid description: ~s") description)
                       'description))))
 
+(define (warn-if-package-has-input linted inputs-to-check input-names message)
+  ;; Emit a warning MESSAGE if some of the inputs named in INPUT-NAMES are
+  ;; contained in INPUTS-TO-CHECK, which are assumed to be inputs of package
+  ;; LINTED.
+  (match inputs-to-check
+    (((labels packages . outputs) ...)
+     (for-each (lambda (package output)
+                 (when (package? package)
+                   (let ((input (string-append
+                                 (package-name package)
+                                 (if (> (length output) 0)
+                                     (string-append ":" (car output))
+                                     ""))))
+                     (when (member input input-names)
+                       (emit-warning linted
+                                     (format #f (_ message) input)
+                                     'inputs-to-check)))))
+               packages outputs))))
+
 (define (check-inputs-should-be-native package)
   ;; Emit a warning if some inputs of PACKAGE are likely to belong to its
   ;; native inputs.
-  (let ((linted package)
+  (let ((message "'~a' should probably be a native input")
         (inputs (package-inputs package))
-        (native-inputs
+        (input-names
           '("pkg-config"
             "extra-cmake-modules"
             "glib:bin"
             "intltool"
             "itstool"
             "qttools")))
-    (match inputs
-      (((labels packages . outputs) ...)
-       (for-each (lambda (package output)
-                   (when (package? package)
-                     (let ((input (string-append
-                                   (package-name package)
-                                   (if (> (length output) 0)
-                                       (string-append ":" (car output))
-                                       ""))))
-                       (when (member input native-inputs)
-                         (emit-warning linted
-                                       (format #f (_ "'~a' should probably \
-be a native input")
-                                               input)
-                                       'inputs)))))
-                 packages outputs)))))
+    (warn-if-package-has-input package inputs input-names message)))
+
+(define (check-inputs-should-not-be-an-input-at-all package)
+  ;; Emit a warning if some inputs of PACKAGE are likely to should not be
+  ;; an input at all.
+  (let ((message "'~a' should probably not be an input at all")
+        (inputs (package-inputs package))
+        (input-names
+          '("python-setuptools"
+            "python2-setuptools"
+            "python-pip"
+            "python2-pip")))
+    (warn-if-package-has-input package (package-inputs package)
+                               input-names message)
+    (warn-if-package-has-input package (package-native-inputs package)
+                               input-names message)
+    (warn-if-package-has-input package (package-propagated-inputs package)
+                               input-names message)))
 
 (define (package-name-regexp package)
   "Return a regexp that matches PACKAGE's name as a word at the beginning of a
@@ -810,6 +833,10 @@ them for PACKAGE."
      (description "Identify inputs that should be native inputs")
      (check       check-inputs-should-be-native))
    (lint-checker
+     (name        'inputs-should-not-be-input)
+     (description "Identify inputs that should be inputs at all")
+     (check       check-inputs-should-not-be-an-input-at-all))
+   (lint-checker
      (name        'patch-file-names)
      (description "Validate file names and availability of patches")
      (check       check-patch-file-names))
diff --git a/tests/lint.scm b/tests/lint.scm
index d692b42..148e162 100644
--- a/tests/lint.scm
+++ b/tests/lint.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2014, 2015, 2016 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015, 2016 Mathieu Lirzin <mthl@gnu.org>
+;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -33,6 +34,7 @@
   #:use-module (gnu packages)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages python)
   #:use-module (web server)
   #:use-module (web server http)
   #:use-module (web response)
@@ -346,6 +348,38 @@ string) on HTTP requests."
           (check-inputs-should-be-native pkg)))
           "'glib:bin' should probably be a native input")))
 
+(test-assert
+    "inputs: python-setuptools should not be an input at all (input)"
+  (->bool
+   (string-contains
+     (with-warnings
+       (let ((pkg (dummy-package "x"
+                    (inputs `(("python-setuptools" ,python-setuptools))))))
+         (check-inputs-should-not-be-an-input-at-all pkg)))
+         "'python-setuptools' should probably not be an input at all")))
+
+(test-assert
+    "inputs: python-setuptools should not be an input at all (native-input)"
+  (->bool
+   (string-contains
+     (with-warnings
+       (let ((pkg (dummy-package "x"
+                    (native-inputs
+                     `(("python-setuptools" ,python-setuptools))))))
+         (check-inputs-should-not-be-an-input-at-all pkg)))
+         "'python-setuptools' should probably not be an input at all")))
+
+(test-assert
+    "inputs: python-setuptools should not be an input at all (propagated-input)"
+  (->bool
+   (string-contains
+     (with-warnings
+       (let ((pkg (dummy-package "x"
+                    (propagated-inputs
+                     `(("python-setuptools" ,python-setuptools))))))
+         (check-inputs-should-not-be-an-input-at-all pkg)))
+         "'python-setuptools' should probably not be an input at all")))
+
 (test-assert "patches: file names"
   (->bool
    (string-contains
-- 
2.7.4

  parent reply	other threads:[~2016-10-10 14:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-10 14:57 [WIP 0/9] python-build-system set 1: please review Hartmut Goebel
2016-10-10 14:57 ` [WIP 1/8] gnu: ensure pip and setuptools are installed even for Python 2 Hartmut Goebel
2016-10-10 14:57 ` [WIP 2/8] guix: build all Python packages with --single-version-externally-managed Hartmut Goebel
2016-10-10 14:57 ` [WIP 3/8] guix: python-build-system: Import setuptools before calling `setup.py' Hartmut Goebel
2016-10-10 14:57 ` [WIP 4/8] guix: python-build-system: Add option "#:use-setuptools?" (default true) Hartmut Goebel
2016-10-10 14:57 ` [WIP 5/8] guix: python-build-system: Add helpers for getting and setting PYTHONPATH Hartmut Goebel
2016-10-10 14:57 ` [WIP 6/8] guix: python-build-system: Delete .egg-info file created in phase check Hartmut Goebel
2016-10-10 14:57 ` Hartmut Goebel [this message]
2016-10-10 14:57 ` [WIP 8/8] lint: more packages to probably be a native input Hartmut Goebel
2016-10-11  8:08 ` [WIP 0/9] python-build-system set 1: please review Hartmut Goebel
2016-10-11  8:37 ` Hartmut Goebel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1476111439-20812-8-git-send-email-h.goebel@crazy-compilers.com \
    --to=h.goebel@crazy-compilers.com \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.