Browse files

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.
  • Loading branch information...
1 parent 4dc7246 commit 425d3d6661b7b25bc6058dbfb01d984f21b73f54 @mgorny mgorny committed May 25, 2014
Showing with 5 additions and 4 deletions.
  1. +5 −4 python/setup.py.in
View
9 python/setup.py.in
@@ -3,27 +3,27 @@
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,
libraries = ['nl-3'],
)
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,
libraries = ['nl-3', 'nl-route-3'],
)
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'],
)

0 comments on commit 425d3d6

Please sign in to comment.