]> git.pld-linux.org Git - packages/python-pyroute2.git/blob - python-pyroute2.spec
- builds without tests (TODO: tests)
[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:        1
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 %py3_install
107 %endif
108
109 %if %{with python2}
110 install -d $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
111 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
112 find $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} -name '*.py' \
113         | xargs sed -i '1s|^#!.*python\b|#!%{__python}|'
114 %endif
115 %if %{with python3}
116 install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
117 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
118 find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \
119         | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
120 %endif
121
122 %clean
123 rm -rf $RPM_BUILD_ROOT
124
125 %if %{with python2}
126 %files
127 %defattr(644,root,root,755)
128 %doc README* CHANGELOG.md
129 %{py_sitescriptdir}/%{module}
130 %{py_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
131 %{_examplesdir}/python-%{module}-%{version}
132 %endif
133
134 %if %{with python3}
135 %files -n python3-%{module}
136 %defattr(644,root,root,755)
137 %doc README* CHANGELOG.md
138 %attr(755,root,root) %{_bindir}/pyroute2-cli
139 %attr(755,root,root) %{_bindir}/ss2
140 %{py3_sitescriptdir}/%{module}
141 %{py3_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
142 %{_examplesdir}/python3-%{module}-%{version}
143 %endif
144
145 %if %{with doc}
146 %files apidocs
147 %defattr(644,root,root,755)
148 %doc docs/html/*
149 %endif
This page took 0.12127 seconds and 3 git commands to generate.