]>
Commit | Line | Data |
---|---|---|
3a01e527 JB |
1 | # |
2 | # Conditional build: | |
3 | %bcond_without tests # unit tests | |
4 | %bcond_without python2 # CPython 2.x module | |
5 | %bcond_without python3 # CPython 3.x module | |
6 | ||
97a7f1de | 7 | %define module ctypesgen |
97a7f1de | 8 | Summary: A pure-python wrapper generator for ctypes |
9966eb05 | 9 | Summary(pl.UTF-8): Generator wrapperów dla ctypes napisany w czystym Pythonie |
97a7f1de | 10 | Name: python-%{module} |
3a01e527 | 11 | Version: 1.0.2 |
5830f4a6 | 12 | Release: 3 |
97a7f1de AM |
13 | License: BSD |
14 | Group: Libraries/Python | |
3a01e527 JB |
15 | # only wheels on https://pypi.org/simple/ctypesgen so get from github |
16 | #Source0Download: https://github.com/davidjamesca/ctypesgen/releases | |
17 | Source0: https://github.com/davidjamesca/ctypesgen/archive/ctypesgen-%{version}/%{module}-%{version}.tar.gz | |
18 | # Source0-md5: 0928ef10a1f0323a82d55d6a0dfac8ff | |
d3adbc4e | 19 | Patch0: %{name}-x32.patch |
9ea10f04 | 20 | URL: https://github.com/davidjamesca/ctypesgen |
3a01e527 | 21 | %if %{with python2} |
9ea10f04 | 22 | BuildRequires: python >= 1:2.3 |
9ea10f04 | 23 | BuildRequires: python-modules >= 1:2.3 |
3a01e527 JB |
24 | BuildRequires: python-setuptools |
25 | %if %{with tests} | |
26 | BuildRequires: python-pytest | |
27 | %endif | |
28 | %endif | |
29 | %if %{with python3} | |
30 | BuildRequires: python3 >= 1:3.2 | |
31 | BuildRequires: python3-modules >= 1:3.2 | |
32 | BuildRequires: python3-setuptools | |
33 | %if %{with tests} | |
34 | BuildRequires: python3-pytest | |
35 | %endif | |
36 | %endif | |
efa91d97 | 37 | BuildRequires: rpm-pythonprov |
3a01e527 | 38 | BuildRequires: rpmbuild(macros) >= 1.714 |
97a7f1de AM |
39 | BuildArch: noarch |
40 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) | |
41 | ||
42 | %description | |
43 | This project automatically generates ctypes wrappers for header files | |
44 | written in C. | |
45 | ||
9966eb05 JB |
46 | %description -l pl.UTF-8 |
47 | Ten program automatycznie generuje wrappery ctypes dla plików | |
48 | nagłówkowych w C. | |
49 | ||
3a01e527 JB |
50 | %package -n python3-%{module} |
51 | Summary: A pure-python wrapper generator for ctypes | |
52 | Summary(pl.UTF-8): Generator wrapperów dla ctypes napisany w czystym Pythonie | |
53 | Group: Libraries/Python | |
54 | ||
55 | %description -n python3-%{module} | |
56 | This project automatically generates ctypes wrappers for header files | |
57 | written in C. | |
58 | ||
59 | %description -n python3-%{module} -l pl.UTF-8 | |
60 | Ten program automatycznie generuje wrappery ctypes dla plików | |
61 | nagłówkowych w C. | |
62 | ||
97a7f1de | 63 | %prep |
3a01e527 | 64 | %setup -q -n %{module}-%{module}-%{version} |
d3adbc4e | 65 | %patch0 -p1 |
97a7f1de AM |
66 | |
67 | %build | |
3a01e527 | 68 | %if %{with python2} |
d11d9109 | 69 | %py_build |
97a7f1de | 70 | |
3a01e527 JB |
71 | %if %{with tests} |
72 | PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \ | |
73 | %{__python} -m pytest -v -x --showlocals ctypesgen/test/testsuite.py | |
74 | %endif | |
75 | ||
76 | find ctypesgen -name '*.py[co]' | xargs %{__rm} | |
77 | %endif | |
78 | ||
79 | %if %{with python3} | |
80 | %py3_build | |
81 | ||
82 | %if %{with tests} | |
83 | PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \ | |
84 | %{__python3} -m pytest -v -x --showlocals ctypesgen/test/testsuite.py | |
85 | %endif | |
86 | ||
87 | find ctypesgen -name '__pycache__' | xargs %{__rm} -r | |
88 | %endif | |
89 | ||
97a7f1de AM |
90 | %install |
91 | rm -rf $RPM_BUILD_ROOT | |
92 | ||
3a01e527 | 93 | %if %{with python2} |
d11d9109 | 94 | %py_install |
97a7f1de | 95 | |
9966eb05 | 96 | # defaultheader.py and preamble.py are templates not modules, so .py files |
9ea10f04 | 97 | # are required instead of compiled versions |
9966eb05 | 98 | # libraryloader.py is used both as module and template, so both forms are required |
3a01e527 JB |
99 | %py_postclean -x defaultheader.py,preamble/2_5.py,preamble/2_7.py,preable/3_2.py,libraryloader.py |
100 | %{__rm} $RPM_BUILD_ROOT%{py_sitescriptdir}/ctypesgen/printer_python/defaultheader.py[co] | |
101 | %{__rm} $RPM_BUILD_ROOT%{py_sitescriptdir}/ctypesgen/printer_python/preamble/[23]_*.py[co] | |
102 | %{__rm} -r $RPM_BUILD_ROOT%{py_sitescriptdir}/ctypesgen/test | |
103 | ||
104 | %{__mv} $RPM_BUILD_ROOT%{_bindir}/ctypesgen{,-2} | |
105 | ||
106 | find ctypesgen -name '*.py[co]' | xargs %{__rm} | |
107 | %endif | |
108 | ||
109 | %if %{with python3} | |
110 | %py3_install | |
111 | ||
112 | %{__rm} -r $RPM_BUILD_ROOT%{py3_sitescriptdir}/ctypesgen/test | |
113 | ||
114 | %{__mv} $RPM_BUILD_ROOT%{_bindir}/ctypesgen{,-3} | |
115 | ln -s ctypesgen-3 $RPM_BUILD_ROOT%{_bindir}/ctypesgen | |
116 | %endif | |
9966eb05 | 117 | |
97a7f1de AM |
118 | %clean |
119 | rm -rf $RPM_BUILD_ROOT | |
120 | ||
3a01e527 | 121 | %if %{with python2} |
97a7f1de AM |
122 | %files |
123 | %defattr(644,root,root,755) | |
3a01e527 JB |
124 | %doc LICENSE README.md todo.txt |
125 | %attr(755,root,root) %{_bindir}/ctypesgen-2 | |
126 | %{py_sitescriptdir}/ctypesgen | |
127 | %{py_sitescriptdir}/ctypesgen-0.0.0-py*.egg-info | |
128 | %endif | |
129 | ||
130 | %files -n python3-%{module} | |
131 | %defattr(644,root,root,755) | |
132 | %doc LICENSE README.md todo.txt | |
133 | %attr(755,root,root) %{_bindir}/ctypesgen | |
134 | %attr(755,root,root) %{_bindir}/ctypesgen-3 | |
135 | %{py3_sitescriptdir}/ctypesgen | |
136 | %{py3_sitescriptdir}/ctypesgen-0.0.0-py*.egg-info |