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