diff --git a/setup.py b/setup.py index 487e8d6ba..ead5be6d7 100755 --- a/setup.py +++ b/setup.py @@ -312,62 +312,47 @@ class pil_build_ext(build_ext): elif sys.platform.startswith("linux"): arch_tp = (plat.processor(), plat.architecture()[0]) - if arch_tp == ("x86_64", "32bit"): - # 32-bit build on 64-bit machine. + # This should be correct on debian derivatives. + if plat.dist()[0].lower() in ('debian', 'ubuntu'): + # If this doesn't work, don't just silently patch + # downstream because it's going to break when people + # try to build pillow from source instead of + # installing from the system packages. + self.add_multiarch_paths() + + elif arch_tp == ("x86_64", "32bit"): + # Special Case: 32-bit build on 64-bit machine. _add_directory(library_dirs, "/usr/lib/i386-linux-gnu") else: + libdirs = { + 'x86_64': ["/lib64", "/usr/lib64", "/usr/lib/x86_64-linux-gnu"], + '64bit': ["/lib64", "/usr/lib64", "/usr/lib/x86_64-linux-gnu"], + 'i386': ["/usr/lib/i386-linux-gnu"], + 'i686': ["/usr/lib/i386-linux-gnu"], + '32bit': ["/usr/lib/i386-linux-gnu"], + 'aarch64': ["/usr/lib64", "/usr/lib/aarch64-linux-gnu"], + 'arm': ["/usr/lib/arm-linux-gnueabi"], + 'armv71': ["/usr/lib/arm-linux-gnueabi"], + 'ppc64': ["/usr/lib64", "/usr/lib/ppc64-linux-gnu", + "/usr/lib/powerpc64-linux-gnu"], + 'ppc': ["/usr/lib/ppc-linux-gnu", + "/usr/lib/powerpc-linux-gnu"], + 's390x': ["/usr/lib64", "/usr/lib/s390x-linux-gnu"], + 's390': ["/usr/lib/s390-linux-gnu"], + } + for platform_ in arch_tp: - + dirs = libdirs.get(platform_, None) if not platform_: continue - - if platform_ in ["x86_64", "64bit"]: - _add_directory(library_dirs, "/lib64") - _add_directory(library_dirs, "/usr/lib64") - _add_directory(library_dirs, - "/usr/lib/x86_64-linux-gnu") - break - elif platform_ in ["i386", "i686", "32bit"]: - _add_directory(library_dirs, "/usr/lib/i386-linux-gnu") - break - elif platform_ in ["aarch64"]: - _add_directory(library_dirs, "/usr/lib64") - _add_directory(library_dirs, - "/usr/lib/aarch64-linux-gnu") - break - elif platform_ in ["arm", "armv7l"]: - _add_directory(library_dirs, - "/usr/lib/arm-linux-gnueabi") - break - elif platform_ in ["ppc64"]: - _add_directory(library_dirs, "/usr/lib64") - _add_directory(library_dirs, - "/usr/lib/ppc64-linux-gnu") - _add_directory(library_dirs, - "/usr/lib/powerpc64-linux-gnu") - break - elif platform_ in ["ppc"]: - _add_directory(library_dirs, "/usr/lib/ppc-linux-gnu") - _add_directory(library_dirs, - "/usr/lib/powerpc-linux-gnu") - break - elif platform_ in ["s390x"]: - _add_directory(library_dirs, "/usr/lib64") - _add_directory(library_dirs, - "/usr/lib/s390x-linux-gnu") - break - elif platform_ in ["s390"]: - _add_directory(library_dirs, "/usr/lib/s390-linux-gnu") - break + for path in dirs: + _add_directory(library_dirs, path) + break + else: raise ValueError( "Unable to identify Linux platform: `%s`" % platform_) - # XXX Kludge. Above /\ we brute force support multiarch. Here we - # try Barry's more general approach. Afterward, something should - # work ;-) - self.add_multiarch_paths() - # termux support for android. # system libraries (zlib) are installed in /system/lib # headers are at $PREFIX/include