56 lines
2.0 KiB
Diff
56 lines
2.0 KiB
Diff
|
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.1/setup.py
|
||
|
===================================================================
|
||
|
--- Python-2.7.1.orig/setup.py
|
||
|
+++ Python-2.7.1/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'
|
||
|
@@ -608,7 +616,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:
|
||
|
@@ -1424,7 +1432,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']):
|