1 |
%global with_python3 1 |
2 |
|
3 |
%define py3dir ../python3 |
4 |
|
5 |
# extracted from sip.h, SIP_API_MAJOR_NR SIP_API_MINOR_NR defines |
6 |
%define _sip_api_major 8 |
7 |
%define _sip_api_minor 1 |
8 |
%define _sip_api %{_sip_api_major}.%{_sip_api_minor} |
9 |
|
10 |
Name: python-sip |
11 |
Summary: Riverbanks's python sip |
12 |
Version: 4.13.2 |
13 |
Release: %mkrel 3 |
14 |
Epoch: 1 |
15 |
Group: Development/Python |
16 |
URL: http://www.riverbankcomputing.co.uk/software/sip/intro |
17 |
Source0: http://www.riverbankcomputing.com/static/Downloads/sip4/sip-%version.tar.gz |
18 |
License: GPLv2+ |
19 |
BuildRequires: bzip2-devel |
20 |
BuildRequires: python-devel |
21 |
%if 0%{?with_python3} |
22 |
BuildRequires: python3-devel |
23 |
%endif |
24 |
|
25 |
Provides: sip-api(%{_sip_api_major}) = %{_sip_api} |
26 |
%rename sip |
27 |
%rename sip-devel |
28 |
|
29 |
%description |
30 |
SIP is a tool that makes it very easy |
31 |
to create Python bindings for C and C++ libraries. |
32 |
It was originally developed to create PyQt, |
33 |
the Python bindings for the Qt toolkit, |
34 |
but can be used to create bindings for |
35 |
any C or C++ library. |
36 |
|
37 |
%if 0%{?with_python3} |
38 |
%package -n python3-sip |
39 |
Summary: SIP - Python 3/C++ Bindings Generator |
40 |
Group: Development/Python |
41 |
Provides: python3-sip-api(%{_sip_api_major}) = %{_sip_api} |
42 |
Provides: python3-sip-api(%{_sip_api_major}) = %{_sip_api} |
43 |
|
44 |
%description -n python3-sip |
45 |
This is the Python 3 build of SIP. |
46 |
|
47 |
SIP is a tool for generating bindings for C++ classes so that they can be |
48 |
accessed as normal Python 3 classes. SIP takes many of its ideas from SWIG but, |
49 |
because it is specifically designed for C++ and Python, is able to generate |
50 |
tighter bindings. SIP is so called because it is a small SWIG. |
51 |
|
52 |
SIP was originally designed to generate Python bindings for KDE and so has |
53 |
explicit support for the signal slot mechanism used by the Qt/KDE class |
54 |
libraries. However, SIP can be used to generate Python 3 bindings for any C++ |
55 |
class library. |
56 |
|
57 |
%package -n python3-sip-devel |
58 |
Summary: Files needed to generate Python 3 bindings for any C++ class library |
59 |
Group: Development/Python |
60 |
Requires: python3-sip = %{epoch}:%{version} |
61 |
Requires: python3-devel |
62 |
%description -n python3-sip-devel |
63 |
This package contains files needed to generate Python 3 bindings for any C++ |
64 |
classes library. |
65 |
%endif |
66 |
|
67 |
%files |
68 |
%defattr(-,root,root) |
69 |
%{_sysconfdir}/rpm/macros.d/sip.macros |
70 |
%_bindir/sip |
71 |
%py_platsitedir/s* |
72 |
%py_incdir/sip.h |
73 |
|
74 |
#------------------------------------------------------------ |
75 |
|
76 |
%prep |
77 |
%setup -q -n sip-%version |
78 |
export real_api_major=`grep SIP_API_MAJOR_NR siplib/sip.h.in|awk -F' ' '{print $3}'` |
79 |
export real_api_minor=`grep SIP_API_MINOR_NR siplib/sip.h.in|awk -F' ' '{print $3}'` |
80 |
if [ $real_api_major -ne %_sip_api_major ]; then |
81 |
echo 'Wrong spi major specified: Should be' $real_api_major ', but set' %_sip_api_major |
82 |
exit 1 |
83 |
fi |
84 |
if [ $real_api_minor -ne %_sip_api_minor ]; then |
85 |
echo 'Wrong spi minor specified: Should be' $real_api_minor ', but set' %_sip_api_minor |
86 |
exit 1 |
87 |
fi |
88 |
|
89 |
%if 0%{?with_python3} |
90 |
rm -rf %{py3dir} |
91 |
cp -a . %{py3dir} |
92 |
%endif |
93 |
|
94 |
%build |
95 |
|
96 |
%if 0%{?with_python3} |
97 |
pushd %{py3dir} |
98 |
%{__python3} configure.py -d %{python3_sitearch} CXXFLAGS="%{optflags}" CFLAGS="%{optflags}" --sipdir=%{_datadir}/python3-sip |
99 |
|
100 |
%make |
101 |
popd |
102 |
%endif |
103 |
|
104 |
# Don't use X11R6 prefix for includes neither libraries by default. |
105 |
for file in specs/linux-*; do |
106 |
perl -p -i -e "s@/X11R6/@/@g" $file |
107 |
done |
108 |
|
109 |
%{__python} configure.py |
110 |
%define _disable_ld_no_undefined 1 |
111 |
%{make} CFLAGS="%{optflags} -fPIC" CXXFLAGS="%{optflags} -fPIC" LIBS="%{?ldflags} -lpython%{py_ver}" |
112 |
|
113 |
%install |
114 |
%{__rm} -rf %{buildroot} |
115 |
# Perform the Python 3 installation first, to avoid stomping over the Python 2 |
116 |
# /usr/bin/sip: |
117 |
%if 0%{?with_python3} |
118 |
pushd %{py3dir} |
119 |
%{makeinstall_std} |
120 |
mkdir -p %{buildroot}%{_datadir}/python3-sip |
121 |
mv %{buildroot}%{_bindir}/sip %{buildroot}%{_bindir}/python3-sip |
122 |
popd |
123 |
%endif |
124 |
%{makeinstall_std} |
125 |
|
126 |
mkdir -p %{buildroot}%{_sysconfdir}/rpm/macros.d/ |
127 |
cat > %{buildroot}%{_sysconfdir}/rpm/macros.d/sip.macros << EOF |
128 |
# extracted from sip.h, SIP_API_MAJOR_NR SIP_API_MINOR_NR defines |
129 |
%%_sip_api_major %{_sip_api_major} |
130 |
%%_sip_api_minor %{_sip_api_minor} |
131 |
%%_sip_api %{_sip_api_major}.%{_sip_api_minor} |
132 |
EOF |
133 |
|
134 |
%if 0%{?with_python3} |
135 |
%files -n python3-sip |
136 |
%defattr(-,root,root,-) |
137 |
%{python3_sitearch}/* |
138 |
|
139 |
%files -n python3-sip-devel |
140 |
%defattr(-,root,root,-) |
141 |
# Note that the "sip" binary is invoked by name in a few places higher up |
142 |
# in the KDE-Python stack; these will need changing to "python3-sip": |
143 |
%{_bindir}/python3-sip |
144 |
%{_datadir}/python3-sip/ |
145 |
%{py3_incdir}/* |
146 |
%endif |
147 |
|
148 |
|