Initial import (#833226).

This commit is contained in:
Eric Smith 2013-07-23 09:45:25 -06:00
parent d0725ec54c
commit d7547ff8ed
7 changed files with 204 additions and 0 deletions

1
.gitignore vendored
View File

@ -0,0 +1 @@
/release_v2.09.1.tar.gz

View File

@ -0,0 +1,38 @@
diff -Naur eliben-pycparser-82ace14bb612/pycparser/c_lexer.py eliben-pycparser-82ace14bb612.modified/pycparser/c_lexer.py
--- eliben-pycparser-82ace14bb612/pycparser/c_lexer.py 2012-12-29 14:22:23.000000000 +0100
+++ eliben-pycparser-82ace14bb612.modified/pycparser/c_lexer.py 2013-03-19 23:15:05.074797841 +0100
@@ -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 -Naur eliben-pycparser-82ace14bb612/pycparser/c_parser.py eliben-pycparser-82ace14bb612.modified/pycparser/c_parser.py
--- eliben-pycparser-82ace14bb612/pycparser/c_parser.py 2012-12-29 14:22:23.000000000 +0100
+++ eliben-pycparser-82ace14bb612.modified/pycparser/c_parser.py 2013-03-19 23:15:20.338751658 +0100
@@ -8,7 +8,7 @@
#------------------------------------------------------------------------------
import re
-from .ply import yacc
+from ply import yacc
from . import c_ast
from .c_lexer import CLexer
diff -Naur eliben-pycparser-82ace14bb612/setup.py eliben-pycparser-82ace14bb612.modified/setup.py
--- eliben-pycparser-82ace14bb612/setup.py 2012-12-29 14:22:23.000000000 +0100
+++ eliben-pycparser-82ace14bb612.modified/setup.py 2013-03-19 23:14:48.861850227 +0100
@@ -22,7 +22,7 @@
classifiers = [
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',],
- packages=['pycparser', 'pycparser.ply'],
+ packages=['pycparser'],
package_data={'pycparser': ['*.cfg']},
)

View File

@ -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()

View File

@ -0,0 +1,12 @@
diff -up pycparser-release_v2.09.1/pycparser/_build_tables.py.tables-sys-path pycparser-release_v2.09.1/pycparser/_build_tables.py
--- pycparser-release_v2.09.1/pycparser/_build_tables.py.tables-sys-path 2013-07-22 13:17:44.950531002 -0600
+++ pycparser-release_v2.09.1/pycparser/_build_tables.py 2013-07-22 13:18:29.188526142 -0600
@@ -17,7 +17,7 @@ ast_gen = ASTCodeGenerator('_c_ast.cfg')
ast_gen.generate(open('c_ast.py', 'w'))
import sys
-sys.path.extend(['.', '..'])
+sys.path[0:0] = ['.', '..']
from pycparser import c_parser
# Generates the tables

View File

@ -0,0 +1,24 @@
# HG changeset patch
# User Scott Tsai <scottt.tw@gmail.com>
# Date 1358446261 -28800
# Node ID 12aa73c5da595a08f587c14a74e84bf72f0bf7a0
# Parent a46039840b0ed8466bebcddae9d4f1df60d3bc98
tests/all_tests.py: add local paths to the front of sys.path
While doing pycparser development on a machine that already has an
older version of pycparser installed, we want unit tests to run against
the local copy instead of the system wide copy of pycparser.
This patch adds '.' and '..' to the front of sys.path instead of the back.
diff --git a/tests/all_tests.py b/tests/all_tests.py
--- a/tests/all_tests.py
+++ b/tests/all_tests.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
import sys
-sys.path.extend(['.', '..'])
+sys.path[0:0] = ['.', '..']
import unittest

90
python-pycparser.spec Normal file
View File

@ -0,0 +1,90 @@
Name: python-pycparser
Version: 2.09.1
Release: 5%{?dist}
Summary: C parser and AST generator written in Python
License: BSD
URL: http://github.com/eliben/pycparser
Source0: http://github.com/eliben/pycparser/archive/release_v%{version}.tar.gz
Source1: pycparser-0.91.1-remove-relative-sys-path.py
Patch0: pycparser-0.91.1-unittests-sys-path.patch
# Submitted as upstream issue #11:
# https://github.com/eliben/pycparser/issues/11
Patch1: pycparser-0.91.1-tables-sys-path.patch
# Submitted as upstream issue #12:
# https://github.com/eliben/pycparser/issues/12
Patch100: pycparser-0.91.1-disable-embedded-ply.patch
# This is Fedora-specific; I don't think we should request upstream to
# remove embedded libraries from their distribuution, when we can remove
# them during packaging.
BuildArch: noarch
BuildRequires: python2-devel
# for unit tests
BuildRequires: python-ply
BuildRequires: dos2unix
Requires: python-ply
%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
%setup -q -n pycparser-release_v%{version}
%patch0 -p1 -b .unittests-sys-path
%patch1 -p1 -b .tables-sys-path
%patch100 -p1 -b .orig
# remove embedded copy of ply
rm -rf pycparser/ply
# examples
%{__python} %{SOURCE1} examples
dos2unix LICENSE
%build
%{__python} setup.py build
cd build/lib/pycparser
%{__python} _build_tables.py
%install
%{__python} setup.py install --skip-build --root %{buildroot}
%check
%{__python} tests/all_tests.py
%files
%doc examples LICENSE
%{python_sitelib}/pycparser/
%{python_sitelib}/pycparser-*.egg-info
%changelog
* Mon Jul 22 2013 Eric Smith <brouhaha@fedoraproject.org> 2.09.1-5
- Renumbered Fedora-specific Patch1 to Patch100
- Added new Patch1 to fix table generation when the build system
already has a python-pycparser package installed.
- Submitted Patch0 and Patch1 as upstream issues.
- Added comments about patches.
* Sun Jul 21 2013 Eric Smith <brouhaha@fedoraproject.org> 2.09.1-4
- Upstream repository is now on github.
- Fix rpmlint strange-permission complaint.
- Rename patches, Source1 to all start with pycparser-{version}, to
simplify updating patches for future upstream releases.
* Sun Jul 21 2013 Eric Smith <brouhaha@fedoraproject.org> 2.09.1-3
- Run _build_tables.py to build the lextab.py and yacctab.py; otherwise
they have to be regenerated at runtime for no benefit.
* Tue Mar 19 2013 Jos de Kloe <josdekloe@gmail.com> 2.09.1-2
- remove the embedded ply code
* Fri Jan 18 2013 Scott Tsai <scottt.tw@gmail.com> 2.09.1-1
- upstream 2.09.1

View File

@ -0,0 +1 @@
b6a3be32513fd0d5d9acce2619abdf98 release_v2.09.1.tar.gz