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