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