[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#681434: unblock: python3-defaults/3.2.3-4



Package: release.debian.org
Severity: normal
User: release.debian.org@packages.debian.org
Usertags: unblock

Please unblock package python3-defaults

Gets RC bug #681235 properly fixed, as the fix I uploaded in 3.2.3-2 missed a
few corner cases.  Additionally fixes RC bug #681389.  

Debdiff attached.

unblock python3-defaults/3.2.3-4
diff -Nru python3-defaults-3.2.3/debian/changelog python3-defaults-3.2.3/debian/changelog
--- python3-defaults-3.2.3/debian/changelog	2012-06-30 11:10:00.000000000 -0400
+++ python3-defaults-3.2.3/debian/changelog	2012-07-13 01:51:55.000000000 -0400
@@ -1,3 +1,30 @@
+python3-defaults (3.2.3-4) unstable; urgency=high
+
+  * py3clean: really close #681389
+
+ -- Piotr Ożarowski <piotr@debian.org>  Thu, 12 Jul 2012 22:45:47 -0600
+
+python3-defaults (3.2.3-3) unstable; urgency=high
+
+  * Yet another update in SHEBANG_RE to handle even more cases
+  * test4 fixed to catch missing /usr/bin/python → /usr/bin/python3 rewrites
+  * py3clean: accept --package *and* directory name at the same time
+    (change missed in -1 upload, closes: #681389)
+  * Bump minimum required python3 version to 3.2.3-3~ in packages with .py files
+    (due to --package option that is added to py3compile/py3clean in rtupdate
+    scripts)
+
+ -- Piotr Ożarowski <piotr@debian.org>  Thu, 12 Jul 2012 12:40:42 -0600
+
+python3-defaults (3.2.3-2) unstable; urgency=high
+
+  * Urgency high for grave bug because this will cause other packages to
+    misbuild
+  * Correct SHEBANG_RE in debpython/tools.py to not capture the 3 from python3
+    (Closes: #681235)
+
+ -- Scott Kitterman <scott@kitterman.com>  Wed, 11 Jul 2012 11:51:46 -0400
+
 python3-defaults (3.2.3-1) unstable; urgency=low
 
   * Bump upstream version to match current unstable/wheezy python3.2 version
diff -Nru python3-defaults-3.2.3/debian/python3.prerm python3-defaults-3.2.3/debian/python3.prerm
--- python3-defaults-3.2.3/debian/python3.prerm	2012-01-09 16:44:09.000000000 -0500
+++ python3-defaults-3.2.3/debian/python3.prerm	2012-07-12 19:40:37.000000000 -0400
@@ -1,4 +1,5 @@
-#! /bin/sh -e
+#! /bin/sh
+set -e
 
 if which py3clean >/dev/null 2>&1; then
 	py3clean -p python3
diff -Nru python3-defaults-3.2.3/debpython/depends.py python3-defaults-3.2.3/debpython/depends.py
--- python3-defaults-3.2.3/debpython/depends.py	2012-06-30 15:10:02.000000000 -0400
+++ python3-defaults-3.2.3/debpython/depends.py	2012-07-12 18:41:16.000000000 -0400
@@ -23,7 +23,7 @@
 from debpython.version import DEFAULT, SUPPORTED, getver, vrepr, vrange_str
 
 # minimum version required for py3compile/py3clean:
-MINPYCDEP = 'python3 (>= 3.1.3-13~)'
+MINPYCDEP = 'python3 (>= 3.2.3-3~)'
 
 log = logging.getLogger(__name__)
 
diff -Nru python3-defaults-3.2.3/debpython/files.py python3-defaults-3.2.3/debpython/files.py
--- python3-defaults-3.2.3/debpython/files.py	1969-12-31 19:00:00.000000000 -0500
+++ python3-defaults-3.2.3/debpython/files.py	2012-07-12 18:49:51.000000000 -0400
@@ -0,0 +1,84 @@
+# Copyright © 2012 Piotr Ożarowski <piotr@debian.org>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+import logging
+from os import walk
+from os.path import abspath, isfile, join
+from subprocess import Popen, PIPE
+from debpython.pydist import PUBLIC_DIR_RE
+
+log = logging.getLogger(__name__)
+
+
+def from_directory(dname, extensions=('.py',)):
+    """Generate *.py file names available in given directory."""
+    extensions = tuple(extensions)  # .endswith doesn't like list
+    if isinstance(dname, (list, tuple)):
+        for item in dname:
+            for fn in from_directory(item):
+                yield fn
+    elif isfile(dname) and dname.endswith(extensions):
+        yield dname
+    else:
+        for root, dirs, file_names in walk(abspath(dname)):
+            for fn in file_names:
+                if fn.endswith(extensions):
+                    yield join(root, fn)
+
+
+def from_package(package_name, extensions=('.py',)):
+    """Generate *.py file names available in given package."""
+    extensions = tuple(extensions)  # .endswith doesn't like list
+    process = Popen("/usr/bin/dpkg -L %s" % package_name,\
+                    shell=True, stdout=PIPE)
+    stdout, stderr = process.communicate()
+    if process.returncode != 0:
+        raise Exception("cannot get content of %s" % package_name)
+    stdout = str(stdout, 'utf-8')
+    for line in stdout.splitlines():
+        if line.endswith(extensions):
+            yield line
+
+
+def filter_directory(files, dname):
+    """Generate *.py file names that match given directory."""
+    for fn in files:
+        if fn.startswith(dname):
+            yield fn
+
+
+def filter_public(files, versions):
+    """Generate *.py file names that match given versions."""
+    vstr = set("%d.%d" % i for i in versions)
+    shared_vstr = set(str(i[0]) for i in versions)
+    for fn in files:
+        public_dir = PUBLIC_DIR_RE.match(fn)
+        if public_dir:
+            vers = public_dir.group(1)
+            if vers in shared_vstr or vers in vstr:
+                yield fn
+
+
+def filter_out_ext(files, extensions):
+    """Removes files with matching extensions from given generator."""
+    extensions = tuple(extensions)  # .endswith doesn't like list
+    for fn in files:
+        if not fn.endswith(extensions):
+            yield fn
diff -Nru python3-defaults-3.2.3/debpython/tools.py python3-defaults-3.2.3/debpython/tools.py
--- python3-defaults-3.2.3/debpython/tools.py	2012-06-30 14:52:30.000000000 -0400
+++ python3-defaults-3.2.3/debpython/tools.py	2012-07-12 15:01:32.000000000 -0400
@@ -29,7 +29,7 @@
 
 log = logging.getLogger(__name__)
 EGGnPTH_RE = re.compile(r'(.*?)(-py\d\.\d(?:-[^.]*)?)?(\.egg-info|\.pth)$')
-SHEBANG_RE = re.compile(r'^#!\s*(.*?/bin/.*?)(python(\d+\.\d+)?(?:-dbg)?)(?:\s(.*))?')
+SHEBANG_RE = re.compile(r'^#!\s*(.*?/bin/.*?)(python(?:(\d+\.\d+)|3)?(?:-dbg)?)(?:\s(.*))?')
 
 
 
@@ -112,6 +112,8 @@
         return None
     if not replacement:
         path, interpreter, version, argv = match.groups()
+        if interpreter == 'python':
+            interpreter = 'python3'
         if path != '/usr/bin':  # f.e. /usr/local/* or */bin/env
             replacement = "/usr/bin/%s" % interpreter
         if replacement and argv:
diff -Nru python3-defaults-3.2.3/py3clean python3-defaults-3.2.3/py3clean
--- python3-defaults-3.2.3/py3clean	2012-06-30 15:14:19.000000000 -0400
+++ python3-defaults-3.2.3/py3clean	2012-07-13 00:57:26.000000000 -0400
@@ -1,7 +1,7 @@
 #! /usr/bin/python3
 # vim: et ts=4 sw=4
 
-# Copyright © 2010 Piotr Ożarowski <piotr@debian.org>
+# Copyright © 2010-2012 Piotr Ożarowski <piotr@debian.org>
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
@@ -25,10 +25,10 @@
 import optparse
 import sys
 from glob import glob1
-from os import environ, remove, rmdir, walk
-from os.path import dirname, exists, isdir, isfile, join
-from subprocess import Popen, PIPE
+from os import environ, remove, rmdir
+from os.path import dirname, exists, join
 sys.path.insert(1, '/usr/share/python3/')
+from debpython import files as dpf
 from debpython.version import SUPPORTED, getver, vrepr
 from debpython.tools import get_magic_tags_map
 
@@ -127,35 +127,9 @@
         log.info("removed files: %s", counter)
 
 
-def get_files(items):
-    for item in items:
-        if isfile(item) and item.endswith('.py'):
-            yield item
-        elif isdir(item):
-            for root, dirs, files in walk(item):
-                #for fn in glob1(root, '*.py'):
-                #    yield join(root, fn)
-                for fn in files:
-                    if fn.endswith('.py'):
-                        yield join(root, fn)
-
-
-def get_package_files(package_name):
-    process = Popen("/usr/bin/dpkg -L %s" % package_name,\
-                    shell=True, stdout=PIPE)
-    stdout, stderr = process.communicate()
-    if process.returncode != 0:
-        log.error('cannot get content of %s', package_name)
-        exit(2)
-    stdout = str(stdout, 'utf-8')
-    for line in stdout.split('\n'):
-        if line.endswith('.py'):
-            yield line
-
-
 def main():
-    usage = '%prog [-V VERSION] [-p PACKAGE | DIR_OR_FILE]'
-    parser = optparse.OptionParser(usage, version='%prog 0.3')
+    usage = '%prog [-V VERSION] [-p PACKAGE] [DIR_OR_FILE]'
+    parser = optparse.OptionParser(usage, version='%prog 1.0')
     parser.add_option('-v', '--verbose', action='store_true', dest='verbose',
         help='turn verbose more one')
     parser.add_option('-q', '--quiet', action='store_false', dest='verbose',
@@ -185,21 +159,24 @@
         d = destroyer()  # remove everything
     next(d)  # initialize coroutine
 
-    if options.package and args:
-        parser.error('only one action is allowed at the same time ('
-                     'cleaning directory or a package)')
+    if not options.package and not args:
+        parser.print_usage()
+        exit(1)
 
     if options.package:
         log.info('cleaning package %s', options.package)
-        for filename in get_package_files(options.package):
-            d.send(filename)
-    elif args:
+        pfiles = set(dpf.from_package(options.package))
+
+    if args:
         log.info('cleaning directories: %s', args)
-        for filename in get_files(args):
-            d.send(filename)
+        files = set(dpf.from_directory(args))
+        if options.package:
+            files = files & pfiles
     else:
-        parser.print_usage()
-        exit(1)
+        files = pfiles
+
+    for filename in files:
+        d.send(filename)
 
 if __name__ == '__main__':
     main()
diff -Nru python3-defaults-3.2.3/py3compile python3-defaults-3.2.3/py3compile
--- python3-defaults-3.2.3/py3compile	2012-06-30 11:28:16.000000000 -0400
+++ python3-defaults-3.2.3/py3compile	2012-07-12 18:56:39.000000000 -0400
@@ -27,12 +27,13 @@
 import os
 import struct
 import sys
-from os import environ, listdir, mkdir, walk
-from os.path import abspath, dirname, exists, isdir, isfile, join
+from os import environ, listdir, mkdir
+from os.path import dirname, exists, isdir, join
 from subprocess import PIPE, Popen
 sys.path.insert(1, '/usr/share/python3/')
 from debpython.version import SUPPORTED, debsorted, vrepr, \
         get_requested_versions, parse_vrange, getver
+from debpython import files as dpf
 from debpython.option import Option, compile_regexpr
 from debpython.pydist import PUBLIC_DIR_RE
 from debpython.tools import cache_from_source, get_magic_numbers_map, memoize
@@ -54,54 +55,6 @@
 """
 
 
-### FILES ######################################################
-def get_directory_files(dname):
-    """Generate *.py file names available in given directory."""
-    if isfile(dname) and dname.endswith('.py'):
-        yield dname
-    else:
-        for root, dirs, file_names in walk(abspath(dname)):
-            #if root != dname and not exists(join(root, '__init__.py')):
-            #    del dirs[:]
-            #    continue
-            for fn in file_names:
-                if fn.endswith('.py'):
-                    yield join(root, fn)
-
-
-def get_package_files(package_name):
-    """Generate *.py file names available in given package."""
-    process = Popen("/usr/bin/dpkg -L %s" % package_name,\
-                    shell=True, stdout=PIPE)
-    stdout, stderr = process.communicate()
-    if process.returncode != 0:
-        log.error('cannot get content of %s', package_name)
-        exit(2)
-    stdout = str(stdout, 'utf-8')
-    for line in stdout.split('\n'):
-        if line.endswith('.py'):
-            yield line
-
-
-def get_private_files(files, dname):
-    """Generate *.py file names that match given directory."""
-    for fn in files:
-        if fn.startswith(dname):
-            yield fn
-
-
-def get_public_files(files, versions):
-    """Generate *.py file names that match given versions."""
-    vstr = set("%d.%d" % i for i in versions)
-    shared_vstr = set(str(i[0]) for i in versions)
-    for fn in files:
-        public_dir = PUBLIC_DIR_RE.match(fn)
-        if public_dir:
-            vers = public_dir.group(1)
-            if vers in shared_vstr or vers in vstr:
-                yield fn
-
-
 ### EXCLUDES ###################################################
 @memoize
 def get_exclude_patterns_from_dir(name='/usr/share/python3/bcep/'):
@@ -294,7 +247,7 @@
         compile_versions = debsorted(versions)[:1]
         log.debug('compile versions: %s', versions)
 
-        pkg_files = tuple(get_package_files(options.package))
+        pkg_files = tuple(dpf.from_package(options.package))
         for item in args:
             e_patterns = get_exclude_patterns(item, options.regexpr, \
                                               compile_versions)
@@ -303,21 +256,21 @@
             else:
                 log.debug('byte compiling %s using Python %s',
                           item, compile_versions)
-                files = get_private_files(pkg_files, item)
+                files = dpf.filter_directory(pkg_files, item)
                 compile(files, compile_versions, options.force,
                         options.optimize, e_patterns)
     elif options.package:  # package's public modules
         # no need to limit versions here, it's either pyr mode or version is
         # hardcoded in path / via -V option
         e_patterns = get_exclude_patterns()
-        files = get_package_files(options.package)
-        files = get_public_files(files, versions)
+        files = dpf.from_package(options.package)
+        files = dpf.filter_public(files, versions)
         compile(files, versions,
                 options.force, options.optimize, e_patterns)
-    elif args:  # other directories/files (private ones mostly)
+    elif args:  # other directories/files
         for item in args:
             e_patterns = get_exclude_patterns(item, options.regexpr, versions)
-            files = get_directory_files(item)
+            files = dpf.from_directory(item)
             compile(files, versions,
                     options.force, options.optimize, e_patterns)
     else:
@@ -330,7 +283,7 @@
         process.communicate()
         if process.returncode not in (None, 0):
             rv = process.returncode
-    sys.exit(rv)
+    exit(rv)
 
 if __name__ == '__main__':
     main()
diff -Nru python3-defaults-3.2.3/tests/t4/Makefile python3-defaults-3.2.3/tests/t4/Makefile
--- python3-defaults-3.2.3/tests/t4/Makefile	2012-06-30 15:11:02.000000000 -0400
+++ python3-defaults-3.2.3/tests/t4/Makefile	2012-07-12 13:39:32.000000000 -0400
@@ -9,7 +9,7 @@
 	# python3.3 hardcoded via shebang
 	grep -q '/usr/share/foo \-V 3.3' debian/foo/DEBIAN/postinst
 	# /env removed from shebang 
-	grep -q '#! /usr/bin/python' debian/foo/usr/share/bar/bar.py
+	grep -q '#! /usr/bin/python3' debian/foo/usr/share/bar/bar.py
 	# /local removed from shebang 
-	grep -q '#! /usr/bin/python' debian/foo/usr/share/foo/baz.py
+	grep -q '#! /usr/bin/python3' debian/foo/usr/share/foo/baz.py
 	grep -q '#! /usr/bin/python3.3' debian/foo/usr/share/foo/foo.py

Reply to: