]> git.pld-linux.org Git - projects/template-specs.git/blame_incremental - python.spec
drop the confusing setuptools version requirement
[projects/template-specs.git] / python.spec
... / ...
CommitLineData
1#
2# Conditional build:
3%bcond_without doc # don't build doc
4%bcond_without tests # do not perform "make test"
5%bcond_without python2 # CPython 2.x module
6%bcond_without python3 # CPython 3.x module
7
8%define module template
9Summary: -
10Summary(pl.UTF-8): -
11# Name must match the python module/package name (as in 'import' statement)
12Name: python-%{module}
13Version: _
14Release: 0.1
15License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here)
16Group: Libraries/Python
17Source0: %{name}-%{version}.tar.gz
18# Source0-md5: -
19URL: -
20# remove BR: python-devel for 'noarch' packages.
21BuildRequires: rpm-pythonprov
22# if py_postclean is used
23BuildRequires: rpmbuild(macros) >= 1.219
24# when using /usr/bin/env or other in-place substitutions
25#BuildRequires: sed >= 4.0
26# when python3 present
27%if %{with python2}
28BuildRequires: python-devel
29BuildRequires: python-setuptools
30%endif
31%if %{with python3}
32BuildRequires: python3-devel
33BuildRequires: python3-modules
34BuildRequires: python3-setuptools
35%endif
36# Below Rs only work for main package (python2)
37#Requires: python-libs
38Requires: python-modules
39#BuildArch: noarch
40BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
41
42%description
43
44%description -l pl.UTF-8
45
46%package -n python3-%{module}
47Summary: -
48Summary(pl.UTF-8): -
49Group: Libraries/Python
50Requires: python3-modules
51
52%description -n python3-%{module}
53
54%description -n python3-%{module} -l pl.UTF-8
55
56%package apidocs
57Summary: %{module} API documentation
58Summary(pl.UTF-8): Dokumentacja API %{module}
59Group: Documentation
60
61%description apidocs
62API documentation for %{module}.
63
64%description apidocs -l pl.UTF-8
65Dokumentacja API %{module}.
66
67%prep
68%setup -q -n %{module}-%{version}
69
70# fix #!/usr/bin/env python -> #!/usr/bin/python:
71#%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
72
73# setup copy of source in py3 dir
74set -- *
75install -d py3
76cp -a "$@" py3
77
78%build
79%if %{with python2}
80# CC/CFLAGS is only for arch packages - remove on noarch packages
81CC="%{__cc}" \
82CFLAGS="%{rpmcppflags} %{rpmcflags}" \
83%{__python} setup.py build --build-base build-2 %{?with_tests:test}
84%endif
85
86%if %{with python3}
87# CC/CFLAGS is only for arch packages - remove on noarch packages
88CC="%{__cc}" \
89CFLAGS="%{rpmcppflags} %{rpmcflags}" \
90%{__python3} setup.py build --build-base build-3 %{?with_tests:test}
91%endif
92
93%if %{with doc}
94cd docs
95%{__make} -j1 html
96rm -rf _build/html/_sources
97%endif
98
99%install
100rm -rf $RPM_BUILD_ROOT
101
102%if %{with python2}
103%{__python} setup.py \
104 build --build-base build-2 \
105 install --skip-build \
106 --optimize=2 \
107 --root=$RPM_BUILD_ROOT
108
109%py_postclean
110%endif
111
112%if %{with python3}
113%{__python3} setup.py \
114 build --build-base build-3 \
115 install --skip-build \
116 --optimize=2 \
117 --root=$RPM_BUILD_ROOT
118%endif
119
120# in case there are examples provided
121%if %{with python2}
122install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
123cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
124%endif
125%if %{with python3}
126install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
127cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
128find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \
129 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
130%endif
131
132# when files are installed in other way that standard 'setup.py
133# they need to be (re-)compiled
134## change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
135#%%py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
136#%%py_comp $RPM_BUILD_ROOT%{py_sitedir}
137#%%py_postclean
138
139%clean
140rm -rf $RPM_BUILD_ROOT
141
142%if %{with python2}
143%files
144%defattr(644,root,root,755)
145%doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
146# change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
147%{py_sitedir}/*.py[co]
148%attr(755,root,root) %{py_sitedir}/*.so
149%if "%{py_ver}" > "2.4"
150%{py_sitedir}/%{module}-%{version}-py*.egg-info
151%endif
152%{_examplesdir}/%{name}-%{version}
153%endif
154
155%if %{with python3}
156%files -n python3-%{module}
157%defattr(644,root,root,755)
158%doc AUTHORS CHANGES LICENSE
159%{py3_sitescriptdir}/%{module}
160%{py3_sitescriptdir}/%{module}-%{version}-py*.egg-info
161%{_examplesdir}/python3-%{module}-%{version}
162%endif
163
164%if %{with doc}
165%files apidocs
166%defattr(644,root,root,755)
167%doc docs/_build/html/*
168%endif
This page took 0.055247 seconds and 4 git commands to generate.