From cc1568eea7eb15881f0506e8b0da9e68130a9a18 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Tue, 16 May 2023 06:20:00 +0000 Subject: [PATCH] import python3.11-pycparser-2.20-1.el8 --- .gitignore | 1 + .python3.11-pycparser.metadata | 1 + ...cparser-0.91.1-remove-relative-sys-path.py | 38 ++++++++ SOURCES/pycparser-unbundle-ply.patch | 51 +++++++++++ SPECS/python3.11-pycparser.spec | 89 +++++++++++++++++++ 5 files changed, 180 insertions(+) create mode 100644 .gitignore create mode 100644 .python3.11-pycparser.metadata create mode 100644 SOURCES/pycparser-0.91.1-remove-relative-sys-path.py create mode 100644 SOURCES/pycparser-unbundle-ply.patch create mode 100644 SPECS/python3.11-pycparser.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5810cd3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/release_v2.20.tar.gz diff --git a/.python3.11-pycparser.metadata b/.python3.11-pycparser.metadata new file mode 100644 index 0000000..464832e --- /dev/null +++ b/.python3.11-pycparser.metadata @@ -0,0 +1 @@ +3a7e92b87f9fe0b863ec99b0c4ee9f90a32a3c3f SOURCES/release_v2.20.tar.gz diff --git a/SOURCES/pycparser-0.91.1-remove-relative-sys-path.py b/SOURCES/pycparser-0.91.1-remove-relative-sys-path.py new file mode 100644 index 0000000..20fcb06 --- /dev/null +++ b/SOURCES/pycparser-0.91.1-remove-relative-sys-path.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +''' +pycparser examples all contain the following boiler plate code +for running in tree. This script removes them: + +# This is not required if you've installed pycparser into +# your site-packages/ with setup.py +# +sys.path.extend(['.', '..']) +''' + +import sys +import os + +boiler_plate = "sys.path.extend(['.', '..'])\n" +d = sys.argv[1] +for (root, dirs, files) in os.walk(d): + for i in files: + if not i.endswith('.py'): + continue + fname = os.path.join(root, i) + lines = open(fname).readlines() + try: + start = lines.index(boiler_plate) + end = start + except ValueError: + start = None + end = start + if start is not None: + while lines[start-1].startswith('#'): + start -= 1 + + if start is not None and end is not None: + f = open(fname, 'w') + f.writelines(lines[:start]) + f.writelines(lines[end+1:]) + f.close() diff --git a/SOURCES/pycparser-unbundle-ply.patch b/SOURCES/pycparser-unbundle-ply.patch new file mode 100644 index 0000000..0f0cd6b --- /dev/null +++ b/SOURCES/pycparser-unbundle-ply.patch @@ -0,0 +1,51 @@ +diff --git a/pycparser/c_lexer.py b/pycparser/c_lexer.py +index 045d24e..9b3cbf2 100644 +--- a/pycparser/c_lexer.py ++++ b/pycparser/c_lexer.py +@@ -9,8 +9,8 @@ + import re + import sys + +-from .ply import lex +-from .ply.lex import TOKEN ++from ply import lex ++from ply.lex import TOKEN + + + class CLexer(object): +diff --git a/pycparser/c_parser.py b/pycparser/c_parser.py +index 744ede8..50156a3 100644 +--- a/pycparser/c_parser.py ++++ b/pycparser/c_parser.py +@@ -8,7 +8,7 @@ + #------------------------------------------------------------------------------ + import re + +-from .ply import yacc ++from ply import yacc + + from . import c_ast + from .c_lexer import CLexer +diff --git a/setup.py b/setup.py +index 6dce89c..b3dbfb4 100644 +--- a/setup.py ++++ b/setup.py +@@ -8,6 +8,8 @@ except ImportError: + from distutils.command.install import install as _install + from distutils.command.sdist import sdist as _sdist + ++import ply ++ + + def _run_build_tables(dir): + from subprocess import check_call +@@ -60,7 +62,8 @@ setup( + 'Programming Language :: Python :: 3.6', + ], + python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", +- packages=['pycparser', 'pycparser.ply'], ++ packages=['pycparser'], ++ install_requires=['ply==' + ply.__version__], + package_data={'pycparser': ['*.cfg']}, + cmdclass={'install': install, 'sdist': sdist}, + ) diff --git a/SPECS/python3.11-pycparser.spec b/SPECS/python3.11-pycparser.spec new file mode 100644 index 0000000..532aa42 --- /dev/null +++ b/SPECS/python3.11-pycparser.spec @@ -0,0 +1,89 @@ +%global __python3 /usr/bin/python3.11 +%global python3_pkgversion 3.11 + +%bcond_without tests + +Name: python%{python3_pkgversion}-pycparser +Summary: C parser and AST generator written in Python +Version: 2.20 +Release: 1%{?dist} +License: BSD +URL: http://github.com/eliben/pycparser +Source0: %{url}/archive/release_v%{version}.tar.gz +Source1: pycparser-0.91.1-remove-relative-sys-path.py + +# This is Fedora-specific; I don't think we should request upstream to +# remove embedded libraries from their distribution, when we can remove +# them during packaging. +# It also ensures that pycparser uses the same YACC __tabversion__ as ply +# package to prevent "yacc table file version is out of date" problem. +Patch100: pycparser-unbundle-ply.patch + +BuildArch: noarch + +BuildRequires: python%{python3_pkgversion}-devel +BuildRequires: python%{python3_pkgversion}-rpm-macros +BuildRequires: python%{python3_pkgversion}-setuptools +BuildRequires: python%{python3_pkgversion}-ply + +Requires: python%{python3_pkgversion}-ply + +# for unit tests +%if %{with tests} +BuildRequires: cpp +%endif + +%description +pycparser is a complete parser for the C language, written in pure Python. +It is a module designed to be easily integrated into applications that +need to parse C source code. + +%prep +%autosetup -p1 -n pycparser-release_v%{version} + +# remove embedded copy of ply +rm -r pycparser/ply + +# Remove relative sys.path from the examples +%{python3} %{SOURCE1} examples + +%build +%py3_build +pushd build/lib/pycparser +%{__python3} _build_tables.py +popd + +%install +%py3_install + +%check +%if %{with tests} +%{python3} tests/all_tests.py +%endif + +%files -n python%{python3_pkgversion}-pycparser +%license LICENSE +%doc examples +%{python3_sitelib}/pycparser/ +%{python3_sitelib}/pycparser-*.egg-info/ + +%changelog +* Tue Nov 29 2022 Charalampos Stratakis - 2.20-1 +- Initial package +- Fedora contributions by: + Charalampos Stratakis + Christian Heimes + Dennis Gilmore + Eric Smith + Igor Gnatenko + Iryna Shcherbina + Lumir Balhar + Marcel Plch + Miro HronĨok + Nathaniel McCallum + Orion Poplawski + Robert Kuska + Slavek Kabrda + Stephen Gallagher + Tom Callaway + Troy Dawson