]>
Commit | Line | Data |
---|---|---|
367df2cb JB |
1 | # |
2 | # This is template for python 3 extension modules (including compiled C code) | |
3 | # use template-specs/python3.spec for pure python packages | |
4 | # | |
5 | # Conditional build: | |
09ee490b JB |
6 | %bcond_without doc # API documentation |
7 | %bcond_without tests # unit tests | |
367df2cb | 8 | |
688a1eb4 | 9 | %define module template |
367df2cb JB |
10 | Summary: - |
11 | Summary(pl.UTF-8): - | |
12 | # Name must match the python module/package name (as on pypi or in 'import' statement) | |
13 | Name: python3-%{module} | |
14 | Version: _ | |
15 | Release: 0.1 | |
16 | License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here) | |
17 | Group: Libraries/Python | |
18 | # if pypi: | |
19 | #Source0Download: https://pypi.org/simple/MODULE/ | |
20 | Source0: https://files.pythonhosted.org/packages/source/M/MODULE/%{module}-%{version}.tar.gz | |
21 | # Source0-md5: - | |
22 | #URL: https://pypi.org/project/MODULE/ | |
23 | URL: - | |
1a50796a | 24 | BuildRequires: python3-devel >= 1:3.2 |
367df2cb JB |
25 | #BuildRequires: python3-setuptools |
26 | %if %{with tests} | |
27 | #BuildRequires: python3- | |
28 | %endif | |
28eb9a67 JB |
29 | # if using noarch subpackage: |
30 | #BuildRequires: rpm-build >= 4.6 | |
367df2cb JB |
31 | BuildRequires: rpm-pythonprov |
32 | BuildRequires: rpmbuild(macros) >= 1.714 | |
367df2cb JB |
33 | # when using /usr/bin/env or other in-place substitutions |
34 | #BuildRequires: sed >= 4.0 | |
35 | %if %{with doc} | |
36 | BuildRequires: sphinx-pdg-3 | |
37 | %endif | |
38 | # replace with other requires if defined in setup.py | |
b95097ca | 39 | Requires: python3-modules >= 1:3.2 |
367df2cb JB |
40 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) |
41 | ||
42 | %description | |
43 | ||
44 | %description -l pl.UTF-8 | |
45 | ||
367df2cb | 46 | %package apidocs |
1a50796a JB |
47 | Summary: API documentation for Python %{module} module |
48 | Summary(pl.UTF-8): Dokumentacja API modułu Pythona %{module} | |
367df2cb | 49 | Group: Documentation |
28eb9a67 | 50 | BuildArch: noarch |
367df2cb JB |
51 | |
52 | %description apidocs | |
1a50796a | 53 | API documentation for Python %{module} module. |
367df2cb JB |
54 | |
55 | %description apidocs -l pl.UTF-8 | |
1a50796a | 56 | Dokumentacja API modułu Pythona %{module}. |
367df2cb JB |
57 | |
58 | %prep | |
59 | %setup -q -n %{module}-%{version} | |
60 | ||
61 | # fix #!/usr/bin/env python -> #!/usr/bin/python: | |
62 | #%{__sed} -i -e '1s,^#!.*python3,#!%{__python3},' %{name}.py | |
63 | ||
64 | %build | |
65 | %py3_build | |
66 | # deprecated target, but sometimes still used: %{?with_tests:test} | |
67 | ||
68 | %if %{with tests} | |
7302396e JB |
69 | # use explicit plugins list for reliable builds (delete PYTEST_PLUGINS if empty) |
70 | PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \ | |
71 | PYTEST_PLUGINS= \ | |
367df2cb JB |
72 | %{__python3} -m pytest ... |
73 | %endif | |
74 | ||
75 | %if %{with doc} | |
76 | %{__make} -C docs html \ | |
77 | SPHINXBUILD=sphinx-build-3 | |
78 | rm -rf docs/_build/html/_sources | |
79 | %endif | |
80 | ||
81 | %install | |
82 | rm -rf $RPM_BUILD_ROOT | |
83 | ||
84 | %py3_install | |
85 | ||
86 | %if %{with enable_if_there_are_examples_provided_in_package} | |
87 | install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} | |
88 | cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} | |
89 | find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \ | |
90 | | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|' | |
91 | %endif | |
92 | ||
93 | %clean | |
94 | rm -rf $RPM_BUILD_ROOT | |
95 | ||
96 | %files | |
97 | %defattr(644,root,root,755) | |
98 | %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO | |
99 | %dir %{py3_sitedir}/%{module} | |
100 | %{py3_sitedir}/%{module}/*.py | |
101 | %attr(755,root,root) %{py3_sitedir}/%{module}/*.so | |
102 | %{py3_sitedir}/%{module}/__pycache__ | |
103 | %{py3_sitedir}/%{module}-%{version}-py*.egg-info | |
104 | %{_examplesdir}/%{name}-%{version} | |
105 | ||
106 | %if %{with doc} | |
107 | %files apidocs | |
108 | %defattr(644,root,root,755) | |
109 | %doc docs/_build/html/* | |
110 | %endif |