Back to index

python3.2  3.2.2
Functions
patchlevel Namespace Reference

Functions

def get_header_version_info
def get_sys_version_info
def get_version_info

Function Documentation

Definition at line 17 of file patchlevel.py.

00017 
00018 def get_header_version_info(srcdir):
00019     patchlevel_h = os.path.join(srcdir, '..', 'Include', 'patchlevel.h')
00020 
00021     # This won't pick out all #defines, but it will pick up the ones we
00022     # care about.
00023     rx = re.compile(r'\s*#define\s+([a-zA-Z][a-zA-Z_0-9]*)\s+([a-zA-Z_0-9]+)')
00024 
00025     d = {}
00026     f = open(patchlevel_h)
00027     try:
00028         for line in f:
00029             m = rx.match(line)
00030             if m is not None:
00031                 name, value = m.group(1, 2)
00032                 d[name] = value
00033     finally:
00034         f.close()
00035 
00036     release = version = '%s.%s' % (d['PY_MAJOR_VERSION'], d['PY_MINOR_VERSION'])
00037     micro = int(d['PY_MICRO_VERSION'])
00038     if micro != 0:
00039         release += '.' + str(micro)
00040 
00041     level = d['PY_RELEASE_LEVEL']
00042     suffixes = {
00043         'PY_RELEASE_LEVEL_ALPHA': 'a',
00044         'PY_RELEASE_LEVEL_BETA':  'b',
00045         'PY_RELEASE_LEVEL_GAMMA': 'rc',
00046         }
00047     if level != 'PY_RELEASE_LEVEL_FINAL':
00048         release += suffixes[level] + str(int(d['PY_RELEASE_SERIAL']))
00049     return version, release
00050 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 51 of file patchlevel.py.

00051 
00052 def get_sys_version_info():
00053     major, minor, micro, level, serial = sys.version_info
00054     release = version = '%s.%s' % (major, minor)
00055     if micro:
00056         release += '.%s' % micro
00057     if level != 'final':
00058         release += '%s%s' % (level[0], serial)
00059     return version, release
00060 

Here is the caller graph for this function:

Definition at line 61 of file patchlevel.py.

00061 
00062 def get_version_info():
00063     try:
00064         return get_header_version_info('.')
00065     except (IOError, OSError):
00066         version, release = get_sys_version_info()
00067         print >>sys.stderr, 'Can\'t get version info from Include/patchlevel.h, ' \
00068               'using version of this interpreter (%s).' % release
00069         return version, release

Here is the call graph for this function: