pylibfdt: Allow version normalization to fail

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: 1416591876 ("pylibfdt: Fix disable version normalization")
Signed-off-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
Tom Rini 2023-01-07 18:02:26 -05:00
parent d1f4b090dd
commit 051f409d25

View file

@ -20,12 +20,17 @@ allows this script to be run stand-alone, e.g.:
./pylibfdt/setup.py install [--prefix=...] ./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 from setuptools.command.build_py import build_py as _build_py
import os import os
import re import re
import sys import sys
try:
from setuptools import sic
except ImportError:
pass
srcdir = os.path.dirname(__file__) srcdir = os.path.dirname(__file__)
with open(os.path.join(srcdir, "../README"), "r") as fh: with open(os.path.join(srcdir, "../README"), "r") as fh:
@ -113,6 +118,9 @@ progname = sys.argv[0]
files = os.environ.get('SOURCES', '').split() files = os.environ.get('SOURCES', '').split()
cflags = os.environ.get('CPPFLAGS', '').split() cflags = os.environ.get('CPPFLAGS', '').split()
objdir = os.environ.get('OBJDIR') objdir = os.environ.get('OBJDIR')
try:
version = sic(os.environ.get('VERSION'))
except:
version = os.environ.get('VERSION') version = os.environ.get('VERSION')
swig_opts = os.environ.get('SWIG_OPTS', '').split() swig_opts = os.environ.get('SWIG_OPTS', '').split()
@ -137,7 +145,7 @@ class build_py(_build_py):
setup( setup(
name='libfdt', name='libfdt',
version=sic(version), version=version,
cmdclass = {'build_py' : build_py}, cmdclass = {'build_py' : build_py},
author='Simon Glass', author='Simon Glass',
author_email='sjg@chromium.org', author_email='sjg@chromium.org',