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
platform.processor() and platform.machine() report inconsistent values under Rosetta on M1 macOS
#96993
Comments
|
A quick experiment shows that this does not appear to be inherent to universal binaries: main.c: #include <stdio.h>
#include <sys/utsname.h>
int main(int argc, const char * argv[]) {
struct utsname u;
uname(&u);
printf("uname machine: %s\n", u.machine);
return 0;
} |
|
Aha - it seems that pyenv did not in fact install a universal Python binary, which would explain this behaviour. I do still think the output is quite confusing, so maybe this is a case where it would be better to clarify the documentation. |
|
The documentation is pretty vague and doesn't consider the case where the program runs under emulation (such as rosetta on macOS, but likewise for binfmt* on Linux). Worse, it is far from clear what the specification should be: I have use cases for both behaviours (sometimes I need to know the real CPU, sometimes I need to know whatever CPU-type is used by the current proces) and sometimes I need to know which CPU-types are supported by the interpreter which is functionality that's not exposed in platform at all. |
|
Interesting... on my M1 mac with Python 3.8.9 (from So this is possibly a regression. I can do a bisect when I get some time. I agree with @ronaldoussoren that the documentation needs an update to clarify cases when the program runs under emulation. Possibly with the fix of this bug. |
|
@rossng if pyenv didn't install a universal binary, how did the binary even execute under x86_64? When I try this on a arm64 binary, I get With python 3.10.6 installed from pyenv, I also built a universal binary from the current and cannot reproduce the behaviour: |
|
I think the problem may stem from my default I just ran into this issue again when trying to compile Blender - also reported before at https://developer.blender.org/T78710#1160643 |
Bug report
When I run the Python interpreter in
x86_64mode on an M1 MacBook, I get an unexpected result fromplatform.machine().In
arm64mode:In
x86_64mode:Not that the
processoris correct, but themachineis not.Using an
x86_64clingbinary gives the expected result:As does calling out to the
unameutility as a subprocess:It looks like the implementation of
platform.process()works the same way as this - by calling out to a subprocess - whereasplatform.machine()uses theunamesyscall directly.Not sure what causes this - perhaps it's a fundamental problem for Universal Binaries? In any case, it might be a good idea to patch for this case (since the output makes no sense at the moment).Edit: not a universal binary issue - see below.
Your environment
The text was updated successfully, but these errors were encountered: