Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python finding mac os build number

Tags:

python

macos

How can I find my Mac OS X build number? And if possible, is there a way to find it using Python? I would like to use Python so that I can automatically make OS X .app files in an automated fashion.

EDIT: I see the 'Marked as duplicate' messages, and realize that people think that I mean the Mac OS X VERSION number. I'm talking about the BUILD number.

like image 968
andrew Avatar asked Feb 02 '26 14:02

andrew


2 Answers

Oddly enough, the OS X build number does not seem to be available through the platform module. OS X does provide a sw_vers command which can be used to retrieve the build number through os.popen.

Example:

import os
print(os.popen("sw_vers -buildVersion").read().strip())

Output on OS X 10.9.4 Mavericks:

13E28

Not ideal, but it works!

like image 68
Alexander O'Mara Avatar answered Feb 05 '26 06:02

Alexander O'Mara


Try the platform module? It will get you just about everything Python knows about the version of the OS, as well as info about the Python interpreter itself.

https://docs.python.org/2/library/platform.htm

like image 39
William McBrine Avatar answered Feb 05 '26 05:02

William McBrine