]> git.pld-linux.org Git - projects/template-specs.git/blob - python.spec
pecl: add example how to make failed tests as XFAIL
[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 # NOTES:
13 # - 'module' should match the Python import path (first component?)
14 # - 'egg_name' should equal to Python egg name
15 # - 'pypi_name' must match the Python Package Index name
16 %define         module          crispy_forms
17 %define         egg_name        django_crispy_forms
18 %define         pypi_name       django-crispy-forms
19 Summary:        -
20 Summary(pl.UTF-8):      -
21 Name:           python-%{pypi_name}
22 Version:        _
23 Release:        0.1
24 License:        - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here)
25 Group:          Libraries/Python
26 Source0:        https://files.pythonhosted.org/packages/source/M/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
27 # Source0-md5:  -
28 #URL:           https://pypi.python.org/pypi/MODULE
29 URL:            -
30 BuildRequires:  rpm-pythonprov
31 BuildRequires:  rpmbuild(macros) >= 1.714
32 %if %{with python2}
33 BuildRequires:  python-modules
34 BuildRequires:  python-setuptools
35 %endif
36 %if %{with python3}
37 BuildRequires:  python3-modules
38 BuildRequires:  python3-setuptools
39 %endif
40 # when using /usr/bin/env or other in-place substitutions
41 #BuildRequires:        sed >= 4.0
42 # replace with other requires if defined in setup.py
43 Requires:       python-modules
44 BuildArch:      noarch
45 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
46
47 %description
48
49 %description -l pl.UTF-8
50
51 %package -n python3-%{pypi_name}
52 Summary:        -
53 Summary(pl.UTF-8):      -
54 Group:          Libraries/Python
55 Requires:       python3-modules
56
57 %description -n python3-%{pypi_name}
58
59 %description -n python3-%{pypi_name} -l pl.UTF-8
60
61 %package apidocs
62 Summary:        API documentation for Python %{module} module
63 Summary(pl.UTF-8):      Dokumentacja API modułu Pythona %{module}
64 Group:          Documentation
65
66 %description apidocs
67 API documentation for Pythona %{module} module.
68
69 %description apidocs -l pl.UTF-8
70 Dokumentacja API modułu Pythona %{module}.
71
72 %prep
73 %setup -q -n %{pypi_name}-%{version}
74
75 # fix #!/usr/bin/env python -> #!/usr/bin/python:
76 #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
77
78 %build
79 %if %{with python2}
80 %py_build %{?with_tests:test}
81 %endif
82
83 %if %{with python3}
84 %py3_build %{?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 %py_install
98
99 # when files are installed in other way that standard 'setup.py
100 # they need to be (re-)compiled
101 # change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
102 %py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
103 %py_comp $RPM_BUILD_ROOT%{py_sitedir}
104
105 %py_postclean
106 %endif
107
108 %if %{with python3}
109 %py3_install
110 %endif
111
112 # in case there are examples provided
113 %if %{with python2}
114 install -d $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
115 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
116 find $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} -name '*.py' \
117         | xargs sed -i '1s|^#!.*python\b|#!%{__python}|'
118 %endif
119 %if %{with python3}
120 install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{pypi_name}-%{version}
121 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{pypi_name}-%{version}
122 find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{pypi_name}-%{version} -name '*.py' \
123         | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
124 %endif
125
126 %clean
127 rm -rf $RPM_BUILD_ROOT
128
129 %if %{with python2}
130 %files
131 %defattr(644,root,root,755)
132 %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
133 %{py_sitescriptdir}/%{module}
134 %{py_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
135 %{_examplesdir}/python-%{module}-%{version}
136 %endif
137
138 %if %{with python3}
139 %files -n python3-%{pypi_name}
140 %defattr(644,root,root,755)
141 %doc AUTHORS CHANGES LICENSE
142 %{py3_sitescriptdir}/%{module}
143 %{py3_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
144 %{_examplesdir}/python3-%{pypi_name}-%{version}
145 %endif
146
147 %if %{with doc}
148 %files apidocs
149 %defattr(644,root,root,755)
150 %doc docs/_build/html/*
151 %endif
This page took 0.086576 seconds and 3 git commands to generate.