@@ -74,6 +74,20 @@ xz -c "$SRC_TAR" > "$SRC" || die "failed to compress sources"
7474
7575SPEC=" ./$PKG .spec"
7676cat > " $SPEC " << EOF
77+ # python3 is not available on RHEL <= 7
78+ %if 0%{?fedora} || 0%{?rhel} > 7
79+ %bcond_without python3
80+ %else
81+ %bcond_with python3
82+ %endif
83+
84+ # python2 is not available on RHEL > 7 and not needed on Fedora > 29
85+ %if 0%{?rhel} > 7 || 0%{?fedora} > 29
86+ %bcond_with python2
87+ %else
88+ %bcond_without python2
89+ %endif
90+
7791Name: $PKG
7892Version: $VER
7993Release: 1%{?dist}
@@ -94,9 +108,13 @@ This package contains the csdiff tool for comparing code scan defect lists in
94108order to find out added or fixed defects, and the csgrep utility for filtering
95109defect lists using various filtering predicates.
96110
111+ %if %{with python2}
97112%package -n python2-%{name}
98113Summary: Python interface to csdiff for Python 2
99114Conflicts: %{name} <= 1.2.3
115+ %if 0%{?fedora} > 28
116+ BuildRequires: boost-python2-devel
117+ %endif
100118BuildRequires: python2-devel
101119%{?python_provide:%python_provide python2-%{name}}
102120
@@ -108,10 +126,9 @@ code scan defect lists to find out added or fixed defects.
108126%{!?__python2: %global __python2 /usr/bin/python2}
109127%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
110128%endif
129+ %endif
111130
112- # build the python3-csdiff package on Fedora 23+
113- %global py3_support ((7 < 0%{?rhel}) || (22 < 0%{?fedora}))
114- %if %{py3_support}
131+ %if %{with python3}
115132%package -n python3-%{name}
116133Summary: Python interface to csdiff for Python 3
117134BuildRequires: boost-python3-devel
@@ -130,22 +147,34 @@ code scan defect lists to find out added or fixed defects.
130147make version.cc
131148mkdir csdiff_build
132149cd csdiff_build
150+ %cmake .. -DBUILD_PYCSDIFF=OFF
151+ make %{?_smp_mflags} VERBOSE=yes
152+
153+ %if %{with python2}
154+ mkdir ../csdiff_build_py2
155+ cd ../csdiff_build_py2
133156%cmake .. -DPYTHON_EXECUTABLE=%{__python2}
134157make %{?_smp_mflags} VERBOSE=yes
158+ %endif
135159
136- # build the python3-csdiff package on Fedora 23+
137- %if %{py3_support}
160+ %if %{with python3}
138161mkdir ../csdiff_build_py3
139162cd ../csdiff_build_py3
140163%cmake .. -DPYTHON_EXECUTABLE=%{__python3} -DBOOST_PYTHON_LIB_NAME=boost_python3
141164make %{?_smp_mflags} VERBOSE=yes pycsdiff
142165%endif
143166
144167%install
145- %if %{py3_support}
168+ %if %{with python2}
169+ mkdir -vp %{buildroot}%{python2_sitearch}
170+ install -vm0644 csdiff_build_py2/pycsdiff.so %{buildroot}%{python2_sitearch}
171+ %endif
172+
173+ %if %{with python3}
146174mkdir -vp %{buildroot}%{python3_sitearch}
147175install -vm0644 csdiff_build_py3/pycsdiff.so %{buildroot}%{python3_sitearch}
148176%endif
177+
149178cd csdiff_build
150179make install DESTDIR="\$ RPM_BUILD_ROOT"
151180
@@ -166,11 +195,13 @@ ctest %{?_smp_mflags} --output-on-failure
166195%{_mandir}/man1/cssort.1*
167196%doc COPYING README
168197
198+ %if %{with python2}
169199%files -n python2-%{name}
170200%{python2_sitearch}/pycsdiff.so
171201%doc COPYING
202+ %endif
172203
173- %if %{py3_support }
204+ %if %{with python3 }
174205%files -n python3-%{name}
175206%{python3_sitearch}/pycsdiff.so
176207%doc COPYING
0 commit comments