]>
git.proxmox.com Git - mirror_lxc.git/blob - src/python-lxc/setup.py
3 # python-lxc: Python bindings for LXC
5 # (C) Copyright Canonical Ltd. 2012
8 # Stéphane Graber <stgraber@ubuntu.com>
10 # This library is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU Lesser General Public
12 # License as published by the Free Software Foundation; either
13 # version 2.1 of the License, or (at your option) any later version.
15 # This library is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # Lesser General Public License for more details.
20 # You should have received a copy of the GNU Lesser General Public
21 # License along with this library; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
28 from distutils
.core
import setup
, Extension
29 from distutils
.command
.build_ext
import build_ext
as BuildExtCommand
32 class LxcBuildExtCommand(BuildExtCommand
):
33 user_options
= BuildExtCommand
.user_options
+ [
34 ('no-pkg-config', None,
35 "don't use pkg-config to detect include/library paths")
38 def initialize_options(self
):
39 super(LxcBuildExtCommand
, self
).initialize_options()
40 self
.no_pkg_config
= False
42 def build_extensions(self
):
43 if not self
.no_pkg_config
:
44 pkg_config_executable
= os
.environ
.get('PKG_CONFIG_EXECUTABLE',
47 def get_pkg_config_var(name
):
48 args
= [pkg_config_executable
, '--variable', name
, 'lxc']
49 output
= subprocess
.check_output(args
,
50 universal_newlines
=True)
51 return output
.rstrip('\n')
54 includedir
= get_pkg_config_var('includedir')
55 libdir
= get_pkg_config_var('libdir')
57 self
.compiler
.add_include_dir(includedir
)
58 self
.compiler
.add_library_dir(libdir
)
60 except subprocess
.CalledProcessError
:
63 super(LxcBuildExtCommand
, self
).build_extensions()
70 package_dir
={'lxc': 'lxc'},
71 ext_modules
=[Extension('_lxc', sources
=['lxc.c'], libraries
=['lxc'])],
72 cmdclass
={'build_ext': LxcBuildExtCommand
},