]> git.proxmox.com Git - mirror_lxc.git/blob - src/python-lxc/setup.py
python-lxc: change distribution name _lxc -> lxc
[mirror_lxc.git] / src / python-lxc / setup.py
1 #!/usr/bin/env python3
2 #
3 # python-lxc: Python bindings for LXC
4 #
5 # (C) Copyright Canonical Ltd. 2012
6 #
7 # Authors:
8 # Stéphane Graber <stgraber@ubuntu.com>
9 #
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.
14 #
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.
19 #
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
23 # USA
24
25 import os
26 import subprocess
27
28 from distutils.core import setup, Extension
29 from distutils.command.build_ext import build_ext as BuildExtCommand
30
31
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")
36 ]
37
38 def initialize_options(self):
39 super(LxcBuildExtCommand, self).initialize_options()
40 self.no_pkg_config = False
41
42 def build_extensions(self):
43 if not self.no_pkg_config:
44 pkg_config_executable = os.environ.get('PKG_CONFIG_EXECUTABLE',
45 'pkg-config')
46
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')
52
53 try:
54 includedir = get_pkg_config_var('includedir')
55 libdir = get_pkg_config_var('libdir')
56
57 self.compiler.add_include_dir(includedir)
58 self.compiler.add_library_dir(libdir)
59
60 except subprocess.CalledProcessError:
61 pass
62
63 super(LxcBuildExtCommand, self).build_extensions()
64
65
66 setup(name='lxc',
67 version='0.1',
68 description='LXC',
69 packages=['lxc'],
70 package_dir={'lxc': 'lxc'},
71 ext_modules=[Extension('_lxc', sources=['lxc.c'], libraries=['lxc'])],
72 cmdclass={'build_ext': LxcBuildExtCommand},
73 )