]> git.pld-linux.org Git - packages/python-pyroute2.git/blob - python-pyroute2.spec
rebuild with tests and docs
[packages/python-pyroute2.git] / python-pyroute2.spec
1 #
2 # Conditional build:
3 %bcond_without  doc     # Sphinx documentation
4 %bcond_without  tests   # unit tests
5 %bcond_without  python2 # CPython 2.x module
6 %bcond_without  python3 # CPython 3.x module
7
8 # NOTES:
9 # - 'module' should match the Python import path (first component?)
10 # - 'egg_name' should equal to Python egg name
11 # - 'pypi_name' must match the Python Package Index name
12 %define         module          pyroute2
13 %define         egg_name        pyroute2
14 %define         pypi_name       pyroute2
15 Summary:        Python Netlink library
16 Name:           python-%{module}
17 Version:        0.5.18
18 Release:        4
19 License:        GPLv2+ or Apache v2
20 Group:          Libraries/Python
21 # if pypi:
22 #Source0Download: https://pypi.org/simple/PYPI_NAME/
23 Source0:        https://pypi.debian.net/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
24 # Source0-md5:  e9cec0003d98e1b0a4d657b87caf52d5
25 URL:            https://pyroute2.org/
26 %if %{with python2}
27 BuildRequires:  python-modules >= 1:2.5
28 BuildRequires:  python-setuptools
29 %if %{with tests}
30 #BuildRequires: python-
31 %endif
32 %endif
33 %if %{with python3}
34 BuildRequires:  python3-modules >= 1:3.2
35 BuildRequires:  python3-setuptools
36 %if %{with tests}
37 #BuildRequires: python3-
38 %endif
39 %endif
40 BuildRequires:  rpm-pythonprov
41 BuildRequires:  rpmbuild(macros) >= 1.714
42 %if %{with doc}
43 BuildRequires:  sphinx-pdg-3
44 %endif
45 Requires:       python-modules >= 1:2.5
46 BuildArch:      noarch
47 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
48
49 %description
50 Python Netlink library.
51
52 %package -n python3-%{module}
53 Summary:        Python Netlink library
54 Group:          Libraries/Python
55 Requires:       python3-modules >= 1:3.2
56
57 %description -n python3-%{module}
58 Python Netlink library.
59
60 %package apidocs
61 Summary:        API documentation for Python %{module} module
62 Summary(pl.UTF-8):      Dokumentacja API modułu Pythona %{module}
63 Group:          Documentation
64
65 %description apidocs
66 API documentation for Python %{module} module.
67
68 %description apidocs -l pl.UTF-8
69 Dokumentacja API modułu Pythona %{module}.
70
71 %prep
72 %setup -q -n %{pypi_name}-%{version}
73
74 %{__sed} -E -i -e '1s,#!\s*/usr/bin/env\s+python3(\s|$),#!%{__python3}\1,' \
75       examples/nftables.py \
76       examples/nl80211_scan_dump.py
77
78 %build
79 %if %{with python2}
80 %py_build
81 # deprecated target, but sometimes still used: %{?with_tests:test}
82
83 %if %{with tests}
84 %{__python} -m pytest ...
85 %endif
86 %endif
87
88 %if %{with python3}
89 %py3_build
90 # deprecated target, but sometimes still used: %{?with_tests:test}
91
92 %if %{with tests}
93 %{__python3} -m pytest ...
94 %endif
95 %endif
96
97 %install
98 rm -rf $RPM_BUILD_ROOT
99
100 %if %{with python2}
101 %py_install
102 %py_postclean
103 %endif
104
105 %if %{with python3}
106 %{__rm} -f $RPM_BUILD_ROOT%{_bindir}/pyroute2-cli
107 %{__rm} -f $RPM_BUILD_ROOT%{_bindir}/ss2
108 %py3_install
109 %endif
110
111 %if %{with python2}
112 install -d $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
113 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
114 find $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} -name '*.py' \
115         | xargs sed -i '1s|^#!.*python\b|#!%{__python}|'
116 %endif
117 %if %{with python3}
118 install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
119 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
120 find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \
121         | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
122 %endif
123
124 %clean
125 rm -rf $RPM_BUILD_ROOT
126
127 %if %{with python2}
128 %files
129 %defattr(644,root,root,755)
130 %doc README* CHANGELOG.md
131 %{py_sitescriptdir}/%{module}
132 %{py_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
133 %{_examplesdir}/python-%{module}-%{version}
134 %endif
135
136 %if %{with python3}
137 %files -n python3-%{module}
138 %defattr(644,root,root,755)
139 %doc README* CHANGELOG.md
140 %attr(755,root,root) %{_bindir}/pyroute2-cli
141 %attr(755,root,root) %{_bindir}/ss2
142 %{py3_sitescriptdir}/%{module}
143 %{py3_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
144 %{_examplesdir}/python3-%{module}-%{version}
145 %endif
146
147 %if %{with doc}
148 %files apidocs
149 %defattr(644,root,root,755)
150 %doc docs/html/*
151 %endif
This page took 0.163827 seconds and 3 git commands to generate.