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