--- pyalpm/setup.py.orig 2020-02-23 16:10:00.163976600 +0100 +++ pyalpm/setup.py 2020-02-23 16:12:27.525811500 +0100 @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import os from setuptools import setup, Extension +import subprocess os.putenv('LC_CTYPE', 'en_US.UTF-8') @@ -9,15 +10,25 @@ PYCMAN_SCRIPTS = ['database', 'deptest', 'query', 'remove', 'sync', 'upgrade', 'version'] +# From: http://code.activestate.com/recipes/502261-python-distutils-pkg-config/ +def pkg_config(*pkg_config_flags, **kw): + flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries'} + kw['extra_compile_args'] = cflags + for token in subprocess.check_output(("pkg-config --libs --cflags %s" % ' '.join(pkg_config_flags)).split()).decode('ascii').split(): + if token[:2] in flag_map: + kw.setdefault(flag_map.get(token[:2]), []).append(token[2:]) + else: + kw['extra_compile_args'].append(token) + return kw + if __name__ == "__main__": cflags = ['-Wall', '-Wextra', '-Werror', '-Wno-unused-parameter', '-Wno-incompatible-pointer-types', - '-Wno-cast-function-type', '-std=c99', '-D_FILE_OFFSET_BITS=64'] + '-Wno-cast-function-type', '-Wno-unused-function', '-Wno-strict-aliasing', '-std=c99', '-D_FILE_OFFSET_BITS=64', + '-DVERSION="%s"' % pyalpm_version] alpm = Extension('pyalpm', - libraries=['alpm'], - extra_compile_args=cflags + ['-DVERSION="%s"' % pyalpm_version], language='C', sources=['src/pyalpm.c', 'src/util.c', @@ -31,7 +42,9 @@ 'src/options.h', 'src/package.h', 'src/pyalpm.h', - 'src/util.h']) + 'src/util.h'], + **pkg_config('libalpm', '--static' if os.getenv('LIBALPM_STATIC') else '') + ) with open("README.md", "r") as fh: long_description = fh.read()