]> git.proxmox.com Git - mirror_lxc.git/commitdiff
python-lxc: pass include/library dirs as arguments to setup.py
authorAleksandr Mezin <mezin.alexander@gmail.com>
Fri, 27 May 2016 09:38:42 +0000 (15:38 +0600)
committerAleksandr Mezin <mezin.alexander@gmail.com>
Fri, 27 May 2016 12:05:17 +0000 (18:05 +0600)
Signed-off-by: Aleksandr Mezin <mezin.alexander@gmail.com>
.gitignore
configure.ac
src/python-lxc/Makefile.am
src/python-lxc/setup.py [new file with mode: 0644]
src/python-lxc/setup.py.in [deleted file]

index adc965e7dd0288b8897b844f40d2b5f153f31402..a2a34e27dc8dd43a982209cabfe2e28614760fa0 100644 (file)
@@ -66,7 +66,6 @@ src/lxc/lxc-wait
 src/lxc/lxc-user-nic
 src/lxc/version.h
 
-src/python-lxc/setup.py
 src/python-lxc/build/
 src/python-lxc/lxc/__pycache__/
 
index 9475b0ed20d3091da8731a522f3c94ed5a5cbd5c..13820ef88bdee6306abc6f85325c98e5df3ca7d0 100644 (file)
@@ -847,7 +847,6 @@ AC_CONFIG_FILES([
        src/lxc/lxc.functions
        src/lxc/version.h
        src/python-lxc/Makefile
-       src/python-lxc/setup.py
 
        src/lua-lxc/Makefile
 
index 4a014df7d8b745a0f10fc397c62dfee6cf1cccb6..cbb274721123ac7efb6667a751abcec3c16ad1a4 100644 (file)
@@ -6,21 +6,25 @@ else
     DISTSETUPOPTS=
 endif
 
+INSTALL_OPTS := install --prefix=$(prefix) --no-compile $(DISTSETUPOPTS)
+CALL_SETUP_PY := cd @srcdir@ && $(PYTHON) setup.py build -b @abs_builddir@/build
+
 all:
-       $(PYTHON) setup.py build
+       $(CALL_SETUP_PY) build_ext -I @abs_top_srcdir@/src -L @abs_top_builddir@/src/lxc
 
 install:
-       if [ "$(DESTDIR)" = "" ]; then \
-               $(PYTHON) setup.py install --prefix=$(prefix) --no-compile $(DISTSETUPOPTS); \
+       if [ -z "$(DESTDIR)" ]; then \
+               $(CALL_SETUP_PY) $(INSTALL_OPTS); \
        else \
-               $(PYTHON) setup.py install --root=$(DESTDIR) --prefix=$(prefix) --no-compile $(DISTSETUPOPTS); \
+               $(CALL_SETUP_PY) $(INSTALL_OPTS) --root=$(DESTDIR); \
        fi
 
 clean-local:
-       rm -rf build
+       rm -rf @builddir@/build
 
 endif
 EXTRA_DIST = \
+       setup.py \
        lxc.c \
        lxc/__init__.py \
        examples/api_test.py \
diff --git a/src/python-lxc/setup.py b/src/python-lxc/setup.py
new file mode 100644 (file)
index 0000000..d8cb166
--- /dev/null
@@ -0,0 +1,34 @@
+#!/usr/bin/env python3
+#
+# python-lxc: Python bindings for LXC
+#
+# (C) Copyright Canonical Ltd. 2012
+#
+# Authors:
+# Stéphane Graber <stgraber@ubuntu.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+# USA
+
+from distutils.core import setup, Extension
+
+
+setup(name='_lxc',
+      version='0.1',
+      description='LXC',
+      packages=['lxc'],
+      package_dir={'lxc': 'lxc'},
+      ext_modules=[Extension('_lxc', sources=['lxc.c'], libraries=['lxc'])],
+      )
diff --git a/src/python-lxc/setup.py.in b/src/python-lxc/setup.py.in
deleted file mode 100644 (file)
index fcb676e..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/usr/bin/env python3
-#
-# python-lxc: Python bindings for LXC
-#
-# (C) Copyright Canonical Ltd. 2012
-#
-# Authors:
-# Stéphane Graber <stgraber@ubuntu.com>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
-# USA
-
-import os, os.path
-from distutils.core import setup, Extension
-
-# Distutils doesn't cope well with source files that have relative paths going
-# up in the directory tree: it tries to navigate outside of the build dir and
-# fails miserably. Therefore, we will instead cd to the source directory,
-# run this script from there, but write the build products to the correct path.
-#
-# Since we will be changing directories before building, we must transform
-# all the path variables to their forms relative to srcdir.
-
-srcdir, builddir, top_srcdir, top_builddir = map(os.path.abspath,
-    ["@srcdir@", "@builddir@", "@top_srcdir@", "@top_builddir@"])
-
-builddir, top_srcdir, top_builddir = map(lambda d: os.path.relpath(d, srcdir),
-    [builddir, top_srcdir, top_builddir])
-
-os.chdir(srcdir)
-
-module = Extension('_lxc', sources=['lxc.c'],
-                   include_dirs=[os.path.join(top_srcdir, 'src'),
-                                 os.path.join(top_builddir, 'src')],
-                   library_dirs=[os.path.join(top_builddir, 'src/lxc')],
-                   libraries=['lxc'])
-
-
-setup(name='_lxc',
-      version='0.1',
-      description='LXC',
-      packages=['lxc'],
-      package_dir={'lxc': 'lxc'},
-      ext_modules=[module],
-      options={'build': {'build_base': os.path.join(builddir, 'build')}})