Skip to content

Commit

Permalink
Merge pull request #3395 from diorcety/improve_configuration
Browse files Browse the repository at this point in the history
Improve configuration
  • Loading branch information
hugovk committed Dec 26, 2018
2 parents 7beecb9 + ddb01ac commit c2b3bd5
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,20 @@ def get_version():

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

Expand Down Expand Up @@ -247,6 +252,11 @@ def build_extensions(self):
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:
Expand Down

0 comments on commit c2b3bd5

Please sign in to comment.