]> arthur.barton.de Git - bup.git/commitdiff
configure: add --with-pylint=[yes|no|maybe] defaulting to maybe
authorRob Browning <rlb@defaultvalue.org>
Sat, 11 Sep 2021 21:02:19 +0000 (16:02 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sat, 11 Sep 2021 21:02:19 +0000 (16:02 -0500)
When set to no, don't run pylint from ./pylint, just exit
successfully.  When set to maybe, use dev/have-pylint to figure out if
pylint is available, and if so, run it, otherwise exit successfully
after describing the situation.  When set to yes, always try to run
pylint.

This may be useful more generally, but in particular, it makes it
possible to run this:

  ./configure --with-pylint=maybe
  make check-both

in situations where pylint is available for say python 3, but not
python 2.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
GNUmakefile
config/configure
configure
dev/have-pylint [new file with mode: 0755]
dev/prep-for-debianish-build
pylint

index 2ed5b7ca24d5e162f804ea748a7cb9b4e1708b29..30f1b3a1cacab7f09f61da6c57f7e7c3c579d58c 100644 (file)
@@ -206,7 +206,7 @@ get_parallel_n = $(patsubst -j%,%,$(parallel_opt))
 maybe_specific_n = $(if $(filter -j%,$(parallel_opt)),-n$(get_parallel_n))
 xdist_opt = $(if $(filter -j,$(parallel_opt)),-nauto,$(maybe_specific_n))
 
-lint: dev/bup-python
+lint: dev/bup-exec dev/bup-python
        ./pylint
 
 test: all test/tmp dev/python lint
index 31a43e105a243a03aed1d08feb7d2214f80a2a1b..f1faa6e8a74cc735eec0d267a734cca761837445 100755 (executable)
@@ -1,5 +1,7 @@
 #!/usr/bin/env bash
 
+ac_help="--with-pylint[=yes|no|maybe]  require and run pylint (maybe)"
+
 bup_find_prog()
 {
     # Prints prog path to stdout or nothing.
@@ -35,6 +37,20 @@ bup_try_c_code()
 
 TARGET=bup
 
+argv=()
+with_pylint=maybe
+while test $# -gt 0; do
+    case "$1" in
+        --with-pylint=yes) with_pylint=yes; shift;;
+        --with-pylint=maybe) with_pylint=maybe; shift;;
+        --with-pylint=no) with_pylint=no; shift;;
+        *) argv+=("$1"); shift;;
+    esac
+done
+
+# Set $@ to the adjusted args
+set - "${argv[@]}"
+
 . ./configure.inc
 
 # FIXME: real tmpdir
@@ -341,6 +357,7 @@ set -euo pipefail
 mkdir -p config.var.tmp
 echo -n "$MAKE" > config.var.tmp/bup-make
 echo -n "$bup_python_config" > config.var.tmp/bup-python-config
+echo -n "$with_pylint" > config.var.tmp/with-pylint
 mv config.var.tmp config.var
 
 if test -e bin; then rm -r bin; fi
index f7cb928936b56e64eb663da8a608f9f5672ed07d..9d6ca151576934c6223afb98830a4d0917f5448f 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,9 +1,6 @@
 #!/bin/sh
 
-if test "$#" -gt 0; then
-    echo "Usage: configure" 1>&2
-    exit 1
-fi
+set -e
 
-cd config &&
+cd config
 exec ./configure "$@"
diff --git a/dev/have-pylint b/dev/have-pylint
new file mode 100755 (executable)
index 0000000..15262b4
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+"""": # -*-python-*-
+bup_exec="$(dirname "$0")/bup-exec" || exit $?
+exec "$bup_exec" "$0" ${1+"$@"}
+"""
+
+from __future__ import absolute_import, print_function
+
+import sys
+
+try:
+    import pylint
+except ImportError as ex:
+    sys.exit(1)
+except BaseException as ex:
+    print(ex, file=sys.stderr)
+    sys.exit(2)
index d45ce303bb4b4e9c44c7d4486de7669a568f1b04..0ded700114b5e5a011719cf8997f17b9db812b5e 100755 (executable)
@@ -25,14 +25,14 @@ case "$pyver" in
                 $common_debs \
                 python2.7-dev python-fuse \
                 python-"$xattr" python-tornado python-pytest \
-                python-pytest-xdist
+                python-pytest-xdist pylint
         ;;
     python3)
         apt-get install -y \
                 $common_debs \
                 python3-dev python3-distutils python3-fuse \
                 python3-"$xattr" python3-tornado python3-pytest \
-                python3-pytest-xdist
+                python3-pytest-xdist pylint3
         ;;
     *)
         usage 1>&2
diff --git a/pylint b/pylint
index c04af785d65941145e36b7a9dd5721578f1c403a..d0474b4f90bd5ae1357bb857d43d9915a2aa4299 100755 (executable)
--- a/pylint
+++ b/pylint
@@ -1,9 +1,36 @@
-#!/bin/sh
+#!/usr/bin/env bash
 
 # Changes here might also be appropriate for ./pytest
 
 set -eu
 
+with_pylint=$(cat config/config.var/with-pylint)
+
+case "$with_pylint" in
+    yes) ;;
+    no)
+        echo "./pylint: doing nothing given ./configure --with-pylint=no" 1>&2
+        exit 0
+        ;;
+    maybe)
+        rc=0
+        dev/have-pylint || rc=$?
+        case "$rc" in
+            0) ;;
+            1)
+                echo "./pylint: doing nothing (pylint not found)" 1>&2
+                exit 0
+                ;;
+            *) exit "$rc" ;;
+        esac
+        ;;
+    *)
+        printf "./pylint: unexpected config/config.var/with-pylint value %q\n" \
+               "$with_pylint" 1>&2
+        exit 2
+        ;;
+esac
+
 script_home="$(cd "$(dirname "$0")" && pwd -P)"
 testlibdir="$script_home/test/lib"