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