From bb814918e0f1b2171f8d60081dc721ca23b519e9 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 16 Jan 2025 10:13:19 +0100 Subject: [PATCH 1/2] scripts/python/Makefile.am, scripts/python/module/Makefile.am: be sure to install nut_telnetlib.py along with PyNUT.py file [#2183, #2501, #2505] Deliver nut_telnetlib.py with Python 3.13 that lacks its own. Some use-cases did ensure its presence, but not all cases yet. Signed-off-by: Jim Klimov --- scripts/python/Makefile.am | 14 +++++++++----- scripts/python/module/Makefile.am | 3 +++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/scripts/python/Makefile.am b/scripts/python/Makefile.am index 29c1291e30..74505fdc81 100644 --- a/scripts/python/Makefile.am +++ b/scripts/python/Makefile.am @@ -69,10 +69,14 @@ NUT_MONITOR_COMMON = \ app/locale/it/LC_MESSAGES/NUT-Monitor.mo \ app/locale/ru/LC_MESSAGES/NUT-Monitor.mo -PYNUT_COMMON = \ - module/nut_telnetlib.py \ +PYNUT_COMMON_CODE = \ + module/nut_telnetlib.py + +PYNUT_COMMON_MISC = \ module/README.adoc +PYNUT_COMMON = $(PYNUT_COMMON_CODE) $(PYNUT_COMMON_MISC) + # Note: we both distribute and install the generated *.mo translation files # so they are listed above and not in NUT_MONITOR_COMMON_TEMPLATE NUT_MONITOR_COMMON_TEMPLATE = \ @@ -176,21 +180,21 @@ endif WITH_NUT_MONITOR if WITH_PYNUT_PY pynut_py_sitedir = $(PYTHON_SITE_PACKAGES) pynut_py_site_DATA = $(PYNUT_GENERATED_NOEXEC) -pynut_py_site_SCRIPTS = $(PYNUT_GENERATED_SCRIPT) +pynut_py_site_SCRIPTS = $(PYNUT_GENERATED_SCRIPT) $(PYNUT_COMMON_CODE) endif if WITH_PYNUT_PY2 pynut_py2_sitedir = $(PYTHON2_SITE_PACKAGES) pynut_py2_site_DATA = $(PYNUT_GENERATED_NOEXEC) -pynut_py2_site_SCRIPTS = $(PYNUT_GENERATED_SCRIPT) +pynut_py2_site_SCRIPTS = $(PYNUT_GENERATED_SCRIPT) $(PYNUT_COMMON_CODE) endif if WITH_PYNUT_PY3 pynut_py3_sitedir = $(PYTHON3_SITE_PACKAGES) pynut_py3_site_DATA = $(PYNUT_GENERATED_NOEXEC) -pynut_py3_site_SCRIPTS = $(PYNUT_GENERATED_SCRIPT) +pynut_py3_site_SCRIPTS = $(PYNUT_GENERATED_SCRIPT) $(PYNUT_COMMON_CODE) endif ################################################################# diff --git a/scripts/python/module/Makefile.am b/scripts/python/module/Makefile.am index 5eb650969c..c9fc4a61e0 100644 --- a/scripts/python/module/Makefile.am +++ b/scripts/python/module/Makefile.am @@ -86,6 +86,9 @@ upload publish: if test -x "$(srcdir)/$${B}.in" ; then chmod +x "PyNUTClient/$${B}"; fi ; \ done ; \ cp -pf "$(srcdir)/nut_telnetlib.py" PyNUTClient/ || exit ; \ + if [ x"$(abs_srcdir)" != x"$(abs_builddir)" ] ; then \ + cp -pf "$(srcdir)/nut_telnetlib.py" . || exit ; \ + fi ; \ cp -pf "$(srcdir)/README.adoc" README.txt || exit ; \ cp -pf "$(top_srcdir)/LICENSE-GPL3" . || exit ; \ echo "from . import PyNUT" > PyNUTClient/__init__.py || exit From e4739b93135c48d766e84731d0acdb2455ca5c33 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 16 Jan 2025 12:35:38 +0100 Subject: [PATCH 2/2] tools/gitlog2changelog.py.in: adapt to Python 3.13 deprecation of positional "maxsplit" parameter to re.split() Signed-off-by: Jim Klimov --- tools/gitlog2changelog.py.in | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tools/gitlog2changelog.py.in b/tools/gitlog2changelog.py.in index fca6f5ac96..9e88d3184b 100755 --- a/tools/gitlog2changelog.py.in +++ b/tools/gitlog2changelog.py.in @@ -151,7 +151,11 @@ for line in fin: # Match the author line and extract the part we want # (Don't use startswith to allow Author override inside commit message.) elif "Author:" in line: - authorList = re.split(": ", line, 1) + if sys.version_info >= (3, 13, ): + authorList = re.split(": ", line, maxsplit=1) + else: + authorList = re.split(": ", line, 1) + try: author = authorList[1] author = author[0 : len(author) - fin_chop] @@ -169,7 +173,11 @@ for line in fin: # Match the date line elif line.startswith("Date:"): - dateList = re.split(": ", line, 1) + if sys.version_info >= (3, 13, ): + dateList = re.split(": ", line, maxsplit=1) + else: + dateList = re.split(": ", line, 1) + try: date = dateList[1] date = date[0 : len(date) - fin_chop] @@ -213,7 +221,11 @@ for line in fin: continue # Collect the files for this commit. FIXME: Still need to add +/- to files elif authorFound and dateFound and messageFound: - fileList = re.split(r' \| ', line, 2) + if sys.version_info >= (3, 13, ): + fileList = re.split(r' \| ', line, maxsplit=2) + else: + fileList = re.split(r' \| ', line, 2) + if len(fileList) > 1: if len(files) > 0: files = files + ", " + fileList[0].strip()