Package: python3-defaults
Version: python3-defaults
Severity: wishlist

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Dear Maintainer,

Similar to bug #699491 - this bug requests support for py3compile -OO to
remove docstrings from the resulting .pyo files.  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)

iQIcBAEBCAAGBQJRCxxzAAoJEBJutWOnSwa/VdsQAIGIT+gbIS9mMFawTjgm0xsZ
NM4LXC2ey9QegKNd6z/txtYwrhWDGfbLFQdO4VhN8YNmw9RbgnmrafdIC6SR4c1j
Lsgu0HkRi96TZsg/uWKTwnNpaKtp76PL8WQAHuF1gqT8/O6UELGNuth24xKLKHUB
kwT271HWoVWrucUuDEnbiKx3BIIBFDPwSN0Z1A4tMsl1YA/vd7piN7QWsjRji2od
9KpZMeEUdQHaY1mq9WttB3IaVNoa2/E1qOHsxsFXupJOg2jH4rypsnPTlhSeVWId
Aqk6Aq0Lpv/tBZWjMyMi54vor0XnaL+QAGE7VutXIBLQmLbWva6GFT1dNceH2yqS
azz6P8RlBvTaRp2M9h/Smr9ammNC7HYC8dzz2+1JkgKuHs+4FcM9YlB1mYEjxaAz
ek/ovUe8dJLY1Zb67F4m5gRJW8stY1bHVlmlWHiwE8+lmB9dcosgRYZzP6PaJppN
5pYcF+6XFW2hE6K8JanI32Pcq5Ul0bSOsELyFg+PTU5WIRn+19rrMbUNhyLK7C8c
Z/88dOPXzvYgi7DAgxvIDdK12x9QkSFPOCY/HRzulrTYrolgspkiHtm/ed4WPbAP
QtsOt5RNk9qj3on6yWCenjU3JzwCjDqwMQ3xYCvwB5xkpP2ZSgx6xBifKao/R/zm
Px/dVOJAoNy4F6JpmskR
=vb6v
-----END PGP SIGNATURE-----
=== modified file 'py3compile'
--- py3compile	2012-12-06 21:59:07 +0000
+++ py3compile	2013-02-01 01:10:49 +0000
@@ -129,8 +129,13 @@
 def py_compile(version, optimize, workers):
     if not isinstance(version, str):
         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, close_fds=True)
     workers[version] = process  # keep the reference for .communicate()
@@ -149,7 +154,14 @@
             next(coroutine)
             STDINS[version] = coroutine
 
-    interpreter = Interpreter('python' if not optimize else 'python -O')
+    interpreter = 'python'
+    if optimize == 0:
+        pass
+    if optimize == 1:
+        interpreter += ' -O'
+    else:
+        interpreter += ' -OO'
+    interpreter = Interpreter(interpreter)
 
     # byte compile files
     skip_dirs = set()
@@ -202,8 +214,9 @@
     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',
@@ -221,6 +234,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)

=== modified file 'py3compile.rst'
--- py3compile.rst	2012-10-24 21:57:35 +0000
+++ py3compile.rst	2013-02-01 00:58:56 +0000
@@ -10,7 +10,7 @@
 ========
   py3compile [-V [X.Y][-][A.B]] DIR_OR_FILE [-X REGEXPR]
 
-  pycompile -p PACKAGE
+  py3compile -p PACKAGE
 
 DESCRIPTION
 ===========
@@ -27,6 +27,8 @@
 
 -O		byte-compile to .pyo files
 
+-OO		byte-compile to .pyo files and remove doc strings
+
 -q, --quiet	be quiet
 
 -v, --verbose	turn verbose mode on

Reply via email to