Re: [PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 52.
On 3/11/24 4:57 AM, Bruno Haible wrote: > This looks good to me. 'sed' accepts POSIX BREs, where '(' and '[' stand for > the literal '(' and '[' characters unless escaped. Thanks for double checking for me. > Also, I applied the attached follow-up, in order to make the logic of the code > easier to follow. There was nothing wrong in your code; it's just to make it > more straightforward to read. Thanks. Your changes look good to me. There is a lot going on in that function so I am all for any changes that make it easier to read. Collin
Re: [PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 52.
Hi Collin, > On 3/10/24 5:13 AM, Bruno Haible wrote: > > automake_options = {x for y in configure_ac_automake_options for x in > > y.split()} > > I've attached the fixed patch. Thanks, applied. > I would like to double check the regular expression I used: > > pattern = re.compile(r'^.*AM_INIT_AUTOMAKE\([\[ ]*([^\]\)]*).*$', > re.MULTILINE) > > Compared to the sed one: > > s,^.*AM_INIT_AUTOMAKE([[ ]*\([^])]*\).*$,\1,p This looks good to me. 'sed' accepts POSIX BREs, where '(' and '[' stand for the literal '(' and '[' characters unless escaped. Also, I applied the attached follow-up, in order to make the logic of the code easier to follow. There was nothing wrong in your code; it's just to make it more straightforward to read. - There's no need to define 'pattern' before reading the file. So, define it after reading the file. - The 'base' variable is only needed in the 'if not found_subdir_objects' case. So, define it only in this case. - Make the two code blocks that read configure.ac and Makefile.am more similar. Bruno >From 2045ee7288c2a4d0dbea090ae5b829557f96dc1a Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 11 Mar 2024 12:49:24 +0100 Subject: [PATCH] gnulib-tool.py: Make some code more straightforward. * pygnulib/GLImport.py (GLImport.__init__): Reorder assignments and conditions slightly. --- ChangeLog| 6 ++ pygnulib/GLImport.py | 33 + 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9135b6b779..308f75a4ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-03-11 Bruno Haible + + gnulib-tool.py: Make some code more straightforward. + * pygnulib/GLImport.py (GLImport.__init__): Reorder assignments and + conditions slightly. + 2024-03-11 Collin Funk gnulib-tool.py: Follow gnulib-tool changes, part 52. diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index de2961c55e..1dabccd201 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -261,31 +261,32 @@ class GLImport(object): # Determine whether --automake-subdir is supported. if self.config['automake_subdir']: -automake_options = set() +found_subdir_objects = False if self.config['destdir']: -pattern = re.compile(r'^.*AM_INIT_AUTOMAKE\([\[ ]*([^\]\)]*).*$', re.MULTILINE) with open(self.config['configure_ac'], encoding='utf-8') as file: data = file.read() +pattern = re.compile(r'^.*AM_INIT_AUTOMAKE\([\[ ]*([^\]\)]*).*$', re.MULTILINE) configure_ac_automake_options = pattern.findall(data) if configure_ac_automake_options: automake_options = { x for y in configure_ac_automake_options for x in y.split() } -found_subdir_objects = 'subdir-objects' in automake_options -if self.config['destdir']: -base = self.config['destdir'] -else: -base = '.' -if not found_subdir_objects and isfile(joinpath(base, 'Makefile.am')): -pattern = re.compile(r'^AUTOMAKE_OPTIONS[\t ]*=(.*)$', re.MULTILINE) -with open(joinpath(base, 'Makefile.am'), encoding='utf-8') as file: -data = file.read() -automake_options = pattern.findall(data) -if automake_options: -automake_options = { x - for y in automake_options - for x in y.split() } found_subdir_objects = 'subdir-objects' in automake_options +if not found_subdir_objects: +if self.config['destdir']: +base = self.config['destdir'] +else: +base = '.' +if isfile(joinpath(base, 'Makefile.am')): +with open(joinpath(base, 'Makefile.am'), encoding='utf-8') as file: +data = file.read() +pattern = re.compile(r'^AUTOMAKE_OPTIONS[\t ]*=(.*)$', re.MULTILINE) +automake_options = pattern.findall(data) +if automake_options: +automake_options = { x + for y in automake_options + for x in y.split() } +found_subdir_objects = 'subdir-objects' in automake_options if not found_subdir_objects: raise GLError(21, None) -- 2.34.1
Re: [PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 52.
Hi Bruno, On 3/10/24 5:13 AM, Bruno Haible wrote: > automake_options = {x for y in configure_ac_automake_options for x in > y.split()} I've attached the fixed patch. The only change is turning this line to: automake_options = { x for y in configure_ac_automake_options for x in y.split() } I would like to double check the regular expression I used: pattern = re.compile(r'^.*AM_INIT_AUTOMAKE\([\[ ]*([^\]\)]*).*$', re.MULTILINE) Compared to the sed one: s,^.*AM_INIT_AUTOMAKE([[ ]*\([^])]*\).*$,\1,p But I did not do it this patch since it would make the changes harder to follow. CollinFrom c0772b3fe45a61dc686ce945e6decfb7ff4a84c4 Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Sun, 10 Mar 2024 21:50:59 -0700 Subject: [PATCH 2/2] gnulib-tool.py: Follow gnulib-tool changes, part 52. Follow gnulib-tool change 2021-12-15 Bruno Haible automake-subdir support: Look for 'subdir-objects' also in configure.ac. * pygnulib/GLImport.py (GLImport.__init__): Check for 'subdir-objects' in the AM_INIT_AUTOMAKE macro of configure.ac. --- ChangeLog| 9 + gnulib-tool.py.TODO | 11 --- pygnulib/GLImport.py | 14 -- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 324e0bc04f..34323c66e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2024-03-10 Collin Funk + + gnulib-tool.py: Follow gnulib-tool changes, part 52. + Follow gnulib-tool change + 2021-12-15 Bruno Haible + automake-subdir support: Look for 'subdir-objects' also in configure.ac. + * pygnulib/GLImport.py (GLImport.__init__): Check for 'subdir-objects' + in the AM_INIT_AUTOMAKE macro of configure.ac. + 2024-03-10 Bruno Haible gnulib-tool.py: Tweak last commit. diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO index 51e6cd9e18..e6c94c8bb8 100644 --- a/gnulib-tool.py.TODO +++ b/gnulib-tool.py.TODO @@ -305,17 +305,6 @@ Date: Sun Dec 19 12:49:16 2021 +0100 -commit b8124d982f454b8526b5e11934a2f71faac2b600 -Author: Bruno Haible -Date: Wed Dec 15 21:49:41 2021 +0100 - -automake-subdir support: Look for 'subdir-objects' also in configure.ac. - -* gnulib-tool: Look for the automake options also in the first argument -of the AM_INIT_AUTOMAKE invocation in configure.ac. - - - commit 4b071c115309079528db7b60e8d2ffb22b129088 Author: Paul Eggert Date: Mon Apr 26 23:31:29 2021 -0700 diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index 64a0bc9b13..de2961c55e 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -261,12 +261,22 @@ class GLImport(object): # Determine whether --automake-subdir is supported. if self.config['automake_subdir']: -found_subdir_objects = False +automake_options = set() +if self.config['destdir']: +pattern = re.compile(r'^.*AM_INIT_AUTOMAKE\([\[ ]*([^\]\)]*).*$', re.MULTILINE) +with open(self.config['configure_ac'], encoding='utf-8') as file: +data = file.read() +configure_ac_automake_options = pattern.findall(data) +if configure_ac_automake_options: +automake_options = { x + for y in configure_ac_automake_options + for x in y.split() } +found_subdir_objects = 'subdir-objects' in automake_options if self.config['destdir']: base = self.config['destdir'] else: base = '.' -if isfile(joinpath(base, 'Makefile.am')): +if not found_subdir_objects and isfile(joinpath(base, 'Makefile.am')): pattern = re.compile(r'^AUTOMAKE_OPTIONS[\t ]*=(.*)$', re.MULTILINE) with open(joinpath(base, 'Makefile.am'), encoding='utf-8') as file: data = file.read() -- 2.44.0
Re: [PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 52.
Hi Collin, This one looks good, except please reformat the line automake_options = {x for y in configure_ac_automake_options for x in y.split()} as suggested for part 51. Bruno
[PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 52.
On 3/9/24 6:28 PM, Collin Funk wrote: > I think that should be a pretty easy change so I will try to get it > done sometime today. Not the cleanest code I have ever written but it seems to work. :) Here is a test case: gnulib-tool.py --create-testdir --dir test-python dummy gnulib-tool --create-testdir --dir test-shell dummy # Copied from Coreutils configure.ac sed -i -e 's/AM_INIT_AUTOMAKE/AM_INIT_AUTOMAKE([1.11.2 dist-xz color-tests parallel-tests subdir-objects])/g' test-python/configure.ac test-shell/configure.ac (cd test-python && gnulib-tool.py --import --automake-subdir --with-tests alloca-opt alloca) (cd test-shell && gnulib-tool --import --automake-subdir --with-tests alloca-opt alloca) git diff --no-index test-python test-shell Now gnulib-tool.py will see subdir-objects in Coreutil's configure.ac. It still fails to bootstrap because of the @NMD@ magic: autoreconf: running: automake --add-missing --copy --force-missing lib/gnulib.mk:2011: error: bad characters in variable name '@!NMD@gl_V_at' Makefile.am:212: 'lib/local.mk' included from here lib/local.mk:1: 'lib/gnulib.mk' included from here gnulib-tests/gnulib.mk:1384: error: bad characters in variable name '@!NMD@gl_V_at' gnulib-tests/Makefile.am:1: 'gnulib-tests/gnulib.mk' included from here autoreconf: error: automake failed with exit status: 1 ./bootstrap: autoreconf failed I don't remember those changes looking too hard, so _hopefully_ I can get them done soon. CollinFrom 081643519481b02362cbc5a9530e13aba2bfcb9b Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Sat, 9 Mar 2024 20:05:10 -0800 Subject: [PATCH 2/2] gnulib-tool.py: Follow gnulib-tool changes, part 52. Follow gnulib-tool change 2021-12-15 Bruno Haible automake-subdir support: Look for 'subdir-objects' also in configure.ac. * pygnulib/GLImport.py (GLImport.__init__): Check for 'subdir-objects' in the AM_INIT_AUTOMAKE macro of configure.ac. --- ChangeLog| 9 + gnulib-tool.py.TODO | 11 --- pygnulib/GLImport.py | 12 ++-- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index f13d759bb4..8dda625922 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2024-03-09 Collin Funk + + gnulib-tool.py: Follow gnulib-tool changes, part 52. + Follow gnulib-tool change + 2021-12-15 Bruno Haible + automake-subdir support: Look for 'subdir-objects' also in configure.ac. + * pygnulib/GLImport.py (GLImport.__init__): Check for 'subdir-objects' + in the AM_INIT_AUTOMAKE macro of configure.ac. + 2024-03-09 Collin Funk gnulib-tool.py: Follow gnulib-tool changes, part 51. diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO index 51e6cd9e18..e6c94c8bb8 100644 --- a/gnulib-tool.py.TODO +++ b/gnulib-tool.py.TODO @@ -305,17 +305,6 @@ Date: Sun Dec 19 12:49:16 2021 +0100 -commit b8124d982f454b8526b5e11934a2f71faac2b600 -Author: Bruno Haible -Date: Wed Dec 15 21:49:41 2021 +0100 - -automake-subdir support: Look for 'subdir-objects' also in configure.ac. - -* gnulib-tool: Look for the automake options also in the first argument -of the AM_INIT_AUTOMAKE invocation in configure.ac. - - - commit 4b071c115309079528db7b60e8d2ffb22b129088 Author: Paul Eggert Date: Mon Apr 26 23:31:29 2021 -0700 diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index 2ebad91da5..ed0139fe3c 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -260,9 +260,17 @@ class GLImport(object): self.config.setModules(modules) if self.config['automake_subdir']: -found_subdir_objects = False +automake_options = set() +if self.config['configure_ac']: +pattern = re.compile(r'^.*AM_INIT_AUTOMAKE\([\[ ]*([^\]\)]*).*$', re.MULTILINE) +with open(self.config['configure_ac'], encoding='utf-8') as file: +data = file.read() +configure_ac_automake_options = pattern.findall(data) +if configure_ac_automake_options: +automake_options = {x for y in configure_ac_automake_options for x in y.split()} +found_subdir_objects = 'subdir-objects' in automake_options base = self.config['destdir'] if self.config['destdir'] else '.' -if isfile(joinpath(base, 'Makefile.am')): +if not found_subdir_objects and isfile(joinpath(base, 'Makefile.am')): pattern = re.compile(r'^AUTOMAKE_OPTIONS[\t| ]*=(.*)$', re.MULTILINE) with open(joinpath(base, 'Makefile.am'), encoding='utf-8') as file: data = file.read() -- 2.44.0