Reputation: 83
I don't have an M1 Mac to work with, I read that python supports it. What's the return of these functions on m1 Macs?
platform.system()
platform.architecture()
Thanks.
Upvotes: 7
Views: 3043
Reputation: 156
For additional context, here's a few more values on Intel vs Apple:
% arch -x86_64 python3
Python 3.11.4 (v3.11.4:d2340ef257, Jun 6 2023, 19:15:51) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
>>> platform.machine()
'x86_64'
>>> platform.processor()
'i386'
% python3
Python 3.11.4 (v3.11.4:d2340ef257, Jun 6 2023, 19:15:51) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
>>> platform.machine()
'arm64'
>>> platform.processor()
'arm'
Upvotes: 0
Reputation: 1
I got an M1 pro and the outputs are:
Python 3.8.15 (default, Nov 10 2022, 13:17:42)
[Clang 14.0.6 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more
information.
>>> import platform
>>> platform.platform()
'macOS-10.16-x86_64-i386-64bit'
>>> platform.system()
'Darwin'
Upvotes: 0
Reputation: 1418
On the actual M1 Mac, the platform
module returns the following values:
shuuji3@momo ~ % python3
Python 3.8.2 (default, Dec 21 2020, 15:06:03)
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.platform()
'macOS-11.2.3-arm64-arm-64bit'
>>> platform.system()
'Darwin'
>>> platform.architecture()
('64bit', '')
>>> platform.processor()
'arm'
In addition to that, under the Rosetta 2 (Intel mode), the platform
module returns the different values like followings:
shuuji3@momo ~ % env /usr/bin/arch -x86_64 /bin/zsh --login
shuuji3@momo ~ % python3
Python 3.8.2 (default, Dec 21 2020, 15:06:04)
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.platform()
'macOS-11.2.3-x86_64-i386-64bit'
>>> platform.system()
'Darwin'
>>> platform.architecture()
('64bit', '')
>>> platform.processor()
'i386'
Note: For the first command, I'm following the instruction in the article, How to Run Legacy Command Line Apps on Apple Silicon | Walled Garden Farmers.
We could use these values to distinguish under which mode the current M1 mac runs an application.
Upvotes: 6