]> git.pld-linux.org Git - projects/template-specs.git/blame - python.spec
- rpmbuild(macros) for all macros included
[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:
3d5ea252
JB
7%bcond_without doc # Sphinx documentation
8%bcond_without tests # unit tests
0dd464e7 9%bcond_without python2 # CPython 2.x module
d328d943 10%bcond_without python3 # CPython 3.x module
4cdaa512 11
643ec869
ER
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
7170a7b1
ER
19Summary: -
20Summary(pl.UTF-8): -
2d5bfe82 21Name: python-%{module}
7170a7b1
ER
22Version: _
23Release: 0.1
24License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here)
6177d217 25Group: Libraries/Python
4b9c89b7
JB
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
7170a7b1 29# Source0-md5: -
4b9c89b7 30#URL: https://pypi.org/project/PYPI_NAME/
7170a7b1 31URL: -
0a48bf0d 32BuildRequires: rpm-pythonprov
038fedf4 33BuildRequires: rpmbuild(macros) >= 1.714
e3bbdd55 34%if %{with python2}
4e897198 35BuildRequires: python-modules
af55af9b 36BuildRequires: python-setuptools
e3bbdd55 37%endif
d328d943 38%if %{with python3}
d328d943 39BuildRequires: python3-modules
af55af9b 40BuildRequires: python3-setuptools
d328d943 41%endif
4e897198
JK
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
76f14f6a 45Requires: python-modules
4e897198 46BuildArch: noarch
7170a7b1
ER
47BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
48
49%description
50
e6f4b058 51%description -l pl.UTF-8
52
2d5bfe82 53%package -n python3-%{module}
0dd464e7
JK
54Summary: -
55Summary(pl.UTF-8): -
56Group: Libraries/Python
76f14f6a 57Requires: python3-modules
0dd464e7 58
2d5bfe82 59%description -n python3-%{module}
0dd464e7 60
2d5bfe82 61%description -n python3-%{module} -l pl.UTF-8
0dd464e7 62
660096c2 63%package apidocs
2bd7838d
JB
64Summary: API documentation for Python %{module} module
65Summary(pl.UTF-8): Dokumentacja API modułu Pythona %{module}
d328d943
ER
66Group: Documentation
67
660096c2 68%description apidocs
3dbbeb1f 69API documentation for Python %{module} module.
d328d943 70
660096c2 71%description apidocs -l pl.UTF-8
2bd7838d 72Dokumentacja API modułu Pythona %{module}.
d328d943 73
7170a7b1 74%prep
643ec869 75%setup -q -n %{pypi_name}-%{version}
7170a7b1 76
5a020810 77# fix #!/usr/bin/env python -> #!/usr/bin/python:
cb13b64b 78#%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
5a020810 79
7170a7b1 80%build
d328d943 81%if %{with python2}
4e897198 82%py_build %{?with_tests:test}
0dd464e7 83%endif
a4ec70eb 84
d328d943 85%if %{with python3}
4e897198 86%py3_build %{?with_tests:test}
d328d943
ER
87%endif
88
89%if %{with doc}
90cd docs
91%{__make} -j1 html
92rm -rf _build/html/_sources
93%endif
94
7170a7b1
ER
95%install
96rm -rf $RPM_BUILD_ROOT
d328d943
ER
97
98%if %{with python2}
4e897198 99%py_install
d328d943 100
caefe7e7
ER
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}
99f75e1c
JB
106
107%py_postclean
d328d943
ER
108%endif
109
d328d943 110%if %{with python3}
4e897198 111%py3_install
d328d943
ER
112%endif
113
0dd464e7
JK
114# in case there are examples provided
115%if %{with python2}
1ce44770
JB
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' \
c7887ed1 119 | xargs sed -i '1s|^#!.*python\b|#!%{__python}|'
0dd464e7
JK
120%endif
121%if %{with python3}
1ce44770
JB
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' \
073f936a 125 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
0dd464e7 126%endif
8424aa58 127
7170a7b1
ER
128%clean
129rm -rf $RPM_BUILD_ROOT
130
0dd464e7 131%if %{with python2}
7170a7b1
ER
132%files
133%defattr(644,root,root,755)
134%doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
4e897198 135%{py_sitescriptdir}/%{module}
643ec869 136%{py_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
1ce44770 137%{_examplesdir}/python-%{module}-%{version}
d328d943
ER
138%endif
139
140%if %{with python3}
2d5bfe82 141%files -n python3-%{module}
d328d943 142%defattr(644,root,root,755)
331aa1fb 143# copy %doc from python2 package here
d328d943 144%{py3_sitescriptdir}/%{module}
643ec869 145%{py3_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
1ce44770 146%{_examplesdir}/python3-%{module}-%{version}
d328d943
ER
147%endif
148
149%if %{with doc}
660096c2 150%files apidocs
d328d943
ER
151%defattr(644,root,root,755)
152%doc docs/_build/html/*
153%endif
This page took 1.576382 seconds and 4 git commands to generate.