Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use compileall.compile_file instead of compileall.compile_dir #8540

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/pip/_internal/operations/install/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,24 @@ def install_unpacked_wheel(
changed = set() # type: Set[RecordPath]
generated = [] # type: List[str]

def pyc_source_file_paths():
# type: () -> Iterator[str]
for dir_path, subdir_paths, files in os.walk(source):
subdir_paths[:] = [
p for p in subdir_paths if p != '__pycache__'
]
for path in files:
yield os.path.join(dir_path, path)

# Compile all of the pyc files that we're going to be installing
if pycompile:
with captured_stdout() as stdout:
with warnings.catch_warnings():
warnings.filterwarnings('ignore')
compileall.compile_dir(source, force=True, quiet=True)
for path in pyc_source_file_paths():
compileall.compile_file(
path, force=True, quiet=True
)
logger.debug(stdout.getvalue())

def record_installed(srcfile, destfile, modified=False):
Expand Down