Add librpm-tizen.spec file & Debian packaging.
[tools/librpm-tizen.git] / python / setup.py.in
1 #!/usr/bin/env python
2
3 from distutils.core import setup, Extension
4 import subprocess
5 import os
6
7 def pkgconfig(what):
8     out = []
9     cmd = 'pkg-config %s %s' % (what, '@PACKAGE_NAME@')
10     pcout = subprocess.check_output(cmd.split()).decode()
11     for token in pcout.split():
12         out.append(token[2:])
13     return out
14
15 cflags = ['-std=c99', '-Wno-strict-aliasing']
16 additional_link_args = []
17
18 # See if we're building in-tree
19 if os.access('Makefile.am', os.F_OK):
20     cflags.append('-I../include')
21     additional_link_args.extend(['-Wl,-L../rpmio/.libs',
22                                  '-Wl,-L../lib/.libs',
23                                  '-Wl,-L../build/.libs',
24                                  '-Wl,-L../sign/.libs'])
25     os.environ['PKG_CONFIG_PATH'] = '..'
26
27
28 rpmmod = Extension('@PYTHON_MODULENAME@._rpm',
29                    sources = ['header-py.c', 'rpmds-py.c', 'rpmfd-py.c',
30                               'rpmfi-py.c', 'rpmii-py.c', 'rpmkeyring-py.c',
31                               'rpmmacro-py.c', 'rpmmi-py.c', 'rpmps-py.c',
32                               'rpmstrpool-py.c', 'rpmfiles-py.c',
33                               'rpmarchive-py.c', 'rpmtd-py.c',
34                               'rpmte-py.c', 'rpmts-py.c',
35                               'spec-py',
36                               'rpmmodule.c'],
37                    include_dirs = pkgconfig('--cflags'),
38                    library_dirs = pkgconfig('--libs-only-L'),
39                    libraries = pkgconfig('--libs-only-l') + ['rpmbuild', 'rpmsign'],
40                    extra_compile_args = cflags,
41                    extra_link_args = additional_link_args
42                   )
43
44 setup(name='@PACKAGE_NAME@',
45       version='@VERSION@',
46       description='Python bindings for @PACKAGE_NAME@',
47       maintainer_email='@PACKAGE_BUGREPORT@',
48       url='http://www.rpm.org/',
49       packages=['@PACKAGE_NAME@'],
50       ext_modules=[rpmmod]
51      )