Use paths relative to srcdir in setup.py.

Currently, setup.py is created by configure in builddir while source
files (.py and .i) reside in srcdir. Adjust paths in setup.py
appropriately to make it possible to perform an out-of-source build.

This is far from perfect but it mostly works. Python files are copied
from srcdir, and swig *.i files are read from there. However, swig
output files are created in srcdir rather than builddir, and distutils
copies '..' literally when constructing '.o' paths. As a result,
'../python/foo.i' would end up being compiled to
'build/temp*/../python/foo.i'.

The alternative would be to copy '*.i' files to builddir before
proceeding with the build, either in Makefile or through creating
additional distutils command.
This commit is contained in:
Michał Górny 2014-05-25 12:51:32 +02:00
parent 4dc7246742
commit 425d3d6661

View File

@ -3,11 +3,11 @@
from distutils.core import setup, Extension
opts = ['-O', '-nodefaultctor']
include = ['@top_builddir@/include']
include = ['@top_builddir@/include', '@top_srcdir@/include']
library_dirs = ['@top_builddir@/lib/.libs']
netlink_capi = Extension('netlink/_capi',
sources = ['netlink/capi.i'],
sources = ['@srcdir@/netlink/capi.i'],
include_dirs = include,
swig_opts = opts,
library_dirs = library_dirs,
@ -15,7 +15,7 @@ netlink_capi = Extension('netlink/_capi',
)
route_capi = Extension('netlink/route/_capi',
sources = ['netlink/route/capi.i'],
sources = ['@srcdir@/netlink/route/capi.i'],
include_dirs = include,
swig_opts = opts,
library_dirs = library_dirs,
@ -23,7 +23,7 @@ route_capi = Extension('netlink/route/_capi',
)
genl_capi = Extension('netlink/genl/_capi',
sources = ['netlink/genl/capi.i'],
sources = ['@srcdir@/netlink/genl/capi.i'],
include_dirs = include,
swig_opts = opts,
library_dirs = library_dirs,
@ -36,6 +36,7 @@ setup(name = 'netlink',
author = 'Thomas Graf',
author_email = 'tgraf@suug.ch',
ext_modules = [netlink_capi, route_capi, genl_capi],
package_dir = {'': '@srcdir@'},
packages = ['netlink', 'netlink.genl', 'netlink.route',
'netlink.route.links', 'netlink.route.qdisc'],
)