Hi Bruno,
On 4/1/24 3:11 PM, Bruno Haible wrote:
> The problem happens here:
>
> # Update configuration dictionary.
> self.config.update(self.cache) # HERE the value is set to
> 'autotools'
> for key in config.keys():
> value = config[key]
> if not config.isdefault(key, value): # HERE 'build-aux' is
> not considered to be the default
> self.config.update_key(config, key) # HERE 'autotools'
> gets overwritten with 'build-aux'
>
> Here I would revisit the entire 'auxdir' handling.
Let me know how this patch is. I am assuming that setting 'auxdir' to
default to 'build-aux' is incorrect. Basing this on your comment and
lines 7251-7274 in gnulib-tool.sh:
# Analyze configure.ac.
guessed_auxdir="."
guessed_libtool=false
...
/AC_CONFIG_AUX_DIR/ {
s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
}
...
if test -z "$auxdir"; then
auxdir="$guessed_auxdir"
fi
I think that this means if no --auxdir is passed to gnulib-tool, use
whatever is found in 'AC_CONFIG_AUX_DIR' of configure.ac. If not found
use the destination directory.
It seems that GLConfig.__getitem__(), used for indexing [1] would
always return 'build-aux' when given the 'auxdir' key.
I've also removed some unused code. The result variable was not used
and we only accept string keys.
diff --git a/pygnulib/GLConfig.py b/pygnulib/GLConfig.py
index 80719d35f2..ab967ec321 100644
--- a/pygnulib/GLConfig.py
+++ b/pygnulib/GLConfig.py
@@ -251,13 +251,6 @@ class GLConfig(object):
def __getitem__(self, y: str) -> str | float | int | bool | CopyAction |
list[str] | None:
'''x.__getitem__(y) <==> x[y]'''
if y in self.table:
- result = self.table[y]
- if type(y) is list:
- result = list(self.table[y])
- if y == "auxdir":
- if self.table['auxdir']:
- return self.table['auxdir']
- return "build-aux"
return self.table[y]
else: # if y not in self.table
raise KeyError('GLConfig does not contain key: %s' % repr(y))
This broke a few import tests. Changing this line solves the issue.
This is because keys not explicitly mentioned in GLImport.default()
return an empty string not None.
In this case we check if --auxdir is given (self.config). If not we
use what is read from configure.ac (self.cache).
This is initialized to '.' like in gnulib-tool.sh in GLImport.py
line 93:
# Get cached auxdir and libtool from configure.ac/in.
self.cache.setAuxDir('.')
though it shouldn't matter since joinpath(destdir, '.') and
joinpath(destdir, '') should be the same.
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index 0adfd8a73c..893494a70a 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -100,7 +100,7 @@ class GLImport(object):
self.cache.setAuxDir(joinpath(self.config['destdir'], result))
pattern = re.compile(r'A[CM]_PROG_LIBTOOL', re.M)
guessed_libtool = bool(pattern.findall(data))
- if self.config['auxdir'] == None:
+ if self.config['auxdir'] == '':
self.config.setAuxDir(self.cache['auxdir'])
# Guess autoconf version.
This seems correct to me since all tests still pass and in freedink:
env GNULIB_TOOL_IMPL=sh+py gnulib-tool ./bootstrap
works correctly.
[1] https://docs.python.org/3/reference/datamodel.html#slice-objects
Collin
From 1285e5a02dc08b68823eaa73ca5cdf65c4f30699 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Mon, 1 Apr 2024 19:13:16 -0700
Subject: [PATCH] gnulib-tool.py: Don't default to 'build-aux' for --auxdir.
* pygnulib/GLConfig.py (GLConfig.__getitem__): Don't unconditionally
return 'build-aux' for the 'auxdir' key. Cleanup dead code.
* pygnulib/GLImport.py (GLImport.__init__): Change conditional to use an
empty string instead of None since this is returned when --auxdir is not
used.
---
ChangeLog | 9 +++++++++
pygnulib/GLConfig.py | 7 -------
pygnulib/GLImport.py | 2 +-
3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1668b7cfd8..d112f5ea99 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-04-01 Collin Funk <collin.fu...@gmail.com>
+
+ gnulib-tool.py: Don't default to 'build-aux' for --auxdir.
+ * pygnulib/GLConfig.py (GLConfig.__getitem__): Don't unconditionally
+ return 'build-aux' for the 'auxdir' key. Cleanup dead code.
+ * pygnulib/GLImport.py (GLImport.__init__): Change conditional to use an
+ empty string instead of None since this is returned when --auxdir is not
+ used.
+
2024-04-01 Bruno Haible <br...@clisp.org>
gnulib-tool.py: Add developer documentation.
diff --git a/pygnulib/GLConfig.py b/pygnulib/GLConfig.py
index 80719d35f2..ab967ec321 100644
--- a/pygnulib/GLConfig.py
+++ b/pygnulib/GLConfig.py
@@ -251,13 +251,6 @@ class GLConfig(object):
def __getitem__(self, y: str) -> str | float | int | bool | CopyAction | list[str] | None:
'''x.__getitem__(y) <==> x[y]'''
if y in self.table:
- result = self.table[y]
- if type(y) is list:
- result = list(self.table[y])
- if y == "auxdir":
- if self.table['auxdir']:
- return self.table['auxdir']
- return "build-aux"
return self.table[y]
else: # if y not in self.table
raise KeyError('GLConfig does not contain key: %s' % repr(y))
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index 0adfd8a73c..893494a70a 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -100,7 +100,7 @@ class GLImport(object):
self.cache.setAuxDir(joinpath(self.config['destdir'], result))
pattern = re.compile(r'A[CM]_PROG_LIBTOOL', re.M)
guessed_libtool = bool(pattern.findall(data))
- if self.config['auxdir'] == None:
+ if self.config['auxdir'] == '':
self.config.setAuxDir(self.cache['auxdir'])
# Guess autoconf version.
--
2.44.0