]> git.pld-linux.org Git - projects/template-specs.git/blame - python.spec
Python template: pypi package names are also ok
[projects/template-specs.git] / python.spec
CommitLineData
4cdaa512 1#
4e897198
JK
2# This is template for pure python modules (noarch)
3# use template-specs/python-ext.spec for binary python packages
4#
5#
4cdaa512 6# Conditional build:
4e897198 7%bcond_without doc # don't build doc
4cdaa512 8%bcond_without tests # do not perform "make test"
0dd464e7 9%bcond_without python2 # CPython 2.x module
d328d943 10%bcond_without python3 # CPython 3.x module
4cdaa512 11
b81eefa5 12%define module template
7170a7b1
ER
13Summary: -
14Summary(pl.UTF-8): -
d1ab9a90 15# Name must match the python module/package name (as on pypi or in 'import' statement)
b81eefa5 16Name: python-%{module}
7170a7b1
ER
17Version: _
18Release: 0.1
19License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here)
6177d217 20Group: Libraries/Python
4e897198 21Source0: https://pypi.python.org/packages/source/M/MODULE/%{module}-%{version}.tar.gz
7170a7b1 22# Source0-md5: -
4e897198 23#URL: https://pypi.python.org/pypi/MODULE
7170a7b1 24URL: -
0a48bf0d 25BuildRequires: rpm-pythonprov
4e897198 26# for the py_build, py_install macros
038fedf4 27BuildRequires: rpmbuild(macros) >= 1.714
e3bbdd55 28%if %{with python2}
4e897198
JK
29BuildRequires: python-modules
30#BuildRequires: python-setuptools
e3bbdd55 31%endif
d328d943 32%if %{with python3}
d328d943 33BuildRequires: python3-modules
4e897198 34#BuildRequires: python3-setuptools
d328d943 35%endif
4e897198
JK
36# when using /usr/bin/env or other in-place substitutions
37#BuildRequires: sed >= 4.0
38# replace with other requires if defined in setup.py
76f14f6a 39Requires: python-modules
4e897198 40BuildArch: noarch
7170a7b1
ER
41BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
42
43%description
44
e6f4b058 45%description -l pl.UTF-8
46
0dd464e7
JK
47%package -n python3-%{module}
48Summary: -
49Summary(pl.UTF-8): -
50Group: Libraries/Python
76f14f6a 51Requires: python3-modules
0dd464e7
JK
52
53%description -n python3-%{module}
54
55%description -n python3-%{module} -l pl.UTF-8
56
660096c2 57%package apidocs
d328d943
ER
58Summary: %{module} API documentation
59Summary(pl.UTF-8): Dokumentacja API %{module}
60Group: Documentation
61
660096c2 62%description apidocs
d328d943
ER
63API documentation for %{module}.
64
660096c2 65%description apidocs -l pl.UTF-8
d328d943
ER
66Dokumentacja API %{module}.
67
7170a7b1 68%prep
641675c1 69%setup -q -n %{module}-%{version}
7170a7b1 70
5a020810 71# fix #!/usr/bin/env python -> #!/usr/bin/python:
cb13b64b 72#%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
5a020810 73
7170a7b1 74%build
d328d943 75%if %{with python2}
4e897198 76%py_build %{?with_tests:test}
0dd464e7 77%endif
a4ec70eb 78
d328d943 79%if %{with python3}
4e897198 80%py3_build %{?with_tests:test}
d328d943
ER
81%endif
82
83%if %{with doc}
84cd docs
85%{__make} -j1 html
86rm -rf _build/html/_sources
87%endif
88
7170a7b1
ER
89%install
90rm -rf $RPM_BUILD_ROOT
d328d943
ER
91
92%if %{with python2}
4e897198 93%py_install
d328d943
ER
94
95%py_postclean
96%endif
97
d328d943 98%if %{with python3}
4e897198 99%py3_install
d328d943
ER
100%endif
101
0dd464e7
JK
102# in case there are examples provided
103%if %{with python2}
104install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
105cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
106%endif
107%if %{with python3}
f33c573b
JK
108install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
109cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
110find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \
073f936a 111 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
0dd464e7 112%endif
8424aa58 113
7170a7b1
ER
114%clean
115rm -rf $RPM_BUILD_ROOT
116
0dd464e7 117%if %{with python2}
7170a7b1
ER
118%files
119%defattr(644,root,root,755)
120%doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
4e897198 121%{py_sitescriptdir}/%{module}
ef0b62a1 122%if "%{py_ver}" > "2.4"
4e897198 123%{py_sitescriptdir}/%{module}-%{version}-py*.egg-info
ef278603 124%endif
8424aa58 125%{_examplesdir}/%{name}-%{version}
d328d943
ER
126%endif
127
128%if %{with python3}
129%files -n python3-%{module}
130%defattr(644,root,root,755)
131%doc AUTHORS CHANGES LICENSE
132%{py3_sitescriptdir}/%{module}
133%{py3_sitescriptdir}/%{module}-%{version}-py*.egg-info
f33c573b 134%{_examplesdir}/python3-%{module}-%{version}
d328d943
ER
135%endif
136
137%if %{with doc}
660096c2 138%files apidocs
d328d943
ER
139%defattr(644,root,root,755)
140%doc docs/_build/html/*
141%endif
This page took 0.161932 seconds and 4 git commands to generate.