]> git.pld-linux.org Git - projects/template-specs.git/blob - python.spec
Python template: pypi package names are also ok
[projects/template-specs.git] / python.spec
1 #
2 # This is template for pure python modules (noarch)
3 # use template-specs/python-ext.spec for binary python packages
4 #
5 #
6 # Conditional build:
7 %bcond_without  doc     # don't build doc
8 %bcond_without  tests   # do not perform "make test"
9 %bcond_without  python2 # CPython 2.x module
10 %bcond_without  python3 # CPython 3.x module
11
12 %define         module  template
13 Summary:        -
14 Summary(pl.UTF-8):      -
15 # Name must match the python module/package name (as on pypi or in 'import' statement)
16 Name:           python-%{module}
17 Version:        _
18 Release:        0.1
19 License:        - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here)
20 Group:          Libraries/Python
21 Source0:        https://pypi.python.org/packages/source/M/MODULE/%{module}-%{version}.tar.gz
22 # Source0-md5:  -
23 #URL:           https://pypi.python.org/pypi/MODULE
24 URL:            -
25 BuildRequires:  rpm-pythonprov
26 # for the py_build, py_install macros
27 BuildRequires:  rpmbuild(macros) >= 1.714
28 %if %{with python2}
29 BuildRequires:  python-modules
30 #BuildRequires: python-setuptools
31 %endif
32 %if %{with python3}
33 BuildRequires:  python3-modules
34 #BuildRequires: python3-setuptools
35 %endif
36 # when using /usr/bin/env or other in-place substitutions
37 #BuildRequires:        sed >= 4.0
38 # replace with other requires if defined in setup.py
39 Requires:       python-modules
40 BuildArch:      noarch
41 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
42
43 %description
44
45 %description -l pl.UTF-8
46
47 %package -n python3-%{module}
48 Summary:        -
49 Summary(pl.UTF-8):      -
50 Group:          Libraries/Python
51 Requires:       python3-modules
52
53 %description -n python3-%{module}
54
55 %description -n python3-%{module} -l pl.UTF-8
56
57 %package apidocs
58 Summary:        %{module} API documentation
59 Summary(pl.UTF-8):      Dokumentacja API %{module}
60 Group:          Documentation
61
62 %description apidocs
63 API documentation for %{module}.
64
65 %description apidocs -l pl.UTF-8
66 Dokumentacja API %{module}.
67
68 %prep
69 %setup -q -n %{module}-%{version}
70
71 # fix #!/usr/bin/env python -> #!/usr/bin/python:
72 #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
73
74 %build
75 %if %{with python2}
76 %py_build %{?with_tests:test}
77 %endif
78
79 %if %{with python3}
80 %py3_build %{?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 %py_install
94
95 %py_postclean
96 %endif
97
98 %if %{with python3}
99 %py3_install
100 %endif
101
102 # in case there are examples provided
103 %if %{with python2}
104 install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
105 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
106 %endif
107 %if %{with python3}
108 install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
109 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
110 find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \
111         | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
112 %endif
113
114 %clean
115 rm -rf $RPM_BUILD_ROOT
116
117 %if %{with python2}
118 %files
119 %defattr(644,root,root,755)
120 %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
121 %{py_sitescriptdir}/%{module}
122 %if "%{py_ver}" > "2.4"
123 %{py_sitescriptdir}/%{module}-%{version}-py*.egg-info
124 %endif
125 %{_examplesdir}/%{name}-%{version}
126 %endif
127
128 %if %{with python3}
129 %files -n python3-%{module}
130 %defattr(644,root,root,755)
131 %doc AUTHORS CHANGES LICENSE
132 %{py3_sitescriptdir}/%{module}
133 %{py3_sitescriptdir}/%{module}-%{version}-py*.egg-info
134 %{_examplesdir}/python3-%{module}-%{version}
135 %endif
136
137 %if %{with doc}
138 %files apidocs
139 %defattr(644,root,root,755)
140 %doc docs/_build/html/*
141 %endif
This page took 0.053902 seconds and 3 git commands to generate.