]> git.pld-linux.org Git - projects/template-specs.git/blame_incremental - python.spec
- rpmbuild(macros) for all macros included
[projects/template-specs.git] / python.spec
... / ...
CommitLineData
1#
2# This is template for pure python modules (noarch)
3# use template-specs/python-ext.spec for binary python packages
4#
5#
6# Conditional build:
7%bcond_without doc # Sphinx documentation
8%bcond_without tests # unit tests
9%bcond_without python2 # CPython 2.x module
10%bcond_without python3 # CPython 3.x module
11
12# NOTES:
13# - 'module' should match the Python import path (first component?)
14# - 'egg_name' should equal to Python egg name
15# - 'pypi_name' must match the Python Package Index name
16%define module crispy_forms
17%define egg_name django_crispy_forms
18%define pypi_name django-crispy-forms
19Summary: -
20Summary(pl.UTF-8): -
21Name: python-%{module}
22Version: _
23Release: 0.1
24License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here)
25Group: Libraries/Python
26# if pypi:
27#Source0Download: https://pypi.org/simple/PYPI_NAME/
28Source0: https://files.pythonhosted.org/packages/source/P/PYPI_NAME/%{pypi_name}-%{version}.tar.gz
29# Source0-md5: -
30#URL: https://pypi.org/project/PYPI_NAME/
31URL: -
32BuildRequires: rpm-pythonprov
33BuildRequires: rpmbuild(macros) >= 1.714
34%if %{with python2}
35BuildRequires: python-modules
36BuildRequires: python-setuptools
37%endif
38%if %{with python3}
39BuildRequires: python3-modules
40BuildRequires: python3-setuptools
41%endif
42# when using /usr/bin/env or other in-place substitutions
43#BuildRequires: sed >= 4.0
44# replace with other requires if defined in setup.py
45Requires: python-modules
46BuildArch: noarch
47BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
48
49%description
50
51%description -l pl.UTF-8
52
53%package -n python3-%{module}
54Summary: -
55Summary(pl.UTF-8): -
56Group: Libraries/Python
57Requires: python3-modules
58
59%description -n python3-%{module}
60
61%description -n python3-%{module} -l pl.UTF-8
62
63%package apidocs
64Summary: API documentation for Python %{module} module
65Summary(pl.UTF-8): Dokumentacja API modułu Pythona %{module}
66Group: Documentation
67
68%description apidocs
69API documentation for Python %{module} module.
70
71%description apidocs -l pl.UTF-8
72Dokumentacja API modułu Pythona %{module}.
73
74%prep
75%setup -q -n %{pypi_name}-%{version}
76
77# fix #!/usr/bin/env python -> #!/usr/bin/python:
78#%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
79
80%build
81%if %{with python2}
82%py_build %{?with_tests:test}
83%endif
84
85%if %{with python3}
86%py3_build %{?with_tests:test}
87%endif
88
89%if %{with doc}
90cd docs
91%{__make} -j1 html
92rm -rf _build/html/_sources
93%endif
94
95%install
96rm -rf $RPM_BUILD_ROOT
97
98%if %{with python2}
99%py_install
100
101# when files are installed in other way that standard 'setup.py
102# they need to be (re-)compiled
103# change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
104%py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
105%py_comp $RPM_BUILD_ROOT%{py_sitedir}
106
107%py_postclean
108%endif
109
110%if %{with python3}
111%py3_install
112%endif
113
114# in case there are examples provided
115%if %{with python2}
116install -d $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
117cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
118find $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} -name '*.py' \
119 | xargs sed -i '1s|^#!.*python\b|#!%{__python}|'
120%endif
121%if %{with python3}
122install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
123cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
124find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \
125 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
126%endif
127
128%clean
129rm -rf $RPM_BUILD_ROOT
130
131%if %{with python2}
132%files
133%defattr(644,root,root,755)
134%doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
135%{py_sitescriptdir}/%{module}
136%{py_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
137%{_examplesdir}/python-%{module}-%{version}
138%endif
139
140%if %{with python3}
141%files -n python3-%{module}
142%defattr(644,root,root,755)
143# copy %doc from python2 package here
144%{py3_sitescriptdir}/%{module}
145%{py3_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
146%{_examplesdir}/python3-%{module}-%{version}
147%endif
148
149%if %{with doc}
150%files apidocs
151%defattr(644,root,root,755)
152%doc docs/_build/html/*
153%endif
This page took 0.064156 seconds and 4 git commands to generate.