diff --git a/setup.py b/setup.py index c0278fd19..74d0083ca 100755 --- a/setup.py +++ b/setup.py @@ -147,15 +147,20 @@ LCMS_ROOT = None def _pkg_config(name): try: - command = [ + command_libs = [ 'pkg-config', '--libs-only-L', name, + ] + command_cflags = [ + 'pkg-config', '--cflags-only-I', name, ] if not DEBUG: - command.append('--silence-errors') - libs = subprocess.check_output(command).decode('utf8').split(' ') - return libs[1][2:].strip(), libs[0][2:].strip() + command_libs.append('--silence-errors') + command_cflags.append('--silence-errors') + libs = subprocess.check_output(command_libs).decode('utf8').strip().replace('-L', '') + cflags = subprocess.check_output(command_cflags).decode('utf8').strip().replace('-I', '') + return (libs, cflags) except Exception: pass @@ -247,6 +252,11 @@ class pil_build_ext(build_ext): IMAGEQUANT_ROOT="libimagequant" ).items(): root = globals()[root_name] + + if root is None and root_name in os.environ: + prefix = os.environ[root_name] + root = (os.path.join(prefix, 'lib'), os.path.join(prefix, 'include')) + if root is None and pkg_config: if isinstance(lib_name, tuple): for lib_name2 in lib_name: