[packages/python-ctypesgen] - updated to 1.0.2 release - removed obsolete gcc7-fix patch - added python3- package - executables

qboosh qboosh at pld-linux.org
Sat Jul 3 21:50:45 CEST 2021


commit 3a01e527b63e3f3ec57cb061b61ad43372d7591f
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Sat Jul 3 21:53:52 2021 +0200

    - updated to 1.0.2 release
    - removed obsolete gcc7-fix patch
    - added python3- package
    - executables are now named ctypesgen-2 (for py2) and ctypesgen{,-3} (for py3)

 gcc7-fix.patch        |  36 --------------
 python-ctypesgen.spec | 128 ++++++++++++++++++++++++++++++++++++--------------
 2 files changed, 94 insertions(+), 70 deletions(-)
---
diff --git a/python-ctypesgen.spec b/python-ctypesgen.spec
index a776c11..f2b4bdb 100644
--- a/python-ctypesgen.spec
+++ b/python-ctypesgen.spec
@@ -1,25 +1,40 @@
-# TODO: programs shouldn't have ".py" extension
+#
+# Conditional build:
+%bcond_without	tests	# unit tests
+%bcond_without	python2 # CPython 2.x module
+%bcond_without	python3 # CPython 3.x module
+
 %define 	module	ctypesgen
-%define		snap	20150512
-%define		gitref	3d2d9803339503d2988382aa861b47a6a4872c32
-%define		rel	2
 Summary:	A pure-python wrapper generator for ctypes
 Summary(pl.UTF-8):	Generator wrapperów dla ctypes napisany w czystym Pythonie
 Name:		python-%{module}
-Version:	0.0
-Release:	1.%{snap}.%{rel}
+Version:	1.0.2
+Release:	1
 License:	BSD
 Group:		Libraries/Python
-Source0:	https://github.com/davidjamesca/ctypesgen/archive/%{gitref}/%{module}-%{snap}.tar.gz
-# Source0-md5:	abbc70e2fb7c5391ade6b56bd503c6ed
-Patch0:		gcc7-fix.patch
+# only wheels on https://pypi.org/simple/ctypesgen so get from github
+#Source0Download: https://github.com/davidjamesca/ctypesgen/releases
+Source0:	https://github.com/davidjamesca/ctypesgen/archive/ctypesgen-%{version}/%{module}-%{version}.tar.gz
+# Source0-md5:	0928ef10a1f0323a82d55d6a0dfac8ff
 URL:		https://github.com/davidjamesca/ctypesgen
+%if %{with python2}
 BuildRequires:	python >= 1:2.3
-BuildRequires:	python-devel >= 1:2.3
 BuildRequires:	python-modules >= 1:2.3
+BuildRequires:	python-setuptools
+%if %{with tests}
+BuildRequires:	python-pytest
+%endif
+%endif
+%if %{with python3}
+BuildRequires:	python3 >= 1:3.2
+BuildRequires:	python3-modules >= 1:3.2
+BuildRequires:	python3-setuptools
+%if %{with tests}
+BuildRequires:	python3-pytest
+%endif
+%endif
 BuildRequires:	rpm-pythonprov
-BuildRequires:	rpmbuild(macros) >= 1.710
-%pyrequires_eq	python-modules
+BuildRequires:	rpmbuild(macros) >= 1.714
 BuildArch:	noarch
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
@@ -31,44 +46,89 @@ written in C.
 Ten program automatycznie generuje wrappery ctypes dla plików
 nagłówkowych w C.
 
+%package -n python3-%{module}
+Summary:	A pure-python wrapper generator for ctypes
+Summary(pl.UTF-8):	Generator wrapperów dla ctypes napisany w czystym Pythonie
+Group:		Libraries/Python
+
+%description -n python3-%{module}
+This project automatically generates ctypes wrappers for header files
+written in C.
+
+%description -n python3-%{module} -l pl.UTF-8
+Ten program automatycznie generuje wrappery ctypes dla plików
+nagłówkowych w C.
+
 %prep
-%setup -q -n %{module}-%{gitref}
-%patch0 -p1
+%setup -q -n %{module}-%{module}-%{version}
 
 %build
+%if %{with python2}
 %py_build
 
+%if %{with tests}
+PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \
+%{__python} -m pytest -v -x --showlocals ctypesgen/test/testsuite.py
+%endif
+
+find ctypesgen -name '*.py[co]' | xargs %{__rm}
+%endif
+
+%if %{with python3}
+%py3_build
+
+%if %{with tests}
+PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \
+%{__python3} -m pytest -v -x --showlocals ctypesgen/test/testsuite.py
+%endif
+
+find ctypesgen -name '__pycache__' | xargs %{__rm} -r
+%endif
+
 %install
 rm -rf $RPM_BUILD_ROOT
 
+%if %{with python2}
 %py_install
 
 # defaultheader.py and preamble.py are templates not modules, so .py files
 # are required instead of compiled versions
 # libraryloader.py is used both as module and template, so both forms are required
-%py_postclean -x defaultheader.py,preamble.py,libraryloader.py
-%{__rm} $RPM_BUILD_ROOT%{py_sitescriptdir}/ctypesgencore/printer_python/{defaultheader,preamble}.py[co]
+%py_postclean -x defaultheader.py,preamble/2_5.py,preamble/2_7.py,preable/3_2.py,libraryloader.py
+%{__rm} $RPM_BUILD_ROOT%{py_sitescriptdir}/ctypesgen/printer_python/defaultheader.py[co]
+%{__rm} $RPM_BUILD_ROOT%{py_sitescriptdir}/ctypesgen/printer_python/preamble/[23]_*.py[co]
+%{__rm} -r $RPM_BUILD_ROOT%{py_sitescriptdir}/ctypesgen/test
+
+%{__mv} $RPM_BUILD_ROOT%{_bindir}/ctypesgen{,-2}
+
+find ctypesgen -name '*.py[co]' | xargs %{__rm}
+%endif
+
+%if %{with python3}
+%py3_install
+
+%{__rm} -r $RPM_BUILD_ROOT%{py3_sitescriptdir}/ctypesgen/test
+
+%{__mv} $RPM_BUILD_ROOT%{_bindir}/ctypesgen{,-3}
+ln -s ctypesgen-3 $RPM_BUILD_ROOT%{_bindir}/ctypesgen
+%endif
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
+%if %{with python2}
 %files
 %defattr(644,root,root,755)
