%global with_python3 1 %define py3dir ../python3 # extracted from sip.h, SIP_API_MAJOR_NR SIP_API_MINOR_NR defines %define _sip_api_major 8 %define _sip_api_minor 1 %define _sip_api %{_sip_api_major}.%{_sip_api_minor} Name: python-sip Summary: Riverbanks's python sip Version: 4.13.2 Release: %mkrel 3 Epoch: 1 Group: Development/Python URL: http://www.riverbankcomputing.co.uk/software/sip/intro Source0: http://www.riverbankcomputing.com/static/Downloads/sip4/sip-%version.tar.gz License: GPLv2+ BuildRequires: bzip2-devel BuildRequires: python-devel %if 0%{?with_python3} BuildRequires: python3-devel %endif Provides: sip-api(%{_sip_api_major}) = %{_sip_api} %rename sip %rename sip-devel %description SIP is a tool that makes it very easy to create Python bindings for C and C++ libraries. It was originally developed to create PyQt, the Python bindings for the Qt toolkit, but can be used to create bindings for any C or C++ library. %if 0%{?with_python3} %package -n python3-sip Summary: SIP - Python 3/C++ Bindings Generator Group: Development/Python Provides: python3-sip-api(%{_sip_api_major}) = %{_sip_api} Provides: python3-sip-api(%{_sip_api_major}) = %{_sip_api} %description -n python3-sip This is the Python 3 build of SIP. SIP is a tool for generating bindings for C++ classes so that they can be accessed as normal Python 3 classes. SIP takes many of its ideas from SWIG but, because it is specifically designed for C++ and Python, is able to generate tighter bindings. SIP is so called because it is a small SWIG. SIP was originally designed to generate Python bindings for KDE and so has explicit support for the signal slot mechanism used by the Qt/KDE class libraries. However, SIP can be used to generate Python 3 bindings for any C++ class library. %package -n python3-sip-devel Summary: Files needed to generate Python 3 bindings for any C++ class library Group: Development/Python Requires: python3-sip = %{epoch}:%{version} Requires: python3-devel %description -n python3-sip-devel This package contains files needed to generate Python 3 bindings for any C++ classes library. %endif %files %defattr(-,root,root) %{_sysconfdir}/rpm/macros.d/sip.macros %_bindir/sip %py_platsitedir/s* %py_incdir/sip.h #------------------------------------------------------------ %prep %setup -q -n sip-%version export real_api_major=`grep SIP_API_MAJOR_NR siplib/sip.h.in|awk -F' ' '{print $3}'` export real_api_minor=`grep SIP_API_MINOR_NR siplib/sip.h.in|awk -F' ' '{print $3}'` if [ $real_api_major -ne %_sip_api_major ]; then echo 'Wrong spi major specified: Should be' $real_api_major ', but set' %_sip_api_major exit 1 fi if [ $real_api_minor -ne %_sip_api_minor ]; then echo 'Wrong spi minor specified: Should be' $real_api_minor ', but set' %_sip_api_minor exit 1 fi %if 0%{?with_python3} rm -rf %{py3dir} cp -a . %{py3dir} %endif %build %if 0%{?with_python3} pushd %{py3dir} %{__python3} configure.py -d %{python3_sitearch} CXXFLAGS="%{optflags}" CFLAGS="%{optflags}" --sipdir=%{_datadir}/python3-sip %make popd %endif # Don't use X11R6 prefix for includes neither libraries by default. for file in specs/linux-*; do perl -p -i -e "s@/X11R6/@/@g" $file done %{__python} configure.py %define _disable_ld_no_undefined 1 %{make} CFLAGS="%{optflags} -fPIC" CXXFLAGS="%{optflags} -fPIC" LIBS="%{?ldflags} -lpython%{py_ver}" %install %{__rm} -rf %{buildroot} # Perform the Python 3 installation first, to avoid stomping over the Python 2 # /usr/bin/sip: %if 0%{?with_python3} pushd %{py3dir} %{makeinstall_std} mkdir -p %{buildroot}%{_datadir}/python3-sip mv %{buildroot}%{_bindir}/sip %{buildroot}%{_bindir}/python3-sip popd %endif %{makeinstall_std} mkdir -p %{buildroot}%{_sysconfdir}/rpm/macros.d/ cat > %{buildroot}%{_sysconfdir}/rpm/macros.d/sip.macros << EOF # extracted from sip.h, SIP_API_MAJOR_NR SIP_API_MINOR_NR defines %%_sip_api_major %{_sip_api_major} %%_sip_api_minor %{_sip_api_minor} %%_sip_api %{_sip_api_major}.%{_sip_api_minor} EOF %if 0%{?with_python3} %files -n python3-sip %defattr(-,root,root,-) %{python3_sitearch}/* %files -n python3-sip-devel %defattr(-,root,root,-) # Note that the "sip" binary is invoked by name in a few places higher up # in the KDE-Python stack; these will need changing to "python3-sip": %{_bindir}/python3-sip %{_datadir}/python3-sip/ %{py3_incdir}/* %endif