diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2016-01-21 20:06:09 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2016-01-21 20:06:09 +0000 |
commit | 88e9da1ddec51a99246d5128a6202dd9205af34c (patch) | |
tree | e63a7c53d07ee4803bca6ee61c9c32c77ab9fa37 | |
parent | d7677ab1bcabe60e84215eb17b51b644737bfcb0 (diff) | |
download | dbus-python-88e9da1ddec51a99246d5128a6202dd9205af34c.tar.gz |
Add a setup.py which wraps Autotools in something virtualenv-friendly
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile.am | 9 | ||||
-rwxr-xr-x | setup.py | 107 |
3 files changed, 117 insertions, 0 deletions
@@ -13,6 +13,7 @@ /aclocal.m4 /api/ /autom4te.cache/ +/build/ /build-aux/ /compile /config.cache diff --git a/Makefile.am b/Makefile.am index 53c38ab..e23b508 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,6 +25,7 @@ EXTRA_DIST = \ m4/am-check-pymod.m4 \ m4/am-check-python-headers.m4 \ m4/dbus-py-add-rst2htmlflag.m4 \ + setup.py \ test/TestSuitePythonService.service.in \ test/tmp-session-bus.conf.in \ tools/check-coding-style.mk \ @@ -347,6 +348,7 @@ $(patsubst %,%.test,$(test_programs)): %.test: Makefile # === Documentation === dist-hook: + echo $(VERSION) > $(distdir)/.version chmod u+w $(distdir)/ChangeLog if test -d $(top_srcdir)/.git; then \ if GIT_DIR=$(top_srcdir)/.git git log --stat > $(distdir)/ChangeLog; then \ @@ -355,6 +357,13 @@ dist-hook: GIT_DIR=$(top_srcdir)/.git git log > $(distdir)/ChangeLog; \ fi; \ fi + touch $(distdir)/MANIFEST + touch $(distdir)/MANIFEST.in + ( cd $(distdir) && find -type d -o -print ) | \ + LC_ALL=C sort | \ + $(SED) -e 's|^\./||' \ + > $(distdir)/MANIFEST + sed -e 's/.*/include &/' < $(distdir)/MANIFEST > $(distdir)/MANIFEST.in TXT_RSTDOCS = \ doc/tutorial.txt \ diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..ee7191b --- /dev/null +++ b/setup.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python +# encoding: utf-8 + +# Copyright © 2016 Collabora Ltd. <http://www.collabora.co.uk/> +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +from distutils.dir_util import copy_tree, mkpath +from distutils.file_util import copy_file +from setuptools.dist import Distribution +from setuptools import setup, Extension +import os +import subprocess +import sys + +if os.path.exists('.version'): + version = open('.version', encoding='utf-8').read().strip() +else: + version = subprocess.check_output(['autoconf', '--trace', 'AC_INIT:$2', + 'configure.ac']).decode('utf-8').strip() + +class Build(Distribution().get_command_class('build')): + """Dummy version of distutils build which runs an Autotools build system + instead. + """ + + def run(self): + srcdir = os.getcwd() + builddir = os.path.join(srcdir, self.build_temp) + configure = os.path.join(srcdir, 'configure') + mkpath(builddir) + + if not os.path.exists(configure): + configure = os.path.join(srcdir, 'autogen.sh') + + subprocess.check_call([ + configure, + 'PYTHON=' + sys.executable, + # Put the documentation, etc. out of the way: we only want + # the Python code and extensions + '--prefix=' + os.path.join(builddir, 'prefix'), + ], + cwd=builddir) + make_args = [ + 'pythondir=' + os.path.join(srcdir, self.build_lib), + 'pyexecdir=' + os.path.join(srcdir, self.build_lib), + ] + subprocess.check_call(['make', '-C', builddir] + make_args) + subprocess.check_call(['make', '-C', builddir, 'install'] + make_args) + +class BuildExt(Distribution().get_command_class('build_ext')): + def run(self): + pass + +class BuildPy(Distribution().get_command_class('build_py')): + def run(self): + pass + +dbus_bindings = Extension('_dbus_bindings', + sources=['_dbus_bindings/module.c']) +dbus_glib_bindings = Extension('_dbus_glib_bindings', + sources=['_dbus_glib_bindings/module.c']) + +setup( + name='dbus-python', + version=version, + description='Python bindings for libdbus', + maintainer='The D-Bus maintainers', + maintainer_email='dbus@lists.freedesktop.org', + download_url='http://dbus.freedesktop.org/releases/dbus-python/', + url='http://www.freedesktop.org/wiki/Software/DBusBindings/#python', + packages=['dbus'], + ext_modules=[dbus_bindings, dbus_glib_bindings], + license='Expat (MIT/X11)', + classifiers=[ + 'Development Status :: 7 - Inactive', + 'License :: OSI Approved :: MIT License', + 'Programming Language :: C', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: Implementation :: CPython', + 'Topic :: Software Development :: Object Brokering', + ], + cmdclass={ + 'build': Build, + 'build_py': BuildPy, + 'build_ext': BuildExt, + }, +) |