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