On Thu, May 23, 2013 at 2:05 PM, Wichert Akkerman <
wic...@wiggy.net> wrote:
> Is there a best practice for using pkg-config? I was trying to use cythonize
> since the documentation suggests this is the current preferred method, but
> there doesn't appear to be any API documentation listing its parameters. The
> only working thing I could come up with is to manually modify the extensions
> it returns:
>
> from distutils.core import setup
> import subprocess
> from Cython.Build import cythonize
>
> flags = subprocess.check_output(['pkg-config', '--cflags-only-I', 'pkgA
> pkgB'])
> include_dirs = [flag[2:] for flag in flags.split()]
> flags = subprocess.check_output(['pkg-config', '--libs-only-L', 'pkgA
> pkgB'])
> library_dirs = [flag[2:] for flag in flags.split()]
>
> extensions = cythonize('*.pyx')
> for ext in extensions:
> ext.include_dirs.extend(include_dirs)
> ext.library_dirs.extend(library_dirs)
>
> setup(name='mypkg', ext_modules=extensions)
>
> This feels unnecessarily complex and definitely is not readable. It would be
> very nice if you could do this:
>
> setup(
> name='mypkg',
> ext_modules=cythonize('*.pyx', pkg_config=['pkgA', 'pkgB']),
> )
>
> Or perhaps like this in a .pyx file:
>
> # distutils: language = c++
> # distutils: pkg_config = pkgA pkgB
Perhaps you should do
extensions = cythonize(Extension('*.pyx', [arbitrary Extension arguments]))
- Robert