Package: python-defaults
Version: 2.7.3-11
Severity: wishlist
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Dear Maintainer,
Python of course supports -OO which both optimizes and removes
docstrings from the resulting .pyo files. This can provide
significant file size savings. pycompile currently only supports a
single -O flag, but it should support -OO too.
I'll attach a proposed patch.
- -- System Information:
Debian Release: wheezy/sid
APT prefers raring-updates
APT policy: (500, 'raring-updates'), (500, 'raring-security'), (500,
'raring'), (100, 'raring-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 3.8.0-2-generic (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iQIcBAEBCAAGBQJRCvAIAAoJEBJutWOnSwa/XK4P/0XUhlGzlX+R3OQjSAk2FOMH
japFqCR8dRo1irmLja9mfx9LY+UhvYdBLIVEUHxecOoh1OwWLx6D9S8zoN8ZA3bz
f3rb9lNb7086q4Z3viHI6j+6UiJwY5q0T8v9Sck/MymV+9kOZvJKgCIj8PZM7cjA
qJ4Gvw88w17OEc9L/6jxe2nkRQoSIv8R5GveDBlnT+9ZGG4ikUfOEeqZG7fJD7ms
jzgO9oyfVN6DFzq3IiJ9ie9xW+TwGWZtSyxcIIR9Vq7YhlBuuei4yC4QSgBkTK7H
tJyF9cqO4yZf4VXwvUBHcscpTsxHVdrfnfdBCkcosKD42OgUUSTqd5nJ2rYnhHHA
4QTNqarLojp8lF89OwF1yMaSXa/fRBOTf6uq5D7F5coQJBu+HhwHMcaCoOTKfU7V
ELRVshGMtHkxpd8N4plJ+UqyAQnFD7zWVxoy7svHeMwBpqgUEmJu/gY+NM+EPNST
mdt/NTeczuIGBuZtVhg0GVEmAEKaH8VV65YUrMEgFOUOwYOiimfztF1vYydj99F5
g3+7OItalDLSCW9+I74jeozsCJlbVghKge7I1pp46qpLYMuIM3A/f/uGcrP36OtC
nvyYLNCKQw09Kc8YS24whtGA1dcdAzaKtrR4jd4X6g9oTV9ULZnvxKvH+nHaVKq9
KLGUXSnHAx51iioCfYlv
=ybRV
-----END PGP SIGNATURE-----
=== modified file 'pycompile'
--- pycompile 2012-06-30 12:33:33 +0000
+++ pycompile 2013-01-31 22:10:31 +0000
@@ -130,8 +130,14 @@
def py_compile(version, optimize, workers):
if not isinstance(version, basestring):
version = vrepr(version)
- cmd = "/usr/bin/python%s%s -m py_compile -" \
- % (version, ' -O' if optimize else '')
+ if optimize == 0:
+ optflag = ''
+ elif optimize == 1:
+ optflag = ' -O'
+ else:
+ optflag = ' -OO'
+
+ cmd = "/usr/bin/python%s%s -m py_compile -" % (version, optflag)
process = Popen(cmd, bufsize=1, shell=True,
stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
workers[version] = process # keep the reference for .communicate()
@@ -190,8 +196,9 @@
default=False, help='be quiet')
parser.add_option('-f', '--force', action='store_true', dest='force',
default=False, help='force rebuild even if timestamps are up-to-date')
- parser.add_option('-O', action='store_true', dest='optimize',
- default=False, help="byte-compile to .pyo files")
+ parser.add_option('-O', action='count', dest='optimize',
+ default=0,
+ help="byte-compile to .pyo files; -OO to remove doc strings")
parser.add_option('-p', '--package',
help='specify Debian package name whose files should be bytecompiled')
parser.add_option('-V', type='version_range', dest='vrange',
@@ -209,6 +216,9 @@
(options, args) = parser.parse_args()
+ if options.optimize > 2:
+ parser.error('-O or -OO only allowed')
+
if options.verbose or environ.get('PYCOMPILE_DEBUG') == '1':
log.setLevel(logging.DEBUG)
log.debug('argv: %s', sys.argv)