bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnulib-tool.py in barcode, gcal, gengetopt, myserver


From: Bruno Haible
Subject: gnulib-tool.py in barcode, gcal, gengetopt, myserver
Date: Thu, 11 Apr 2024 02:05:03 +0200

A couple of packages (barcode, gcal, gengetopt, myserver) have an old
gnulib configuration that still uses a module 'free', 'malloc', or 'getopt'.
These modules have been renamed in the mean time.

gnulib-tool.sh prints warnings about missing modules or mistyped module names.
gnulib-tool.py currently
  - fails,
  - prints a Python stack trace, which is not helpful to the user.

For example, in the 'barcode' package:

$ export GNULIB_TOOL_IMPL=sh+py
$ git clone https://git.savannah.gnu.org/git/barcode.git
$ cd barcode
$ ./bootstrap --no-git --gnulib-srcdir=$GNULIB_SRCDIR
...
./bootstrap: .../gnulib-tool  --import --no-changelog --aux-dir build-aux 
--doc-base doc --lib libgnu --m4-base m4/ --source-base lib/ --tests-base tests 
--local-dir gl  --libtool --import ...
+ .../gnulib-tool --import --no-changelog --aux-dir build-aux --doc-base doc 
--lib libgnu --m4-base m4/ --source-base lib/ --tests-base tests --local-dir gl 
--libtool --import calloc-gnu close error float fopen free gettext-h 
git-version-gen malloc-gnu memcpy memset open rint search sigpipe snprintf 
stdio strdup-posix strerror string time verify write
.../gnulib-tool: *** gnulib-tool.sh succeeded but gnulib-tool.py failed! 
Inspect .../glpyB2dMjm/ and .../glpyB2dMjm-py-err.
.../gnulib-tool: *** Stop.

gnulib-tool.sh stderr:
--------------------------------------------------------------------------------
gnulib-tool: warning: module free doesn't exist
gnulib-tool: warning: module free doesn't exist
--------------------------------------------------------------------------------

gnulib-tool.py stderr:
--------------------------------------------------------------------------------
gnulib-tool: warning: file free does not exist
Traceback (most recent call last):
  File ".../.gnulib-tool.py", line 30, in <module>
    main.main_with_exception_handling()
  File ".../pygnulib/main.py", line 1384, in main_with_exception_handling
    main()
  File ".../pygnulib/main.py", line 956, in main
    filetable, transformers = importer.prepare()
  File ".../pygnulib/GLImport.py", line 815, in prepare
    final_modules = self.moduletable.transitive_closure(base_modules)
  File ".../pygnulib/GLModuleSystem.py", line 825, in transitive_closure
    raise TypeError('each module must be a GLModule instance')
TypeError: each module must be a GLModule instance
--------------------------------------------------------------------------------

This patch aligns the behaviour of gnulib-tool.py with the one of
gnulib-tool.sh, except that it prints the warning only once instead of twice.


2024-04-10  Bruno Haible  <bruno@clisp.org>

        gnulib-tool.py: Skip nonexistent modules instead of failing.
        * pygnulib/GLModuleSystem.py (GLModuleSystem.find): Use the same warning
        wording as gnulib-tool.sh.
        * pygnulib/GLImport.py (GLImport.gnulib_cache): Print the specified
        modules, not the base modules.
        (GLImport.prepare): Don't put None elements into base_modules.

diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index 66d8eb922c..fdca884a08 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -523,8 +523,7 @@ class GLImport:
         podomain = self.config['podomain']
         witness_c_macro = self.config['witness_c_macro']
         vc_files = self.config['vc_files']
-        modules = [ str(module)
-                    for module in moduletable.getBaseModules() ]
+        modules = self.config['modules']
         avoids = self.config['avoids']
         emit += self.emitter.copyright_notice()
         emit += '''#
@@ -808,8 +807,12 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
         m4base = self.config['m4base']
         lgpl = self.config['lgpl']
         verbose = self.config['verbosity']
-        base_modules = sorted({ self.modulesystem.find(m)
-                                for m in modules })
+        base_modules = set()
+        for name in modules:
+            module = self.modulesystem.find(name)
+            if module is not None:
+                base_modules.add(module)
+        base_modules = sorted(base_modules)
 
         # Perform transitive closure.
         final_modules = self.moduletable.transitive_closure(base_modules)
diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index ed96b9846c..01378259d9 100644
--- a/pygnulib/GLModuleSystem.py
+++ b/pygnulib/GLModuleSystem.py
@@ -110,7 +110,7 @@ class GLModuleSystem:
                 raise GLError(3, module)
             else:  # if not self.config['errors']
                 sys.stderr.write('gnulib-tool: warning: ')
-                sys.stderr.write('file %s does not exist\n' % str(module))
+                sys.stderr.write("module %s doesn't exist\n" % str(module))
 
     def file_is_module(self, filename: str) -> bool:
         '''Given the name of a file in the modules/ directory, return true






reply via email to

[Prev in Thread] Current Thread [Next in Thread]