Handle __pycache__ directories in Python filter
@@ -27,7 +27,8 @@ def builtin(input_files, **kwargs):
# Hidden files
path.unicodename[0] == '.' or
# Shared libraries
- _so_file.search(path.name)):
+ _so_file.search(path.name)
+ ):
logger.info("Removing input %s", path)
else:
lst.append(path)
@@ -38,7 +39,14 @@ def builtin(input_files, **kwargs):
def python(files, input_files, **kwargs):
add = []
for path, fi in iteritems(files):
+ # Include .py files instead of .pyc
if path.ext == b'.pyc':
+ if path.parent.name == b'__pycache__':
+ # Python 3: /dir/__pycache__/mod.cpython-38.pyc -> /dir/mod.py
+ basename = path.unicodename.split('.', 1)[0]
+ pyfile = path.parent.parent / basename + '.py'
+ else:
+ # Python2: /dir/mod.pyc -> /dir/moc.py
pyfile = path.parent / path.stem + '.py'
if pyfile.is_file():
if pyfile not in files:
