setup.py: add option to disable platform guessing

When cross-compiling (ex on Buildroot) platform guessing is not needed
cause the environment is correctly built externally.
This patch adds an option to disable platform guessing on Linux.
This commit is contained in:
Angelo Compagnucci 2016-04-25 17:03:36 +02:00
parent 72766b8f4e
commit ce2bb05a2b

View File

@ -146,9 +146,13 @@ class pil_build_ext(build_ext):
('disable-%s' % x, None, 'Disable support for %s' % x) for x in feature
] + [
('enable-%s' % x, None, 'Enable support for %s' % x) for x in feature
] + [('debug', None, 'Debug logging')]
] + [
('disable-platform-guessing', None, 'Disable platform guessing on Linux'),
('debug', None, 'Debug logging')
]
def initialize_options(self):
self.disable_platform_guessing = None
build_ext.initialize_options(self)
for x in self.feature:
setattr(self, 'disable_%s' % x, None)
@ -266,6 +270,9 @@ class pil_build_ext(build_ext):
_add_directory(include_dirs, "/usr/X11/include")
elif sys.platform.startswith("linux"):
if self.disable_platform_guessing:
pass
else:
arch_tp = (plat.processor(), plat.architecture()[0])
if arch_tp == ("x86_64", "32bit"):
# 32-bit build on 64-bit machine.
@ -382,11 +389,13 @@ class pil_build_ext(build_ext):
# look for tcl specific subdirectory (e.g debian)
if _tkinter:
if not self.disable_platform_guessing:
tcl_dir = "/usr/include/tcl" + TCL_VERSION
if os.path.isfile(os.path.join(tcl_dir, "tk.h")):
_add_directory(include_dirs, tcl_dir)
# standard locations
if not self.disable_platform_guessing:
_add_directory(library_dirs, "/usr/local/lib")
_add_directory(include_dirs, "/usr/local/include")