]> git.pld-linux.org Git - projects/template-specs.git/blob - python.spec
- BR comments fix
[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 using /usr/bin/env or other in-place substitutions
26 #BuildRequires: sed >= 4.0
27 # when python3 present
28 %if %{with python3}
29 BuildRequires:  python3-devel
30 BuildRequires:  python3-distribute
31 BuildRequires:  python3-modules
32 %endif
33 #Requires:              python-libs
34 Requires:               python-modules
35 #BuildArch:     noarch
36 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
37
38 %description
39
40 %description -l pl.UTF-8
41
42 %package -n python3-%{module}
43 Summary:        -
44 Summary(pl.UTF-8):      -
45 Group:          Libraries/Python
46
47 %description -n python3-%{module}
48
49 %description -n python3-%{module} -l pl.UTF-8
50
51 %package apidocs
52 Summary:        %{module} API documentation
53 Summary(pl.UTF-8):      Dokumentacja API %{module}
54 Group:          Documentation
55
56 %description apidocs
57 API documentation for %{module}.
58
59 %description apidocs -l pl.UTF-8
60 Dokumentacja 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
71 CC="%{__cc}" \
72 CFLAGS="%{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
78 CC="%{__cc}" \
79 CFLAGS="%{rpmcflags}" \
80 %{__python3} setup.py build --build-base build-3 %{?with_tests:test}
81 %endif
82
83 %if %{with doc}
84 cd docs
85 %{__make} -j1 html
86 rm -rf _build/html/_sources
87 %endif
88
89 %install
90 rm -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}
112 install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
113 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
114 %endif
115 %if %{with python3}
116 install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
117 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
118 find $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
130 rm -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.072628 seconds and 3 git commands to generate.