]> git.pld-linux.org Git - projects/template-specs.git/blob - python.spec
- drop alt_kernel<>build_kernels conflict error, build_kernels will always take prece...
[projects/template-specs.git] / python.spec
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
9 Summary:        -
10 Summary(pl.UTF-8):      -
11 # Name must match the python module/package name (as in 'import' statement)
12 Name:           python-%{module}
13 Version:        _
14 Release:        0.1
15 License:        - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here)
16 Group:          Libraries/Python
17 Source0:        %{name}-%{version}.tar.gz
18 # Source0-md5:  -
19 URL:            -
20 # remove BR: python-devel for 'noarch' packages.
21 BuildRequires:  rpm-pythonprov
22 # if py_postclean is used
23 BuildRequires:  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}
28 BuildRequires:  python-devel
29 BuildRequires:  python-setuptools
30 %endif
31 %if %{with python3}
32 BuildRequires:  python3-devel
33 BuildRequires:  python3-modules
34 BuildRequires:  python3-setuptools
35 %endif
36 # Below Rs only work for main package (python2)
37 #Requires:              python-libs
38 Requires:       python-modules
39 #BuildArch:     noarch
40 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
41
42 %description
43
44 %description -l pl.UTF-8
45
46 %package -n python3-%{module}
47 Summary:        -
48 Summary(pl.UTF-8):      -
49 Group:          Libraries/Python
50 Requires:       python3-modules
51
52 %description -n python3-%{module}
53
54 %description -n python3-%{module} -l pl.UTF-8
55
56 %package apidocs
57 Summary:        %{module} API documentation
58 Summary(pl.UTF-8):      Dokumentacja API %{module}
59 Group:          Documentation
60
61 %description apidocs
62 API documentation for %{module}.
63
64 %description apidocs -l pl.UTF-8
65 Dokumentacja 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
74 set -- *
75 install -d py3
76 cp -a "$@" py3
77
78 %build
79 %if %{with python2}
80 # CC/CFLAGS is only for arch packages - remove on noarch packages
81 CC="%{__cc}" \
82 CFLAGS="%{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
88 CC="%{__cc}" \
89 CFLAGS="%{rpmcppflags} %{rpmcflags}" \
90 %{__python3} setup.py build --build-base build-3 %{?with_tests:test}
91 %endif
92
93 %if %{with doc}
94 cd docs
95 %{__make} -j1 html
96 rm -rf _build/html/_sources
97 %endif
98
99 %install
100 rm -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}
122 install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
123 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
124 %endif
125 %if %{with python3}
126 install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
127 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
128 find $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
140 rm -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.053224 seconds and 3 git commands to generate.