diff mbox series

pylibfdt: Allow version normalization to fail

Message ID 20230107230407.2457827-1-trini@konsulko.com
State Accepted
Commit 051f409d25f84b394c15e82190c897a46cf6c60c
Delegated to: Tom Rini
Headers show
Series pylibfdt: Allow version normalization to fail | expand

Commit Message

Tom Rini Jan. 7, 2023, 11:04 p.m. UTC
In some cases, we might not have the sic portion of setuputils
available. Make our import and use of this be done in try/except blocks
as this is done to suppress a run-time warning that is otherwise
non-fatal.

Reported-by: Pali Rohár <pali@kernel.org>
Fixes: 141659187667 ("pylibfdt: Fix disable version normalization")
Signed-off-by: Tom Rini <trini@konsulko.com>
---
 scripts/dtc/pylibfdt/setup.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

Comments

Tom Rini Jan. 8, 2023, 4:54 p.m. UTC | #1
On Sat, Jan 07, 2023 at 06:04:07PM -0500, Tom Rini wrote:

> In some cases, we might not have the sic portion of setuputils
> available. Make our import and use of this be done in try/except blocks
> as this is done to suppress a run-time warning that is otherwise
> non-fatal.
> 
> Reported-by: Pali Rohár <pali@kernel.org>
> Fixes: 141659187667 ("pylibfdt: Fix disable version normalization")
> Signed-off-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/scripts/dtc/pylibfdt/setup.py b/scripts/dtc/pylibfdt/setup.py
index c07f65e6bcaf..8baae08770ca 100755
--- a/scripts/dtc/pylibfdt/setup.py
+++ b/scripts/dtc/pylibfdt/setup.py
@@ -20,12 +20,17 @@  allows this script to be run stand-alone, e.g.:
     ./pylibfdt/setup.py install [--prefix=...]
 """
 
-from setuptools import setup, Extension, sic
+from setuptools import setup, Extension
 from setuptools.command.build_py import build_py as _build_py
 import os
 import re
 import sys
 
+try:
+    from setuptools import sic
+except ImportError:
+    pass
+
 srcdir = os.path.dirname(__file__)
 
 with open(os.path.join(srcdir, "../README"), "r") as fh:
@@ -113,7 +118,10 @@  progname = sys.argv[0]
 files = os.environ.get('SOURCES', '').split()
 cflags = os.environ.get('CPPFLAGS', '').split()
 objdir = os.environ.get('OBJDIR')
-version = os.environ.get('VERSION')
+try:
+    version = sic(os.environ.get('VERSION'))
+except:
+    version = os.environ.get('VERSION')
 swig_opts = os.environ.get('SWIG_OPTS', '').split()
 
 # If we were called directly rather than through our Makefile (which is often
@@ -137,7 +145,7 @@  class build_py(_build_py):
 
 setup(
     name='libfdt',
-    version=sic(version),
+    version=version,
     cmdclass = {'build_py' : build_py},
     author='Simon Glass',
     author_email='sjg@chromium.org',