Removed warning about old GnuPG.
[zeroinstall.git] / zeroinstall / injector / arch.py
blob00212ce39024129b39b159c8a1696acd0484a451
1 """
2 Information about the current system's architecture.
4 This module provides information about the current system. It is used to determine
5 whether an implementation is suitable for this machine, and to compare different implementations.
7 For example, it will indicate that:
9 - An i486 machine cannot run an i686 binary.
10 - An i686 machine can run an i486 binary, but would prefer an i586 one.
11 - A Windows binary cannot run on a Linux machine.
13 Each dictionary maps from a supported architecture type to a preference level. Lower numbers are
14 better, Unsupported architectures are not listed at all.
15 """
17 # Copyright (C) 2006, Thomas Leonard
18 # See the README file for details, or visit http://0install.net.
20 import os
22 # os_ranks and mapping are mappings from names to how good they are.
23 # 1 => Native (best)
24 # Higher numbers are worse but usable.
25 _uname = os.uname()
27 os_ranks = {
28 # 'Linux' : 3, # Linux (lots of systems support emulation)
29 None : 2, # Any OS
30 _uname[0] : 1, # Current OS
33 def _get_machine_ranks():
34 # Binaries compiled for _this_machine are best...
35 this_machine = _uname[-1]
36 machine_ranks = {this_machine : 0}
38 # If this_machine appears in the first column of this table, all
39 # following machine types on the line will also run on this one
40 # (earlier ones preferred):
41 _machine_matrix = {
42 'i486': ['i386'],
43 'i586': ['i486', 'i386'],
44 'i686': ['i586', 'i486', 'i386'],
45 'ppc64': ['ppc32'],
47 for supported in _machine_matrix.get(this_machine, []):
48 machine_ranks[supported] = len(machine_ranks)
50 # At the lowest priority, try a machine-independant implementation
51 machine_ranks[None] = len(machine_ranks)
52 return machine_ranks
54 machine_ranks = _get_machine_ranks()
55 #print machine_ranks