From 3a332fb886f19c9c72cfb064422b09b7a67089dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20O=C5=BCarowski?= <piotr@debian.org> Date: Sun, 12 Dec 2010 20:43:04 +0100 Subject: [PATCH] remove --lazy (option and feature), fix -O --- debian/changelog | 2 +- pycompile | 22 +++++++--------------- pycompile.1 | 4 ---- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/debian/changelog b/debian/changelog index 335ebf4..3f90174 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,7 +4,7 @@ python-defaults (2.6.6-7) experimental; urgency=high - Don't over-optimize, check the timestamps of byte-code files. - Use the correct name for byte-code files. - Use the correct python interpreter when called with -O. - - Add options -f/--force, -l/--lazy, -O. + - Add options -f/--force, -O. - Copy stdout/stderr of py_compile processes in case of error. - Propagate the exit value of the py_compile processes. - Update manual page. diff --git a/pycompile b/pycompile index bcf2a9c..544a979 100755 --- a/pycompile +++ b/pycompile @@ -170,7 +170,7 @@ def py_compile(version, optimize, workers): if not isinstance(version, basestring): version = vrepr(version) cmd = "python%s%s -m py_compile -" \ - % (version, (__debug__ or optimize) and '' or ' -O') + % (version, '' if (__debug__ or not optimize) else ' -O') process = Popen(cmd, bufsize=1, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True) workers[version] = process # keep the reference for .communicate() @@ -180,7 +180,7 @@ def py_compile(version, optimize, workers): stdin.write(filename + '\n') -def compile(files, versions, force, lazy, optimize, e_patterns=None): +def compile(files, versions, force, optimize, e_patterns=None): global STDINS, WORKERS # start Python interpreters that will handle byte compilation for version in versions: @@ -191,10 +191,8 @@ def compile(files, versions, force, lazy, optimize, e_patterns=None): # byte compile files for fn, versions_to_compile in filter_files(files, e_patterns, versions): - cfn = fn + ((__debug__ or optimize) and 'c' or 'o') - if lazy and exists(cfn): - continue - if not force: + cfn = fn + 'c' if (__debug__ or not optimize) else 'o' + if exists(cfn) and not force: ftime = os.stat(fn).st_mtime try: ctime = os.stat(cfn).st_mtime @@ -225,8 +223,6 @@ def main(): 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('-l', '--lazy', action='store_true', dest='lazy', - default=False, help="don' t check if byte-code files are up-to-date") parser.add_option('-O', action='store_true', dest='optimize', default=False, help="byte-compile to .pyo files") parser.add_option('-p', '--package', @@ -254,10 +250,6 @@ multiple times to build up a list of things to exclude.') else: log.setLevel(logging.WARN) - if options.force and options.lazy: - options.lazy = False - log.warn('--force is in effect, ignore --lazy') - if options.regexpr and not args: parser.error('--exclude option works with private directories ' 'only, please use /usr/share/python/bcep to specify ' @@ -289,7 +281,7 @@ multiple times to build up a list of things to exclude.') log.debug('byte compiling %s using Python %s', item, compile_versions) files = get_private_files(pkg_files, item) - compile(files, compile_versions, options.force, options.lazy, + 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 @@ -298,14 +290,14 @@ multiple times to build up a list of things to exclude.') files = get_package_files(options.package) files = get_public_files(files, versions) compile(files, versions, - options.force, options.lazy, options.optimize, e_patterns) + options.force, options.optimize, e_patterns) elif args: # other directories/files (public ones mostly) versions = debsorted(versions)[:1] for item in args: e_patterns = get_exclude_patterns(item, options.regexpr, versions) files = get_directory_files(item) compile(files, versions, - options.force, options.lazy, options.optimize, e_patterns) + options.force, options.optimize, e_patterns) else: parser.print_usage() exit(1) diff --git a/pycompile.1 b/pycompile.1 index 57af9db..16812bf 100644 --- a/pycompile.1 +++ b/pycompile.1 @@ -22,10 +22,6 @@ Show this help message and exit \fB\-f\fR, \fB\-\-force\fR Force rebuild of byte-code files even if timestamps are up-to-date. .TP -\fB\-l\fR, \fB\-\-lazy\fR -Do not rebuild byte-code files even if timestamps are out-of-date (ignored when -\fB\-\-force\fR is in effect). -.TP \fB\-O\fR Byte-compile to .pyo files. .TP -- GitLab