-%doc LICENSE todo.txt
-%attr(755,root,root) %{_bindir}/ctypesgen.py
-%{py_sitescriptdir}/ctypesgen-0.0-py*.egg-info
-%dir %{py_sitescriptdir}/ctypesgencore
-%{py_sitescriptdir}/ctypesgencore/*.py[co]
-%{py_sitescriptdir}/ctypesgencore/libraryloader.py
-%dir %{py_sitescriptdir}/ctypesgencore/parser
-%{py_sitescriptdir}/ctypesgencore/parser/*.py[co]
-%dir %{py_sitescriptdir}/ctypesgencore/printer_json
-%{py_sitescriptdir}/ctypesgencore/printer_json/*.py[co]
-%dir %{py_sitescriptdir}/ctypesgencore/printer_python
-%{py_sitescriptdir}/ctypesgencore/printer_python/__init__.py[co]
-%{py_sitescriptdir}/ctypesgencore/printer_python/printer.py[co]
-%{py_sitescriptdir}/ctypesgencore/printer_python/test.py[co]
-%{py_sitescriptdir}/ctypesgencore/printer_python/defaultheader.py
-%{py_sitescriptdir}/ctypesgencore/printer_python/preamble.py
-%dir %{py_sitescriptdir}/ctypesgencore/processor
-%{py_sitescriptdir}/ctypesgencore/processor/*.py[co]
+%doc LICENSE README.md todo.txt
+%attr(755,root,root) %{_bindir}/ctypesgen-2
+%{py_sitescriptdir}/ctypesgen
+%{py_sitescriptdir}/ctypesgen-0.0.0-py*.egg-info
+%endif
+
+%files -n python3-%{module}
+%defattr(644,root,root,755)
+%doc LICENSE README.md todo.txt
+%attr(755,root,root) %{_bindir}/ctypesgen
+%attr(755,root,root) %{_bindir}/ctypesgen-3
+%{py3_sitescriptdir}/ctypesgen
+%{py3_sitescriptdir}/ctypesgen-0.0.0-py*.egg-info
diff --git a/gcc7-fix.patch b/gcc7-fix.patch
deleted file mode 100644
index 00f4c05..0000000
--- a/gcc7-fix.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff -ur ctypesgen.orig/ctypesgencore/parser/lextab.py ctypesgen/ctypesgencore/parser/lextab.py
---- ctypesgen.orig/ctypesgencore/parser/lextab.py	2015-05-11 16:17:08.000000000 +0000
-+++ ctypesgen/ctypesgencore/parser/lextab.py	2018-01-22 10:30:56.565147882 +0000
-@@ -3,6 +3,6 @@
- _lexreflags   = 0
- _lexliterals  = ''
- _lexstateinfo = {'INITIAL': 'inclusive', 'DEFINE': 'exclusive'}
--_lexstatere   = {'INITIAL': [('(?P<t_ANY_directive>\\#\\s+(\\d+)\\s+"([^"]+)"[ \\d]*\\n)|(?P<t_ANY_punctuator>(\\.\\.\\.|\\|\\||\\+\\+|\\*=|\\^=|<<=|>>=|\\|=|\\+=|>=|>>|<<|<=|<:|%=|:>|<%|!=|\\)|\\+|\\*|\\.|\\?|==|&=|&&|\\[|\\^|--|/=|%>|-=|->|\\||!|%|&|-|,|/|;|:|=|>|]|<|{|}|~))', [None, ('t_ANY_directive', 'ANY_directive'), None, None, ('t_ANY_punctuator', 'ANY_punctuator')]), ('(?P<t_INITIAL_identifier>[a-zA-Z_]([a-zA-Z_]|[0-9])*)', [None, ('t_INITIAL_identifier', 'INITIAL_identifier')]), ('(?P<t_ANY_float>(?P<p1>[0-9]+)?(?P<dp>[.]?)(?P<p2>(?(p1)[0-9]*|[0-9]+))(?P<exp>(?:[Ee][+-]?[0-9]+)?)(?P<suf>[FflL]?)(?!\\w))', [None, ('t_ANY_float', 'ANY_float'), None, None, None, None, None]), ('(?P<t_ANY_int>(?P<p1>(?:0x[a-fA-F0-9]+)|(?:[0-9]+))(?P<suf>[uUlL]*))', [None, ('t_ANY_int', 'ANY_int'), None, None]), ('(?P<t_ANY_character_constant>L?\'(\\\\.|[^\\\\\'])+\')|(?P<t_ANY_string_literal>L?"(\\\\.|[^\\\\"])*")|(?P<t_ANY_lparen>\\()|(?P<t_INITIAL_newline>\\n)|(?P<t_INITIAL_pp_define>\\#define)', [None, ('t_ANY_character_constant', 'ANY_character_constant'), None, ('t_ANY_string_literal', 'ANY_string_literal'), None, ('t_ANY_lparen', 'ANY_lparen'), ('t_INITIAL_newline', 'INITIAL_newline'), ('t_INITIAL_pp_define', 'INITIAL_pp_define')])], 'DEFINE': [('(?P<t_ANY_directive>\\#\\s+(\\d+)\\s+"([^"]+)"[ \\d]*\\n)|(?P<t_ANY_punctuator>(\\.\\.\\.|\\|\\||\\+\\+|\\*=|\\^=|<<=|>>=|\\|=|\\+=|>=|>>|<<|<=|<:|%=|:>|<%|!=|\\)|\\+|\\*|\\.|\\?|==|&=|&&|\\[|\\^|--|/=|%>|-=|->|\\||!|%|&|-|,|/|;|:|=|>|]|<|{|}|~))', [None, ('t_ANY_directive', 'ANY_directive'), None, None, ('t_ANY_punctuator', 'ANY_punctuator')]), ('(?P<t_DEFINE_identifier>[a-zA-Z_]([a-zA-Z_]|[0-9])*)', [None, ('t_DEFINE_identifier', 'DEFINE_identifier')]), ('(?P<t_ANY_float>(?P<p1>[0-9]+)?(?P<dp>[.]?)(?P<p2>(?(p1)[0-9]*|[0-9]+))(?P<exp>(?:[Ee][+-]?[0-9]+)?)(?P<suf>[FflL]?)(?!\\w))', [None, ('t_ANY_float', 'ANY_float'), None, None, None, None, None]), ('(?P<t_ANY_int>(?P<p1>(?:0x[a-fA-F0-9]+)|(?:[0-9]+))(?P<suf>[uUlL]*))', [None, ('t_ANY_int', 'ANY_int'), None, None]), ('(?P<t_ANY_character_constant>L?\'(\\\\.|[^\\\\\'])+\')|(?P<t_ANY_string_literal>L?"(\\\\.|[^\\\\"])*")|(?P<t_ANY_lparen>\\()|(?P<t_DEFINE_newline>\\n)|(?P<t_DEFINE_pp_param_op>(\\#\\#)|(\\#))', [None, ('t_ANY_character_constant', 'ANY_character_constant'), None, ('t_ANY_string_literal', 'ANY_string_literal'), None, ('t_ANY_lparen', 'ANY_lparen'), ('t_DEFINE_newline', 'DEFINE_newline'), ('t_DEFINE_pp_param_op', 'DEFINE_pp_param_op')])]}
-+_lexstatere   = {'INITIAL': [('(?P<t_ANY_directive>\\#\\s+(\\d+)\\s+"([^"]+)"[ \\d]*\\n)|(?P<t_ANY_punctuator>(\\.\\.\\.|\\|\\||\\+\\+|>>=|\\|=|\\^=|<<=|\\*=|\\+=|>=|>>|%=|:>|%>|!=|\\*|\\.|==|\\^|--|-=|->|\\||<<|<=|<:|<%|\\)|\\+|\\?|&=|&&|\\[|/=|&|,|:|<|>|~|!|%|-|/|;|=|]|{|}))', [None, ('t_ANY_directive', 'ANY_directive'), None, None, ('t_ANY_punctuator', 'ANY_punctuator')]), ('(?P<t_INITIAL_identifier>[a-zA-Z_]([a-zA-Z_]|[0-9])*)', [None, ('t_INITIAL_identifier', 'INITIAL_identifier')]), ('(?P<t_ANY_float>(?P<p1>[0-9]+)?(?P<dp>[.]?)(?P<p2>(?(p1)[0-9]*|[0-9]+))(?P<exp>(?:[Ee][+-]?[0-9]+)?)(?P<suf>([FfLl]|d[dfl]|D[DFL]|[fFdD][0-9]+x?)?)(?!\\w))', [None, ('t_ANY_float', 'ANY_float'), None, None, None, None, None]), ('(?P<t_ANY_int>(?P<p1>(?:0x[a-fA-F0-9]+)|(?:[0-9]+))(?P<suf>[uUlL]*))', [None, ('t_ANY_int', 'ANY_int'), None, None]), ('(?P<t_ANY_character_constant>L?\'(\\\\.|[^\\\\\'])+\')|(?P<t_ANY_string_literal>L?"(\\\\.|[^\\\\"])*")|(?P<t_ANY_lparen>\\()|(?P<t_INITIAL_newline>\\n)|(?P<t_INITIAL_pp_define>\\#define)', [None, ('t_ANY_character_constant', 'ANY_character_constant'), None, ('t_ANY_string_literal', 'ANY_string_literal'), None, ('t_ANY_lparen', 'ANY_lparen'), ('t_INITIAL_newline', 'INITIAL_newline'), ('t_INITIAL_pp_define', 'INITIAL_pp_define')])], 'DEFINE': [('(?P<t_ANY_directive>\\#\\s+(\\d+)\\s+"([^"]+)"[ \\d]*\\n)|(?P<t_ANY_punctuator>(\\.\\.\\.|\\|\\||\\+\\+|>>=|\\|=|\\^=|<<=|\\*=|\\+=|>=|>>|%=|:>|%>|!=|\\*|\\.|==|\\^|--|-=|->|\\||<<|<=|<:|<%|\\)|\\+|\\?|&=|&&|\\[|/=|&|,|:|<|>|~|!|%|-|/|;|=|]|{|}))', [None, ('t_ANY_directive', 'ANY_directive'), None, None, ('t_ANY_punctuator', 'ANY_punctuator')]), ('(?P<t_DEFINE_identifier>[a-zA-Z_]([a-zA-Z_]|[0-9])*)', [None, ('t_DEFINE_identifier', 'DEFINE_identifier')]), ('(?P<t_ANY_float>(?P<p1>[0-9]+)?(?P<dp>[.]?)(?P<p2>(?(p1)[0-9]*|[0-9]+))(?P<exp>(?:[Ee][+-]?[0-9]+)?)(?P<suf>([FfLl]|d[dfl]|D[DFL]|[fFdD][0-9]+x?)?)(?!\\w))', [None, ('t_ANY_float', 'ANY_float'), None, None, None, None, None]), ('(?P<t_ANY_int>(?P<p1>(?:0x[a-fA-F0-9]+)|(?:[0-9]+))(?P<suf>[uUlL]*))', [None, ('t_ANY_int', 'ANY_int'), None, None]), ('(?P<t_ANY_character_constant>L?\'(\\\\.|[^\\\\\'])+\')|(?P<t_ANY_string_literal>L?"(\\\\.|[^\\\\"])*")|(?P<t_ANY_lparen>\\()|(?P<t_DEFINE_newline>\\n)|(?P<t_DEFINE_pp_param_op>(\\#\\#)|(\\#))', [None, ('t_ANY_character_constant', 'ANY_character_constant'), None, ('t_ANY_string_literal', 'ANY_string_literal'), None, ('t_ANY_lparen', 'ANY_lparen'), ('t_DEFINE_newline', 'DEFINE_newline'), ('t_DEFINE_pp_param_op', 'DEFINE_pp_param_op')])]}
- _lexstateignore = {'INITIAL': ' \t\x0b\x0c\r', 'DEFINE': ' \t\x0b\x0c\r'}
- _lexstateerrorf = {'INITIAL': 't_INITIAL_error', 'DEFINE': 't_DEFINE_error'}
-diff -ur ctypesgen.orig/ctypesgencore/parser/pplexer.py ctypesgen/ctypesgencore/parser/pplexer.py
---- ctypesgen.orig/ctypesgencore/parser/pplexer.py	2015-05-11 16:17:08.000000000 +0000
-+++ ctypesgen/ctypesgencore/parser/pplexer.py	2018-01-22 10:31:29.006145948 +0000
-@@ -36,7 +36,7 @@
-     'L': '[a-zA-Z_]',
-     'H': '[a-fA-F0-9]',
-     'E': '[Ee][+-]?\s*{D}+',
--    'FS': '[FflL]',
-+    'FS': '([FfLl]|d[dfl]|D[DFL]|[fFdD][0-9]+x?)',
-     'IS': '[uUlL]*',
- }
- # Helper: substitute {foo} with subs[foo] in string (makes regexes more lexy)
-@@ -184,10 +184,10 @@
-     exp = m.group("exp")
-     suf = m.group("suf")
- 
--    if dp or exp or (suf and suf in ("Ff")):
-+    if dp or exp or (suf and suf not in ("Ll")):
-         s = m.group(0)
-         if suf:
--            s = s[:-1]
-+            s = s[:-len(suf)]
-         # Attach a prefix so the parser can figure out if should become an
-         # integer, float, or long
-         t.value = "f" + s
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/python-ctypesgen.git/commitdiff/3a01e527b63e3f3ec57cb061b61ad43372d7591f



More information about the pld-cvs-commit mailing list