From 488f150bab8126c53715375ff6be4c3647d51a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Wed, 21 Jan 2026 18:54:01 +0100 Subject: [PATCH] Keep the ply library bundled, as intended upstream Related: RHEL-120810 --- pycparser-unbundle-ply.patch | 51 ------------------------------------ python3.14-pycparser.spec | 25 +++++++++--------- 2 files changed, 13 insertions(+), 63 deletions(-) delete mode 100644 pycparser-unbundle-ply.patch diff --git a/pycparser-unbundle-ply.patch b/pycparser-unbundle-ply.patch deleted file mode 100644 index 5abbf72..0000000 --- a/pycparser-unbundle-ply.patch +++ /dev/null @@ -1,51 +0,0 @@ -diff --git a/pycparser/c_lexer.py b/pycparser/c_lexer.py -index 22c64bc..a97c5d1 100644 ---- a/pycparser/c_lexer.py -+++ b/pycparser/c_lexer.py -@@ -8,8 +8,8 @@ - #------------------------------------------------------------------------------ - import re - --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 d31574a..5fc3544 100644 ---- a/pycparser/c_parser.py -+++ b/pycparser/c_parser.py -@@ -6,7 +6,7 @@ - # Eli Bendersky [https://eli.thegreenplace.net/] - # License: BSD - #------------------------------------------------------------------------------ --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 f7e89bf..f78f559 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.12', - ], - python_requires=">=3.8", -- packages=['pycparser', 'pycparser.ply'], -+ packages=['pycparser'], -+ install_requires=['ply==' + ply.__version__], - package_data={'pycparser': ['*.cfg']}, - cmdclass={'install': install, 'sdist': sdist}, - ) diff --git a/python3.14-pycparser.spec b/python3.14-pycparser.spec index 7f93c03..f5bfeb0 100644 --- a/python3.14-pycparser.spec +++ b/python3.14-pycparser.spec @@ -6,28 +6,30 @@ Name: python%{python3_pkgversion}-pycparser Summary: C parser and AST generator written in Python Version: 2.22 Release: %autorelease + +# pycparser: BSD-3-Clause +# bundled ply: BSD-3-Clause License: BSD-3-Clause + 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}-ply # for unit tests %if %{with tests} BuildRequires: gcc %endif +# pycaparser bundles ply, +# which is the preferred upstream for both upstreams. +# See https://github.com/eliben/pycparser/pull/589 +%global ply_version 3.9 +Provides: bundled(python%{python3_pkgversion}dist(ply)) = %{ply_version} + %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 @@ -36,9 +38,6 @@ 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 @@ -57,9 +56,11 @@ popd %check %pyproject_check_import +export %{py3_test_envvars} %if %{with tests} -%py3_test_envvars %{python3} -m unittest discover +%{python3} -m unittest discover %endif +%{python3} -c 'import pycparser; assert pycparser.ply.__version__ == "%{ply_version}"' %files -n python%{python3_pkgversion}-pycparser -f %{pyproject_files} %doc examples