| Use correct mechanism to determine 32/64 bits |
| |
| Python setup.py builds certain extensions (dl and imageop) only on 32 |
| bits architecture. However, to test whether the architecture is 32 |
| bits or not, it was looking at the sys.maxint value of the host Python |
| interpreter... which might run on a 64 bits architecture even though |
| the target is 32 bits, or which might run on a 32 bits architecture |
| even though the target is 64 bits. |
| |
| Therefore, we introduce a is_arch_64_bits() function, which looks at |
| the pyconfig.h file generated by ./configure for the value of |
| SIZEOF_LONG to determine if the architecture is 32 or 64 bits. |
| |
| Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> |
| --- |
| setup.py | 12 ++++++++++-- |
| 1 file changed, 10 insertions(+), 2 deletions(-) |
| |
| Index: Python-2.7.2/setup.py |
| =================================================================== |
| --- Python-2.7.2.orig/setup.py |
| +++ Python-2.7.2/setup.py |
| @@ -29,6 +29,14 @@ |
| except KeyError: |
| disabled_module_list = list() |
| |
| +def is_arch_64_bits(): |
| + data = open('pyconfig.h').read() |
| + m = re.search(r"#s*define\s+SIZEOF_LONG\s+4\s*", data) |
| + if m is None: |
| + return True |
| + else: |
| + return False |
| + |
| def add_dir_to_list(dirlist, dir): |
| """Add the directory 'dir' to the list 'dirlist' (at the front) if |
| 1) 'dir' is not already in 'dirlist' |
| @@ -628,7 +636,7 @@ |
| exts.append( Extension('audioop', ['audioop.c']) ) |
| |
| # Disabled on 64-bit platforms |
| - if sys.maxint != 9223372036854775807L: |
| + if not is_arch_64_bits(): |
| # Operations on images |
| exts.append( Extension('imageop', ['imageop.c']) ) |
| else: |
| @@ -1444,7 +1452,7 @@ |
| missing.append('_codecs_%s' % loc) |
| |
| # Dynamic loading module |
| - if sys.maxint == 0x7fffffff: |
| + if not is_arch_64_bits(): |
| # This requires sizeof(int) == sizeof(long) == sizeof(char*) |
| dl_inc = find_file('dlfcn.h', [], inc_dirs) |
| if (dl_inc is not None) and (platform not in ['atheos']): |