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