From 2309e060ee473676d0d82acf132cfefa43cd203c8e3ea2f3e79a1f857e7ab3af Mon Sep 17 00:00:00 2001 From: Atri Bhattacharya Date: Sat, 20 Mar 2021 17:07:11 +0000 Subject: [PATCH] Accepting request 879538 from home:aaronpuchert - Fix build by adding missing python-rpm-macros dependency. - Build Python bindings for current Python version. - Make sure we're actually using the compiler flags. - Fix shebangs. OBS-URL: https://build.opensuse.org/request/show/879538 OBS-URL: https://build.opensuse.org/package/show/science/libsvm?expand=0&rev=17 --- libsvm.changes | 8 ++++++++ libsvm.spec | 35 +++++++++++++++++++++++------------ 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/libsvm.changes b/libsvm.changes index d08c8ec..3a41627 100644 --- a/libsvm.changes +++ b/libsvm.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Tue Mar 16 23:03:23 UTC 2021 - Aaron Puchert + +- Fix build by adding missing python-rpm-macros dependency. +- Build Python bindings for current Python version. +- Make sure we're actually using the compiler flags. +- Fix shebangs. + ------------------------------------------------------------------- Wed Sep 11 11:54:50 UTC 2019 - Stefan BrĂ¼ns diff --git a/libsvm.spec b/libsvm.spec index f0b1832..5b35b4c 100644 --- a/libsvm.spec +++ b/libsvm.spec @@ -1,7 +1,7 @@ # # spec file for package libsvm # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -25,12 +25,13 @@ Release: 0 URL: https://www.csie.ntu.edu.tw/~cjlin/libsvm/ Source0: https://www.csie.ntu.edu.tw/~cjlin/libsvm/%{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildRequires: %{python_module devel} BuildRequires: fdupes BuildRequires: gcc-c++ BuildRequires: java-devel BuildRequires: javapackages-tools BuildRequires: ncurses-devel -BuildRequires: python-devel +BuildRequires: python-rpm-macros %description LIBSVM is an integrated software for support vector classification, @@ -67,14 +68,14 @@ Conflicts: vpp-devel This package contains the libraries and header files needed for developing applications with libsvm. -%package -n python-svm +%package -n %{python_prefix}-svm Summary: Python bindings for libsvm Group: Development/Languages/Python Requires: gnuplot Requires: svm-tools = %{version} BuildArch: noarch -%description -n python-svm +%description -n %{python_prefix}-svm This package contains the Python bindings for libsvm. %package java @@ -94,10 +95,12 @@ This package contains the Java bindings for libsvm. %setup -q %build -export CFLAGS="%{optflags} -Wconversion -fPIC" -make -make all -make lib +# We can't override CFLAGS, we have to patch the Makefile. +sed -i ' + s/^CFLAGS = .*$/CFLAGS = %{optflags} -Wall -Wconversion -fPIC/g + s/$(CXX) $${SHARED_LIB_FLAG}/$(CXX) %{optflags} $${SHARED_LIB_FLAG}/g +' Makefile +make %{_smp_mflags} all lib rm -f java/libsvm.jar make -C java @@ -121,10 +124,18 @@ ln -s %{_libdir}/libsvm.so.2 %{buildroot}%{_libdir}/libsvm.so mv ./python/README README-python mv ./tools/README README-python-tools -install -m 755 ./python/svm.py %{buildroot}%{python_sitelib}/svm -install -m 755 ./python/svmutil.py %{buildroot}%{python_sitelib}/svm +# Don't use env in shebangs, and prefer the default Python. +# (https://www.python.org/dev/peps/pep-0394/#for-python-runtime-distributors) +sed -i '1s|/usr/bin/env *|%{_bindir}/|;1s|/usr/bin/python$|%{_bindir}/python%python_bin_suffix|' \ + %{buildroot}%{_bindir}/svm-* + +install -m 644 ./python/svm.py %{buildroot}%{python_sitelib}/svm +install -m 644 ./python/svmutil.py %{buildroot}%{python_sitelib}/svm touch %{buildroot}%{python_sitelib}/svm/__init__.py +# Remove unnecessary shebangs. +sed -i '/^#!\/usr\/bin\/env .*$/d' %{buildroot}%{python_sitelib}/svm/* + install -m 755 ./java/%{name}.jar %{buildroot}%{_javadir}/%{name}.jar %fdupes -s %{buildroot} @@ -140,14 +151,14 @@ install -m 755 ./java/%{name}.jar %{buildroot}%{_javadir}/%{name}.jar %{_bindir}/svm-predict %files -n libsvm2 -%doc COPYRIGHT +%license COPYRIGHT %{_libdir}/libsvm.so.2 %files devel %{_includedir}/libsvm %{_libdir}/libsvm.so -%files -n python-svm +%files -n %{python_prefix}-svm %doc README-python README-python-tools %{_bindir}/svm-checkdata %{_bindir}/svm-grid