-
Notifications
You must be signed in to change notification settings - Fork 52
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
Installer compiles bytecode for wrong python version #172
Comments
Yeah, I'd probably note this down as a bug, because This can be fixed by using installer/src/installer/destinations.py Lines 250 to 253 in 5d1514c
|
I dabbled with switching in So probably this needs some slightly more invasive refactoring. |
You can just save the files that need compiling and do a single subprocess call in |
I don't think it's reasonable to expect a mismatched interepreter version to behave correctly -- the current logic uses information from sysconfig of the currently running interpreter by default, and overriding that means we're breaking that assumption. This is a case that we didn't consider when implementing bytecode compilation though. I think it'd be cleaner to disallow creating a |
If SchemeDictionaryDestination knows the interpreter and it isn't sys.executable it seems trivial to simply allow it via subprocess.run -- batching the files is simply a performance optimization. I'd expect that anyone passing in a bytecode_optimization_levels would rather it work slowly than raise an error. |
I don't know if this is a valid use case or out of scope for this project but since it's possible to install in another environment one might expect that it is also possible to compile bytecode for the target environment.
In the following example
installer
lives in a Python 3.9 environment and installs tomli into a Python 3.11 environment. So far so good. However, it compiles bytecode for its own (Python 3.9) environment instead of the target (Python 3.11) environment. (Probably, it's not even possible to compile for the target environment without creating a subprocess to run the target interpreter?)This issue was originally posted as a side note in python-poetry/poetry#7639. Before implementing our own solution, I just wanted to know if this will probably remain a known limitation of installer or if anyone has an idea if/how it could be supported by installer itself.
install_and_compile.py
The text was updated successfully, but these errors were encountered: