diff --git a/detect-lib-with-py3.patch b/detect-lib-with-py3.patch index fa15aaf..d1d68bb 100644 --- a/detect-lib-with-py3.patch +++ b/detect-lib-with-py3.patch @@ -1,19 +1,33 @@ --- - src/setup_common.py | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) + src/setup_common.py | 14 +++++++++++--- + 1 file changed, 11 insertions(+), 3 deletions(-) --- a/src/setup_common.py +++ b/src/setup_common.py -@@ -30,7 +30,7 @@ import subprocess, sys +@@ -30,7 +30,12 @@ import subprocess, sys if sys.version_info[0] < 3: import commands as subprocess from os import path as os_path -from distutils.sysconfig import get_python_lib -+from distutils.sysconfig import get_python_lib, get_config_var ++try: ++ from distutils.sysconfig import get_python_lib, get_config_var ++ __python_lib = get_python_lib(1) ++except ImportError: ++ from sysconfig import get_config_var, get_path ++ __python_lib = get_path('platlib') # libxml2 - C flags def libxml2_include(incdir): -@@ -69,7 +69,10 @@ def libxml2_lib(libdir, libs): +@@ -50,7 +55,7 @@ def libxml2_include(incdir): + + # libxml2 - library flags + def libxml2_lib(libdir, libs): +- libdir.append(get_python_lib(1)) ++ libdir.append(__python_lib) + if os_path.exists("/etc/debian_version"): #. XXX: Debian Workaround... + libdir.append("/usr/lib/pymodules/python%d.%d"%sys.version_info[0:2]) + +@@ -69,7 +74,10 @@ def libxml2_lib(libdir, libs): libs.append(l.replace("-l", "", 1)) # this library is not reported and we need it anyway diff --git a/python-dmidecode.changes b/python-dmidecode.changes index c236969..8718175 100644 --- a/python-dmidecode.changes +++ b/python-dmidecode.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri May 20 15:07:23 UTC 2022 - Matej Cepl + +- Synchronize SPEC file to be more like the SLE one. + ------------------------------------------------------------------- Mon Mar 7 13:44:33 UTC 2022 - Matej Cepl diff --git a/python-dmidecode.spec b/python-dmidecode.spec index da3ab90..89d5291 100644 --- a/python-dmidecode.spec +++ b/python-dmidecode.spec @@ -22,13 +22,18 @@ Name: python-dmidecode Version: 3.12.2+git.1625035095.f0a089a Release: 0 Summary: Python module to access DMI data -Group: System/Management License: GPL-2.0-only +Group: System/Libraries URL: https://github.com/nima/python-dmidecode # Source0: https://github.com/nima/python-dmidecode/archive/refs/tags/v%%{version}.tar.gz#/python-dmidecode-%%{version}.tar.gz Source0: python-dmidecode-%{version}.tar.gz +# use DWORD instead of WORD when calling dmi_memory_device_extended_size Patch0: huge-memory.patch +# PATCH-FIX-UPSTREAM gcc7-inline.patch gh#nima/python-dmidecode#35 mcepl@suse.com +# Don't use inline keyword. Patch1: gcc7-inline.patch +# PATCH-FIX-UPSTREAM detect-lib-with-py3.patch gh#nima/python-dmidecode#36 mcepl@suse.com +# Make the code future-proof against removal of distutils module. Patch2: detect-lib-with-py3.patch # PATCH-FIX-UPSTREAM 31-version_info-v-version.patch gh#nima/python-dmidecode#31 mcepl@suse.com # use sys.version_info instead of sys.version @@ -36,15 +41,16 @@ Patch3: 31-version_info-v-version.patch Obsoletes: %{oldpython}-dmidecode <= 3.12.2+git.1625035095.f0a089a Obsoletes: python-python-dmidecode <= 3.12.2+git.1625035095.f0a089a BuildRequires: %{python_module devel} -%if 0%{?sle_version} && 0%{?sle_version} < 150400 +%if 0%{?sle_version} >= 150400 || 0%{?suse_version} >= 1550 +BuildRequires: %{python_module libxml2} +%else BuildRequires: python2-libxml2-python BuildRequires: python3-libxml2-python -%else -BuildRequires: %{python_module libxml2} %endif BuildRequires: fdupes BuildRequires: libxml2-devel BuildRequires: python-rpm-macros +Requires: python Requires(post): update-alternatives Requires(postun):update-alternatives %python_subpackages @@ -57,8 +63,6 @@ structures or as XML data using libxml2. %prep %autosetup -p1 -sed -i 's/python2/python3/g' Makefile unit-tests/Makefile - %build %{python_expand export LDFLAGS="-Wl,-rpath=%{$python_sitearch}" %make_build PY_BIN=$python build @@ -67,31 +71,35 @@ sed -i 's/python2/python3/g' Makefile unit-tests/Makefile %install %{python_expand rm -f %{buildroot}%{_datadir}/python-dmidecode/pymap.xml $python src/setup.py install --root %{buildroot} --prefix=%{_prefix} -ls -l %{buildroot}%{_datadir}/python-dmidecode/ + +# prepare alternatives +install -d %{buildroot}%{_sysconfdir}/alternatives mv %{buildroot}%{_datadir}/python-dmidecode/pymap{,-%{$python_bin_suffix}}.xml -touch %{buildroot}%{_datadir}/python-dmidecode/pymap.xml +touch %{buildroot}%{_sysconfdir}/alternatives/pymap.xml +ln -s %{_sysconfdir}/alternatives/pymap.xml \ + %{buildroot}%{_datadir}/python-dmidecode/pymap.xml %fdupes %{buildroot}%{$python_sitearch} } %check pushd unit-tests -%python_expand PYTHON=$python %make_build +%{python_expand export PYTHONPATH=%{buildroot}%{$python_sitearch} +make PY_BIN=$python +} popd %post PRIO=$(echo %{python_version}|tr -d '.') -/usr/sbin/update-alternatives --install %{_datadir}/python-dmidecode/pymap.xml pymap.xml \ +%{_sbindir}/update-alternatives --install %{_datadir}/python-dmidecode/pymap.xml pymap.xml \ %{_datadir}/python-dmidecode/pymap-%{python_bin_suffix}.xml ${PRIO} %postun if [ ! -f %{_datadir}/python-dmidecode/pymap-%{python_bin_suffix}.xml ] ; then MAJVER=$(ver=%{python_version}; echo ${ver:0:1}) - /usr/sbin/update-alternatives --remove pymap.xml \ + %{_sbindir}/update-alternatives --remove pymap.xml \ %{_datadir}/python-dmidecode/pymap-%{python_bin_suffix}.xml fi -%clean - %files %{python_files} %license doc/LICENSE %doc README doc/README.upstream doc/AUTHORS doc/AUTHORS.upstream @@ -99,8 +107,9 @@ fi %ghost %{_sysconfdir}/alternatives/pymap.xml %ghost %{_datadir}/python-dmidecode/pymap.xml %{_datadir}/python-dmidecode/pymap-%{python_bin_suffix}.xml +# %{python_sitearch}/python_dmidecode-%{version}*-info +%{python_sitearch}/python_dmidecode-3.12.2*-info %{python_sitearch}/dmidecode* -%{python_sitearch}/*.egg-info -%pycache_only %{python_sitearch}/__pycache__/* +%pycache_only %{python_sitearch}/__pycache__/dmidecode*.py[co] %changelog