View | Details | Raw Unified | Return to bug 203525
Collapse All | Expand All

(-)Makefile (-10 / +1 lines)
Lines 2-9 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	ply
4
PORTNAME=	ply
5
PORTVERSION=	3.6
5
PORTVERSION=	3.8
6
PORTREVISION=	1
7
CATEGORIES=	devel python
6
CATEGORIES=	devel python
8
MASTER_SITES=	http://www.dabeaz.com/ply/
7
MASTER_SITES=	http://www.dabeaz.com/ply/
9
PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
8
PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
Lines 20-33 Link Here
20
19
21
OPTIONS_DEFINE=	DOCS EXAMPLES
20
OPTIONS_DEFINE=	DOCS EXAMPLES
22
21
23
post-extract:
24
	@${FIND} ${WRKSRC}/example -name "*.pyc" -type f -delete
25
	@${FIND} ${WRKSRC}/example -name "__pycache__" -type d -delete
26
27
pre-configure:
28
	@${REINPLACE_CMD} -e 's|from setuptools import setup|from distutils.core import setup|' \
29
		${WRKSRC}/setup.py
30
31
post-install:
22
post-install:
32
	@${MKDIR} ${STAGEDIR}${DOCSDIR}
23
	@${MKDIR} ${STAGEDIR}${DOCSDIR}
33
	${INSTALL_DATA} ${WRKSRC}/doc/ply.html ${STAGEDIR}${DOCSDIR}
24
	${INSTALL_DATA} ${WRKSRC}/doc/ply.html ${STAGEDIR}${DOCSDIR}
(-)distinfo (-2 / +2 lines)
Lines 1-2 Link Here
1
SHA256 (ply-3.6.tar.gz) = 61367b9eb2f4b819f69ea116750305270f1df8859992c9e356d6a851f25a4b47
1
SHA256 (ply-3.8.tar.gz) = e7d1bdff026beb159c9942f7a17e102c375638d9478a7ecd4cc0c76afd8de0b8
2
SIZE (ply-3.6.tar.gz) = 281690
2
SIZE (ply-3.8.tar.gz) = 157286
(-)files/patch-CHANGES (-12 lines)
Lines 1-12 Link Here
1
--- CHANGES.orig	2015-04-25 14:15:57 UTC
2
+++ CHANGES
3
@@ -1,3 +1,9 @@
4
+Version 3.7
5
+---------------------
6
+05/07/15: beazley
7
+          Fixed regression in handling of table modules if specified as module
8
+          objects.   See https://github.com/dabeaz/ply/issues/63
9
+
10
 Version 3.6
11
 ---------------------
12
 04/25/15: beazley
(-)files/patch-ply_lex.py (-82 lines)
Lines 1-82 Link Here
1
--- ply/lex.py.orig	2015-04-26 21:17:41 UTC
2
+++ ply/lex.py
3
@@ -171,7 +171,10 @@ class Lexer:
4
     # ------------------------------------------------------------
5
     # writetab() - Write lexer information to a table file
6
     # ------------------------------------------------------------
7
-    def writetab(self, basetabmodule, outputdir=''):
8
+    def writetab(self, lextab, outputdir=''):
9
+        if isinstance(lextab, types.ModuleType):
10
+            raise IOError("Won't overwrite existing lextab module")
11
+        basetabmodule = lextab.split('.')[-1]
12
         filename = os.path.join(outputdir, basetabmodule) + '.py'
13
         with open(filename, 'w') as tf:
14
             tf.write('# %s.py. This file automatically created by PLY (version %s). Don\'t edit!\n' % (basetabmodule, __version__))
15
@@ -856,6 +859,10 @@ class LexerReflect(object):
16
 # -----------------------------------------------------------------------------
17
 def lex(module=None, object=None, debug=False, optimize=False, lextab='lextab',
18
         reflags=0, nowarn=False, outputdir=None, debuglog=None, errorlog=None):
19
+
20
+    if lextab is None:
21
+        lextab = 'lextab'
22
+
23
     global lexer
24
 
25
     ldict = None
