From 16aea81dc77fece89766065d70dcff3ce9a640a7 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 9 Mar 2011 15:37:07 +0200 Subject: [PATCH] Preliminary distutils support for the python bindings - Steps towards separating rpm-python from the main rpm tarball even though developed within the rpm repository. - Having the bindings in a separate tarball makes it simpler to build them for different python versions, notably python 3 (RhBug:531543) --- configure.ac | 1 + python/MANIFEST.in | 1 + python/setup.py.in | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 python/MANIFEST.in create mode 100644 python/setup.py.in diff --git a/configure.ac b/configure.ac index ede3c44..cae5f0b 100644 --- a/configure.ac +++ b/configure.ac @@ -881,5 +881,6 @@ AC_CONFIG_FILES([Makefile luaext/Makefile tests/Makefile plugins/Makefile + python/setup.py ]) AC_OUTPUT diff --git a/python/MANIFEST.in b/python/MANIFEST.in new file mode 100644 index 0000000..a430636 --- /dev/null +++ b/python/MANIFEST.in @@ -0,0 +1 @@ +include MANIFEST.in *.h diff --git a/python/setup.py.in b/python/setup.py.in new file mode 100644 index 0000000..619b0ac --- /dev/null +++ b/python/setup.py.in @@ -0,0 +1,55 @@ +#!/usr/bin/env python + +from distutils.core import setup, Extension +import subprocess +from glob import glob + +def pkgconfig(what): + out = [] + cmd = 'pkg-config %s %s' % (what, '@PACKAGE_NAME@') + pcout = subprocess.check_output(cmd.split()).decode() + for token in pcout.split(): + out.append(token[2:]) + return out + +def mksources(names): + srcs = [] + for n in names: + srcs.extend(glob('%s*.c' % n)) + return srcs + +cflags = ['-std=c99'] + +rpmmod = Extension('rpm._rpm', + sources = mksources([ + 'header', 'rpmds', 'rpmfd', 'rpmfi', 'rpmii', + 'rpmkeyring', 'rpmmacro', 'rpmmi', 'rpmps', + 'rpmtd', 'rpmte', 'rpmts', 'rpmmodule', + ]), + include_dirs = pkgconfig('--cflags'), + libraries = pkgconfig('--libs'), + extra_compile_args = cflags + ) + +rpmbuild_mod = Extension('rpm._rpmb', + sources = mksources(['rpmbmodule', 'spec']), + include_dirs = pkgconfig('--cflags'), + libraries = pkgconfig('--libs') + ['rpmbuild'], + extra_compile_args = cflags + ) + +rpmsign_mod = Extension('rpm._rpms', + sources = mksources(['rpmbmodule']), + include_dirs = pkgconfig('--cflags'), + libraries = pkgconfig('--libs') + ['rpmsign'], + extra_compile_args = cflags + ) + +setup(name='@PACKAGE_NAME@-python', + version='@VERSION@', + description='Python bindings for @PACKAGE_NAME@', + maintainer_email='@PACKAGE_BUGREPORT@', + url='http://www.rpm.org/', + packages = ['@PACKAGE_NAME@'], + ext_modules= [rpmmod, rpmbuild_mod, rpmsign_mod] + ) -- 2.7.4