3 %bcond_without tests # unit tests
4 %bcond_without python2 # CPython 2.x module
5 %bcond_without python3 # CPython 3.x module
7 %define module ctypesgen
8 Summary: A pure-python wrapper generator for ctypes
9 Summary(pl.UTF-8): Generator wrapperów dla ctypes napisany w czystym Pythonie
10 Name: python-%{module}
14 Group: Libraries/Python
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
19 Patch0: %{name}-x32.patch
20 URL: https://github.com/davidjamesca/ctypesgen
22 BuildRequires: python >= 1:2.3
23 BuildRequires: python-modules >= 1:2.3
24 BuildRequires: python-setuptools
26 BuildRequires: python-pytest
30 BuildRequires: python3 >= 1:3.2
31 BuildRequires: python3-modules >= 1:3.2
32 BuildRequires: python3-setuptools
34 BuildRequires: python3-pytest
37 BuildRequires: rpm-pythonprov
38 BuildRequires: rpmbuild(macros) >= 1.714
40 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
43 This project automatically generates ctypes wrappers for header files
46 %description -l pl.UTF-8
47 Ten program automatycznie generuje wrappery ctypes dla plików
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
55 %description -n python3-%{module}
56 This project automatically generates ctypes wrappers for header files
59 %description -n python3-%{module} -l pl.UTF-8
60 Ten program automatycznie generuje wrappery ctypes dla plików
64 %setup -q -n %{module}-%{module}-%{version}
72 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \
73 %{__python} -m pytest -v -x --showlocals ctypesgen/test/testsuite.py
76 find ctypesgen -name '*.py[co]' | xargs %{__rm}
83 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \
84 %{__python3} -m pytest -v -x --showlocals ctypesgen/test/testsuite.py
87 find ctypesgen -name '__pycache__' | xargs %{__rm} -r
91 rm -rf $RPM_BUILD_ROOT
96 # defaultheader.py and preamble.py are templates not modules, so .py files
97 # are required instead of compiled versions
98 # libraryloader.py is used both as module and template, so both forms are required
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
104 %{__mv} $RPM_BUILD_ROOT%{_bindir}/ctypesgen{,-2}
106 find ctypesgen -name '*.py[co]' | xargs %{__rm}
112 %{__rm} -r $RPM_BUILD_ROOT%{py3_sitescriptdir}/ctypesgen/test
114 %{__mv} $RPM_BUILD_ROOT%{_bindir}/ctypesgen{,-3}
115 ln -s ctypesgen-3 $RPM_BUILD_ROOT%{_bindir}/ctypesgen
119 rm -rf $RPM_BUILD_ROOT
123 %defattr(644,root,root,755)
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
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