Bundled compileall2 module update to 0.6.0
This commit is contained in:
parent
af35bb0ac9
commit
bebf85d28b
@ -9,6 +9,10 @@ recursing into subdirectories. (Even though it should do so for
|
|||||||
packages -- for now, you'll have to deal with packages separately.)
|
packages -- for now, you'll have to deal with packages separately.)
|
||||||
|
|
||||||
See module py_compile for details of the actual byte-compilation.
|
See module py_compile for details of the actual byte-compilation.
|
||||||
|
|
||||||
|
License:
|
||||||
|
Compileall2 is an enhanced copy of Python's compileall module
|
||||||
|
and it follows Python licensing. For more info see: https://www.python.org/psf/license/
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -39,8 +43,6 @@ else:
|
|||||||
pyc_header_lenght = 8
|
pyc_header_lenght = 8
|
||||||
pyc_header_format = (pyc_struct_format, importlib.util.MAGIC_NUMBER)
|
pyc_header_format = (pyc_struct_format, importlib.util.MAGIC_NUMBER)
|
||||||
|
|
||||||
RECURSION_LIMIT = sys.getrecursionlimit()
|
|
||||||
|
|
||||||
__all__ = ["compile_dir","compile_file","compile_path"]
|
__all__ = ["compile_dir","compile_file","compile_path"]
|
||||||
|
|
||||||
def optimization_kwarg(opt):
|
def optimization_kwarg(opt):
|
||||||
@ -56,7 +58,7 @@ def optimization_kwarg(opt):
|
|||||||
else:
|
else:
|
||||||
return dict()
|
return dict()
|
||||||
|
|
||||||
def _walk_dir(dir, maxlevels=RECURSION_LIMIT, quiet=0):
|
def _walk_dir(dir, maxlevels, quiet=0):
|
||||||
if PY36 and quiet < 2 and isinstance(dir, os.PathLike):
|
if PY36 and quiet < 2 and isinstance(dir, os.PathLike):
|
||||||
dir = os.fspath(dir)
|
dir = os.fspath(dir)
|
||||||
else:
|
else:
|
||||||
@ -81,7 +83,7 @@ def _walk_dir(dir, maxlevels=RECURSION_LIMIT, quiet=0):
|
|||||||
yield from _walk_dir(fullname, maxlevels=maxlevels - 1,
|
yield from _walk_dir(fullname, maxlevels=maxlevels - 1,
|
||||||
quiet=quiet)
|
quiet=quiet)
|
||||||
|
|
||||||
def compile_dir(dir, maxlevels=RECURSION_LIMIT, ddir=None, force=False,
|
def compile_dir(dir, maxlevels=None, ddir=None, force=False,
|
||||||
rx=None, quiet=0, legacy=False, optimize=-1, workers=1,
|
rx=None, quiet=0, legacy=False, optimize=-1, workers=1,
|
||||||
invalidation_mode=None, stripdir=None,
|
invalidation_mode=None, stripdir=None,
|
||||||
prependdir=None, limit_sl_dest=None):
|
prependdir=None, limit_sl_dest=None):
|
||||||
@ -119,6 +121,8 @@ def compile_dir(dir, maxlevels=RECURSION_LIMIT, ddir=None, force=False,
|
|||||||
from concurrent.futures import ProcessPoolExecutor
|
from concurrent.futures import ProcessPoolExecutor
|
||||||
except ImportError:
|
except ImportError:
|
||||||
workers = 1
|
workers = 1
|
||||||
|
if maxlevels is None:
|
||||||
|
maxlevels = sys.getrecursionlimit()
|
||||||
files = _walk_dir(dir, quiet=quiet, maxlevels=maxlevels)
|
files = _walk_dir(dir, quiet=quiet, maxlevels=maxlevels)
|
||||||
success = True
|
success = True
|
||||||
if workers is not None and workers != 1 and ProcessPoolExecutor is not None:
|
if workers is not None and workers != 1 and ProcessPoolExecutor is not None:
|
||||||
@ -169,6 +173,11 @@ def compile_file(fullname, ddir=None, force=False, rx=None, quiet=0,
|
|||||||
limit_sl_dest: ignore symlinks if they are pointing outside of
|
limit_sl_dest: ignore symlinks if they are pointing outside of
|
||||||
the defined path.
|
the defined path.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if ddir is not None and (stripdir is not None or prependdir is not None):
|
||||||
|
raise ValueError(("Destination dir (ddir) cannot be used "
|
||||||
|
"in combination with stripdir or prependdir"))
|
||||||
|
|
||||||
success = True
|
success = True
|
||||||
if PY36 and quiet < 2 and isinstance(fullname, os.PathLike):
|
if PY36 and quiet < 2 and isinstance(fullname, os.PathLike):
|
||||||
fullname = os.fspath(fullname)
|
fullname = os.fspath(fullname)
|
||||||
@ -323,7 +332,7 @@ def main():
|
|||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='Utilities to support installing Python libraries.')
|
description='Utilities to support installing Python libraries.')
|
||||||
parser.add_argument('-l', action='store_const', const=0,
|
parser.add_argument('-l', action='store_const', const=0,
|
||||||
default=RECURSION_LIMIT, dest='maxlevels',
|
default=None, dest='maxlevels',
|
||||||
help="don't recurse into subdirectories")
|
help="don't recurse into subdirectories")
|
||||||
parser.add_argument('-r', type=int, dest='recursion',
|
parser.add_argument('-r', type=int, dest='recursion',
|
||||||
help=('control the maximum recursion level. '
|
help=('control the maximum recursion level. '
|
||||||
@ -345,16 +354,16 @@ def main():
|
|||||||
default=None,
|
default=None,
|
||||||
help=('part of path to left-strip from path '
|
help=('part of path to left-strip from path '
|
||||||
'to source file - for example buildroot. '
|
'to source file - for example buildroot. '
|
||||||
'if `-d` and `-s` options are specified, '
|
'`-d` and `-s` options cannot be '
|
||||||
'then `-d` takes precedence.'))
|
'specified together.'))
|
||||||
parser.add_argument('-p', metavar='PREPENDDIR', dest='prependdir',
|
parser.add_argument('-p', metavar='PREPENDDIR', dest='prependdir',
|
||||||
default=None,
|
default=None,
|
||||||
help=('path to add as prefix to path '
|
help=('path to add as prefix to path '
|
||||||
'to source file - for example / to make '
|
'to source file - for example / to make '
|
||||||
'it absolute when some part is removed '
|
'it absolute when some part is removed '
|
||||||
'by `-s` option'
|
'by `-s` option. '
|
||||||
'if `-d` and `-a` options are specified, '
|
'`-d` and `-p` options cannot be '
|
||||||
'then `-d` takes precedence.'))
|
'specified together.'))
|
||||||
parser.add_argument('-x', metavar='REGEXP', dest='rx', default=None,
|
parser.add_argument('-x', metavar='REGEXP', dest='rx', default=None,
|
||||||
help=('skip files matching the regular expression; '
|
help=('skip files matching the regular expression; '
|
||||||
'the regexp is searched for in the full path '
|
'the regexp is searched for in the full path '
|
||||||
@ -404,6 +413,11 @@ def main():
|
|||||||
if args.opt_levels is None:
|
if args.opt_levels is None:
|
||||||
args.opt_levels = [-1]
|
args.opt_levels = [-1]
|
||||||
|
|
||||||
|
if args.ddir is not None and (
|
||||||
|
args.stripdir is not None or args.prependdir is not None
|
||||||
|
):
|
||||||
|
parser.error("-d cannot be used in combination with -s or -p")
|
||||||
|
|
||||||
# if flist is provided then load it
|
# if flist is provided then load it
|
||||||
if args.flist:
|
if args.flist:
|
||||||
try:
|
try:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Name: python-rpm-macros
|
Name: python-rpm-macros
|
||||||
Version: 3
|
Version: 3
|
||||||
Release: 49%{?dist}
|
Release: 50%{?dist}
|
||||||
Summary: The unversioned Python RPM macros
|
Summary: The unversioned Python RPM macros
|
||||||
|
|
||||||
# macros: MIT, compileall2.py: PSFv2
|
# macros: MIT, compileall2.py: PSFv2
|
||||||
@ -78,6 +78,9 @@ install -m 644 %{SOURCE5} \
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Nov 26 2019 Lumír Balhar <lbalhar@redhat.com> - 3-50
|
||||||
|
- Update of bundled compileall2 module
|
||||||
|
|
||||||
* Fri Sep 27 2019 Miro Hrončok <mhroncok@redhat.com> - 3-49
|
* Fri Sep 27 2019 Miro Hrončok <mhroncok@redhat.com> - 3-49
|
||||||
- Define %%python2 and %%python3
|
- Define %%python2 and %%python3
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user