Repository navigation
feat: implement bytecode/pyc compilation - #103
Conversation
|
|
||
| // The file that contains the python source code of the compilation host. We keep this around | ||
| // to make sure the file is not accidentally deleted while the compilation host is still using | ||
| // it. |
There was a problem hiding this comment.
I think this is actually only potentially a problem on Windows, right? On macOS and Linux it shouldn't matter if the file is deleted while Python is running.
There was a problem hiding this comment.
We need to make sure the file exists when python is still initializing. The new method starts the executable but there is no way to be certain that python already read the source code. To that end, I just keep the file around as long as the process is alive but in theory it could also just be deleted somewhere earlier.
| let compiler = ByteCodeCompiler::new(&python_path).unwrap(); | ||
| compiler | ||
| .compile_and_wait(compiler_source.path()) | ||
| .unwrap_err(); |
There was a problem hiding this comment.
Does this mean the process will fail when it can't compile a file? I think usually we should ignore failures – it can happen that some Python file can only be compiled with a newer version, or has some template variables in it etc. so we should silently fail (or with a trace::warn or so).
There was a problem hiding this comment.
Yes! I will change the unpack behavior to just ignore these errors.
Adds pyc compilation.
Since most of the time we want to install multiple wheels at the same time and since starting the Python interpreter has a non-negligable amount of overhead, a compilation daemon is spawned as a subprocess.
Closes #60