3

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.

2
  • 1
    What do you mean by "build number"? Commented Sep 2, 2014 at 21:13
  • 1
    The bit of information needed in the Info.plist file to create applications called BuildMachineOSBuild, the build number being shown here Commented Sep 3, 2014 at 23:32

4 Answers 4

3

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!

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

1

See https://stackoverflow.com/a/11697362/871119

A Python version might look like:

import ctypes

libc = ctypes.CDLL("libc.dylib")
size = ctypes.c_uint(256)
buf = ctypes.create_string_buffer(size.value)

if libc.sysctlbyname("kern.osversion", buf, ctypes.byref(size), None, 0) == 0:
    print buf.value
else:
    print "Fails"

Works on the system provided version of Python on my Mac.

Comments

0

To find the current working platform, I would usually use the

    sys

module, with a .platform to get this code

    import sys
    sys.platform
'win32'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.