-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Conversation
We want to move towards having more control over the generation of pyc files, which will allow us to provide deterministic installs and generate pyc files without relying on an already-extracted wheel. To that end, here we are stripping away one layer of abstraction, `compileall.compile_dir`. `compileall.compile_dir` essentially recurses through the provided directories and passes the files and args verbatim to `compileall.compile_file`, so removing that layer means that we directly call `compileall.compile_file`. We make the assumption that we can successfully walk over the source file tree, since we just wrote it, and omit the per-directory traversal error handling done by `compileall.compile_dir`.
What's the advantage of deliberately not using a stdlib function but replicating its behaviour ourselves? This seems like we're taking on extra complexity for no obvious reason. You say
but I don't see how this will enable that. I suggest postponing this change until it's needed for that work, so that the benefit can be seen in context. At the moment this feels very much like YAGNI, or at least a case of splitting PRs up too finely... |
Currently, 'pyc' files are only generated for the wheel we are installing because we run The approach I intend to take is to use the source files after they are installed. Using
That may be fair. My reason for submitting this as a separate PR was to give reviewers a chance to look at If it would help I can submit a PR with the next steps. |
I put the next steps that depend on this one in #8541, so it's clearer how this will be used. I'd love any feedback on how this could be broken up more effectively for review. :) |
Personally, I'm not going to dig into how Of course, that's just my opinion - and I don't particularly mind larger PRs, so maybe I'm unusual here.
Thanks - that's a much more reasonable level to review IMO. To be clear, #8541 replaces this PR, doesn't it? I had a quick look and I think I have a few comments, but I'll look at it properly tomorrow. (Note - I'm somewhat ambivalent about the whole question of "reproducible builds", so I'm more interested in progressing #6030 than #7808. But I don't think that affects my view on this change). |
We want to move towards having more control over the generation of pyc
files, which will allow us to provide deterministic installs and
generate pyc files without relying on an already-extracted wheel.
To that end, here we are stripping away one layer of abstraction,
compileall.compile_dir
.compileall.compile_dir
essentially recursesthrough the provided directories and passes the files and args verbatim
to
compileall.compile_file
, so removing that layer means that wedirectly call
compileall.compile_file
.We make the assumption that we can successfully walk over the
source file tree, since we just wrote it, and omit the per-directory
traversal error handling done by
compileall.compile_dir
.Progresses #6030 and #7808.