[arch-commits] Commit in python-ply/trunk (PKGBUILD python-3.5.patch)
Felix Yan
fyan at archlinux.org
Sat Sep 19 10:33:07 UTC 2015
Date: Saturday, September 19, 2015 @ 12:33:06
Author: fyan
Revision: 246598
upgpkg: python-ply 3.7-2
rebuild for python 3.5
Added:
python-ply/trunk/python-3.5.patch
Modified:
python-ply/trunk/PKGBUILD
------------------+
PKGBUILD | 19 ++--
python-3.5.patch | 216 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 228 insertions(+), 7 deletions(-)
Modified: PKGBUILD
===================================================================
--- PKGBUILD 2015-09-19 10:29:09 UTC (rev 246597)
+++ PKGBUILD 2015-09-19 10:33:06 UTC (rev 246598)
@@ -14,20 +14,25 @@
license=('BSD')
makedepends=('python-setuptools' 'python2-setuptools')
source=("${url}ply-$pkgver.tar.gz"
- LICENSE)
+ LICENSE
+ python-3.5.patch)
sha256sums=('f85fb7b44c1c9a04873e6d76fa2c2eef43f2cfd81468aa714a9c63af7ae0af80'
- '87c20dd0a774f4d4ff837b4f1555f7eb1ed1b8dc1e3223cd105e5c1e282d62bf')
+ '87c20dd0a774f4d4ff837b4f1555f7eb1ed1b8dc1e3223cd105e5c1e282d62bf'
+ 'b7969d290e659d9756a2b0ad3b19481a4b32e1ec79590db1c7ab64bcc6519029')
prepare() {
- cp -a ${pkgbase#python-}-$pkgver{,-py2}
+ # https://github.com/dabeaz/ply/pull/78
+ (cd ply-$pkgver; patch -p1 -i ../python-3.5.patch)
+
+ cp -a ply-$pkgver{,-py2}
}
check() {
- cd "${pkgbase#python-}-$pkgver/test"
+ cd "ply-$pkgver/test"
python testlex.py
python testyacc.py
- cd "$srcdir/${pkgbase#python-}-$pkgver-py2/test"
+ cd "$srcdir/ply-$pkgver-py2/test"
python2 testlex.py
python2 testyacc.py
}
@@ -35,7 +40,7 @@
package_python-ply() {
depends=('python')
- cd "${pkgbase#python-}-$pkgver"
+ cd "ply-$pkgver"
python setup.py install --root="$pkgdir"
install -Dm644 ../LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
@@ -44,7 +49,7 @@
package_python2-ply() {
depends=('python2')
- cd "${pkgbase#python-}-$pkgver-py2"
+ cd "ply-$pkgver-py2"
python2 setup.py install --root="$pkgdir"
install -Dm644 ../LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
Added: python-3.5.patch
===================================================================
--- python-3.5.patch (rev 0)
+++ python-3.5.patch 2015-09-19 10:33:06 UTC (rev 246598)
@@ -0,0 +1,216 @@
+From 1186219ceece79c1faa55a8dce31cfb235ccfb13 Mon Sep 17 00:00:00 2001
+From: Barry Warsaw <barry at python.org>
+Date: Mon, 14 Sep 2015 15:38:42 -0400
+Subject: [PATCH] Fixes for Python 3.5 compatibility.
+
+---
+ test/testlex.py | 77 +++++++++++++++++++++++++++++++++++----------------------
+ 1 file changed, 47 insertions(+), 30 deletions(-)
+
+diff --git a/test/testlex.py b/test/testlex.py
+index fd5002e..3880f6f 100755
+--- a/test/testlex.py
++++ b/test/testlex.py
+@@ -16,14 +16,22 @@
+
+ import ply.lex
+
+-def make_pymodule_path(filename):
++try:
++ from importlib.util import cache_from_source
++except ImportError:
++ # Python 2.7, but we don't care.
++ cache_from_source = None
++
++
++def make_pymodule_path(filename, optimization=None):
+ path = os.path.dirname(filename)
+ file = os.path.basename(filename)
+ mod, ext = os.path.splitext(file)
+
+- if sys.hexversion >= 0x3040000:
+- import importlib.util
+- fullpath = importlib.util.cache_from_source(filename, ext=='.pyc')
++ if sys.hexversion >= 0x3050000:
++ fullpath = cache_from_source(filename, optimization=optimization)
++ elif sys.hexversion >= 0x3040000:
++ fullpath = cache_from_source(filename, ext=='.pyc')
+ elif sys.hexversion >= 0x3020000:
+ import imp
+ modname = mod+"."+imp.get_tag()+ext
+@@ -32,11 +40,12 @@ def make_pymodule_path(filename):
+ fullpath = filename
+ return fullpath
+
+-def pymodule_out_exists(filename):
+- return os.path.exists(make_pymodule_path(filename))
++def pymodule_out_exists(filename, optimization=None):
++ return os.path.exists(make_pymodule_path(filename,
++ optimization=optimization))
+
+-def pymodule_out_remove(filename):
+- os.remove(make_pymodule_path(filename))
++def pymodule_out_remove(filename, optimization=None):
++ os.remove(make_pymodule_path(filename, optimization=optimization))
+
+ def implementation():
+ if platform.system().startswith("Java"):
+@@ -156,8 +165,12 @@ def test_lex_ignore2(self):
+ def test_lex_re1(self):
+ self.assertRaises(SyntaxError,run_import,"lex_re1")
+ result = sys.stderr.getvalue()
++ if sys.hexversion < 0x3050000:
++ msg = "Invalid regular expression for rule 't_NUMBER'. unbalanced parenthesis\n"
++ else:
++ msg = "Invalid regular expression for rule 't_NUMBER'. missing ), unterminated subpattern at position 0"
+ self.assert_(check_expected(result,
+- "Invalid regular expression for rule 't_NUMBER'. unbalanced parenthesis\n",
++ msg,
+ contains=True))
+
+ def test_lex_re2(self):
+@@ -173,10 +186,15 @@ def test_lex_re3(self):
+ # "Invalid regular expression for rule 't_POUND'. unbalanced parenthesis\n"
+ # "Make sure '#' in rule 't_POUND' is escaped with '\\#'\n"))
+
++ if sys.hexversion < 0x3050000:
++ msg = ("Invalid regular expression for rule 't_POUND'. unbalanced parenthesis\n"
++ "Make sure '#' in rule 't_POUND' is escaped with '\\#'\n")
++ else:
++ msg = ("Invalid regular expression for rule 't_POUND'. missing ), unterminated subpattern at position 0\n"
++ "ERROR: Make sure '#' in rule 't_POUND' is escaped with '\#'")
+ self.assert_(check_expected(result,
+- "Invalid regular expression for rule 't_POUND'. unbalanced parenthesis\n"
+- "Make sure '#' in rule 't_POUND' is escaped with '\\#'\n",
+- contains=True))
++ msg,
++ contains=True), result)
+
+ def test_lex_rule1(self):
+ self.assertRaises(SyntaxError,run_import,"lex_rule1")
+@@ -365,7 +383,6 @@ def test_lex_optimize(self):
+ "(NUMBER,4,1,2)\n"))
+ self.assert_(os.path.exists("lextab.py"))
+
+-
+ p = subprocess.Popen([sys.executable,'-O','lex_optimize.py'],
+ stdout=subprocess.PIPE)
+ result = p.stdout.read()
+@@ -375,8 +392,8 @@ def test_lex_optimize(self):
+ "(PLUS,'+',1,1)\n"
+ "(NUMBER,4,1,2)\n"))
+ if test_pyo:
+- self.assert_(pymodule_out_exists("lextab.pyo"))
+- pymodule_out_remove("lextab.pyo")
++ self.assert_(pymodule_out_exists("lextab.pyo", 1))
++ pymodule_out_remove("lextab.pyo", 1)
+
+ p = subprocess.Popen([sys.executable,'-OO','lex_optimize.py'],
+ stdout=subprocess.PIPE)
+@@ -387,7 +404,7 @@ def test_lex_optimize(self):
+ "(NUMBER,4,1,2)\n"))
+
+ if test_pyo:
+- self.assert_(pymodule_out_exists("lextab.pyo"))
++ self.assert_(pymodule_out_exists("lextab.pyo", 2))
+ try:
+ os.remove("lextab.py")
+ except OSError:
+@@ -397,7 +414,7 @@ def test_lex_optimize(self):
+ except OSError:
+ pass
+ try:
+- pymodule_out_remove("lextab.pyo")
++ pymodule_out_remove("lextab.pyo", 2)
+ except OSError:
+ pass
+
+@@ -430,8 +447,8 @@ def test_lex_optimize2(self):
+ "(PLUS,'+',1,1)\n"
+ "(NUMBER,4,1,2)\n"))
+ if test_pyo:
+- self.assert_(pymodule_out_exists("opt2tab.pyo"))
+- pymodule_out_remove("opt2tab.pyo")
++ self.assert_(pymodule_out_exists("opt2tab.pyo", 1))
++ pymodule_out_remove("opt2tab.pyo", 1)
+ p = subprocess.Popen([sys.executable,'-OO','lex_optimize2.py'],
+ stdout=subprocess.PIPE)
+ result = p.stdout.read()
+@@ -440,7 +457,7 @@ def test_lex_optimize2(self):
+ "(PLUS,'+',1,1)\n"
+ "(NUMBER,4,1,2)\n"))
+ if test_pyo:
+- self.assert_(pymodule_out_exists("opt2tab.pyo"))
++ self.assert_(pymodule_out_exists("opt2tab.pyo", 2))
+ try:
+ os.remove("opt2tab.py")
+ except OSError:
+@@ -450,7 +467,7 @@ def test_lex_optimize2(self):
+ except OSError:
+ pass
+ try:
+- pymodule_out_remove("opt2tab.pyo")
++ pymodule_out_remove("opt2tab.pyo", 2)
+ except OSError:
+ pass
+
+@@ -480,8 +497,8 @@ def test_lex_optimize3(self):
+ "(PLUS,'+',1,1)\n"
+ "(NUMBER,4,1,2)\n"))
+ if test_pyo:
+- self.assert_(pymodule_out_exists("lexdir/sub/calctab.pyo"))
+- pymodule_out_remove("lexdir/sub/calctab.pyo")
++ self.assert_(pymodule_out_exists("lexdir/sub/calctab.pyo", 1))
++ pymodule_out_remove("lexdir/sub/calctab.pyo", 1)
+
+ p = subprocess.Popen([sys.executable,'-OO','lex_optimize3.py'],
+ stdout=subprocess.PIPE)
+@@ -491,7 +508,7 @@ def test_lex_optimize3(self):
+ "(PLUS,'+',1,1)\n"
+ "(NUMBER,4,1,2)\n"))
+ if test_pyo:
+- self.assert_(pymodule_out_exists("lexdir/sub/calctab.pyo"))
++ self.assert_(pymodule_out_exists("lexdir/sub/calctab.pyo", 2))
+ try:
+ shutil.rmtree("lexdir")
+ except OSError:
+@@ -526,8 +543,8 @@ def test_lex_opt_alias(self):
+ "(+,'+',1,1)\n"
+ "(NUMBER,4,1,2)\n"))
+ if test_pyo:
+- self.assert_(pymodule_out_exists("aliastab.pyo"))
+- pymodule_out_remove("aliastab.pyo")
++ self.assert_(pymodule_out_exists("aliastab.pyo", 1))
++ pymodule_out_remove("aliastab.pyo", 1)
+
+ p = subprocess.Popen([sys.executable,'-OO','lex_opt_alias.py'],
+ stdout=subprocess.PIPE)
+@@ -538,7 +555,7 @@ def test_lex_opt_alias(self):
+ "(NUMBER,4,1,2)\n"))
+
+ if test_pyo:
+- self.assert_(pymodule_out_exists("aliastab.pyo"))
++ self.assert_(pymodule_out_exists("aliastab.pyo", 2))
+ try:
+ os.remove("aliastab.py")
+ except OSError:
+@@ -548,7 +565,7 @@ def test_lex_opt_alias(self):
+ except OSError:
+ pass
+ try:
+- pymodule_out_remove("aliastab.pyo")
++ pymodule_out_remove("aliastab.pyo", 2)
+ except OSError:
+ pass
+
+@@ -593,8 +610,8 @@ def test_lex_many_tokens(self):
+ "(TOK999,'TOK999:',1,47)\n"
+ ))
+
+- self.assert_(pymodule_out_exists("manytab.pyo"))
+- pymodule_out_remove("manytab.pyo")
++ self.assert_(pymodule_out_exists("manytab.pyo", 1))
++ pymodule_out_remove("manytab.pyo", 1)
+ try:
+ os.remove("manytab.py")
+ except OSError:
More information about the arch-commits
mailing list