26
@@ -885,29 +892,13 @@ def lex(module=None, object=None, debug=
27
     else:
28
         ldict = get_caller_module_dict(2)
29
 
30
-    if outputdir is None:
31
-        # If no output directory is set, the location of the output files
32
-        # is determined according to the following rules:
33
-        #     - If lextab specifies a package, files go into that package directory
34
-        #     - Otherwise, files go in the same directory as the specifying module
35
-        if '.' not in lextab:
36
-            srcfile = ldict['__file__']
37
-        else:
38
-            parts = lextab.split('.')
39
-            pkgname = '.'.join(parts[:-1])
40
-            exec('import %s' % pkgname)
41
-            srcfile = getattr(sys.modules[pkgname], '__file__', '')
42
-        outputdir = os.path.dirname(srcfile)
43
-
44
     # Determine if the module is package of a package or not.
45
     # If so, fix the tabmodule setting so that tables load correctly
46
     pkg = ldict.get('__package__')
47
-    if pkg:
48
+    if pkg and isinstance(lextab, str):
49
         if '.' not in lextab:
50
             lextab = pkg + '.' + lextab
51
 
52
-    baselextab = lextab.split('.')[-1]
53
-
54
     # Collect parser information from the dictionary
55
     linfo = LexerReflect(ldict, log=errorlog, reflags=reflags)
56
     linfo.get_all()
57
@@ -1029,8 +1020,24 @@ def lex(module=None, object=None, debug=
58
 
59
     # If in optimize mode, we write the lextab
60
     if lextab and optimize:
61
+        if outputdir is None:
62
+            # If no output directory is set, the location of the output files
63
+            # is determined according to the following rules:
64
+            #     - If lextab specifies a package, files go into that package directory
65
+            #     - Otherwise, files go in the same directory as the specifying module
66
+            if isinstance(lextab, types.ModuleType):
67
+                srcfile = lextab.__file__
68
+            else:
69
+                if '.' not in lextab:
70
+                    srcfile = ldict['__file__']
71
+                else:
72
+                    parts = lextab.split('.')
73
+                    pkgname = '.'.join(parts[:-1])
74
+                    exec('import %s' % pkgname)
75
+                    srcfile = getattr(sys.modules[pkgname], '__file__', '')
76
+            outputdir = os.path.dirname(srcfile)
77
         try:
78
-            lexobj.writetab(baselextab, outputdir)
79
+            lexobj.writetab(lextab, outputdir)
80
         except IOError as e:
81
             errorlog.warning("Couldn't write lextab module %r. %s" % (lextab, e))
82
 
(-)files/patch-ply_yacc.py (-79 lines)
Lines 1-79 Link Here
1
--- ply/yacc.py.orig	2015-04-26 21:19:12 UTC
2
+++ ply/yacc.py
3
@@ -2692,7 +2692,11 @@ class LRGeneratedTable(LRTable):
4
     # This function writes the LR parsing tables to a file
5
     # -----------------------------------------------------------------------------
6
 
7
-    def write_table(self, basemodulename, outputdir='', signature=''):
8
+    def write_table(self, tabmodule, outputdir='', signature=''):
9
+        if isinstance(tabmodule, types.ModuleType):
10
+            raise IOError("Won't overwrite existing tabmodule")
11
+
12
+        basemodulename = tabmodule.split('.')[-1]
13
         filename = os.path.join(outputdir, basemodulename) + '.py'
14
         try:
15
             f = open(filename, 'w')
16
@@ -2705,7 +2709,7 @@ _tabversion = %r
17
 _lr_method = %r
18
 
19
 _lr_signature = %r
20
-    ''' % (filename, __tabversion__, self.lr_method, signature))
21
+    ''' % (os.path.basename(filename), __tabversion__, self.lr_method, signature))
22
 
23
             # Change smaller to 0 to go back to original tables
24
             smaller = 1
25
@@ -3179,6 +3183,9 @@ def yacc(method='LALR', debug=yaccdebug,
26
          check_recursion=True, optimize=False, write_tables=True, debugfile=debug_file,
27
          outputdir=None, debuglog=None, errorlog=None, picklefile=None):
28
 
29
+    if tabmodule is None:
30
+        tabmodule = tab_module
31
+
32
     # Reference to the parsing method of the last built parser
33
     global parse
34
 
35
@@ -3204,22 +3211,26 @@ def yacc(method='LALR', debug=yaccdebug,
36
         # is determined according to the following rules:
37
         #     - If tabmodule specifies a package, files go into that package directory
38
         #     - Otherwise, files go in the same directory as the specifying module
39
-        if '.' not in tabmodule:
40
-            srcfile = pdict['__file__']
41
+        if isinstance(tabmodule, types.ModuleType):
42
+            srcfile = tabmodule.__file__
43
         else:
44
-            parts = tabmodule.split('.')
45
-            pkgname = '.'.join(parts[:-1])
46
-            exec('import %s' % pkgname)
47
-            srcfile = getattr(sys.modules[pkgname], '__file__', '')
48
+            if '.' not in tabmodule:
49
+                srcfile = pdict['__file__']
50
+            else:
51
+                parts = tabmodule.split('.')
52
+                pkgname = '.'.join(parts[:-1])
53
+                exec('import %s' % pkgname)
54
+                srcfile = getattr(sys.modules[pkgname], '__file__', '')
55
         outputdir = os.path.dirname(srcfile)
56
 
57
     # Determine if the module is package of a package or not.
58
     # If so, fix the tabmodule setting so that tables load correctly
59
     pkg = pdict.get('__package__')
60
-    if pkg and '.' not in tabmodule:
61
-        tabmodule = pkg + '.' + tabmodule
62
+    if pkg and isinstance(tabmodule, str):
63
+        if '.' not in tabmodule:
64
+            tabmodule = pkg + '.' + tabmodule
65
+
66
 
67
-    basetabmodule = tabmodule.split('.')[-1]
68
 
69
     # Set start symbol if it's specified directly using an argument
70
     if start is not None:
71
@@ -3432,7 +3443,7 @@ def yacc(method='LALR', debug=yaccdebug,
72
     # Write the table file if requested
73
     if write_tables:
74
         try:
75
-            lr.write_table(basetabmodule, outputdir, signature)
76
+            lr.write_table(tabmodule, outputdir, signature)
77
         except IOError as e:
78
             errorlog.warning("Couldn't create %r. %s" % (tabmodule, e))
79
 
(-)pkg-plist (-27 / +20 lines)
Lines 1-28 Link Here
1
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/ansic/README
1
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/README
2
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/ansic/clex.py
2
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/basic.py
3
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/ansic/cparse.py
4
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/calc/calc.py
5
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/calc/parser.out
6
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/calc/parsetab.py
7
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/calceof/calc.py
8
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/calcdebug/calc.py
9
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/classcalc/calc.py
10
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/classcalc/calc_Calc_parsetab.py
11
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/closurecalc/calc.py
12
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/hedit/hedit.py
13
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/newclasscalc/calc.py
14
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/newclasscalc/calc_Calc_parsetab.py
15
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/optcalc/README
16
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/optcalc/calc.py
17
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/optcalc/lextab.py
18
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/optcalc/parser.out
19
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/optcalc/parsetab.py
20
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/unicalc/calc.py
21
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/yply/README
22
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/yply/ylex.py
23
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/yply/yparse.py
24
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/yply/yply.py
25
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/sqrt2.bas
26
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/basiclex.py
3
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/basiclex.py
27
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/basiclog.py
4
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/basiclog.py
28
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/basinterp.py
5
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/basinterp.py
Lines 36-47 Link Here
36
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/maxsin.bas
13
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/maxsin.bas
37
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/powers.bas
14
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/powers.bas
38
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/rand.bas
15
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/rand.bas
39
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/README
40
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/sales.bas
16
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/sales.bas
41
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/sears.bas
17
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/sears.bas
42
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/sqrt1.bas
18
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/sqrt1.bas
43
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/basic.py
19
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/BASIC/sqrt2.bas
44
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/GardenSnake/GardenSnake.py
20
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/GardenSnake/GardenSnake.py
45
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/GardenSnake/README
21
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/GardenSnake/README
46
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/README
22
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/README
23
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/ansic/README
24
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/ansic/clex.py
25
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/ansic/cparse.py
26
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/calc/calc.py
27
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/calcdebug/calc.py
28
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/calceof/calc.py
29
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/classcalc/calc.py
47
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/cleanup.sh
30
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/cleanup.sh
31
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/closurecalc/calc.py
32
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/hedit/hedit.py
33
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/newclasscalc/calc.py
34
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/optcalc/README
35
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/optcalc/calc.py
36
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/unicalc/calc.py
37
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/yply/README
38
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/yply/ylex.py
39
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/yply/yparse.py
40
%%PORTEXAMPLES%%%%EXAMPLESDIR%%/yply/yply.py

Return to bug 203525