diff options
| author | Julian Andres Klode <jak@debian.org> | 2009-07-15 17:02:34 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2009-07-15 17:02:34 +0200 |
| commit | 7581c5fb8a8d8e1e0a79c343cbd23725475f846c (patch) | |
| tree | 0597cfe165b0b863f7a3a582dfa8fc9f6d929ff0 /setup.py | |
| parent | f52a32c76764f0e1f0af30b4d9a6471996eabede (diff) | |
| download | python-apt-7581c5fb8a8d8e1e0a79c343cbd23725475f846c.tar.gz | |
Simplify the whole building, build all Python versions with setup.py
Diffstat (limited to 'setup.py')
| -rw-r--r--[-rwxr-xr-x] | setup.py | 73 |
1 files changed, 34 insertions, 39 deletions
@@ -1,50 +1,59 @@ -#! /usr/bin/env python +#!/usr/bin/python +# Builds on python2.X and python3 # $Id: setup.py,v 1.2 2002/01/08 07:13:21 jgg Exp $ import glob import os -import shutil import sys from distutils.core import setup, Extension -from distutils.sysconfig import parse_makefile -from DistUtilsExtra.command import build_extra, build_i18n +cmdclass = {} +try: + from DistUtilsExtra.command import build_extra, build_i18n + from DistUtilsExtra.auto import clean_build_tree + cmdclass['build'] = build_extra.build_extra + cmdclass['build_i18n'] = build_i18n.build_i18n + cmdclass['clean'] = clean_build_tree + build_extra.build_extra.sub_commands.append(("build_sphinx", + lambda x: 'build_sphinx' in cmdclass)) +except ImportError: + print('W: [python%s] DistUtilsExtra import error.' % sys.version[:3]) -# The apt_pkg module -files = map(lambda source: "python/"+source, - sorted(parse_makefile("python/makefile")["APT_PKG_SRC"].split())) +try: + from sphinx.setup_command import BuildDoc + cmdclass['build_sphinx'] = BuildDoc +except ImportError: + print('W: [python%s] Sphinx import error.' % sys.version[:3]) + +if sys.version_info[0] == 3: + from distutils.command.build_py import build_py_2to3 + cmdclass['build_py'] = build_py_2to3 + +# The apt_pkg module. +files = ['apt_pkgmodule.cc', 'acquire.cc', 'cache.cc', 'cdrom.cc', + 'configuration.c', 'depcache.cc', 'generic.cc', 'hashes.cc', + 'hashstring.cc', 'indexfile.cc', 'indexrecords.cc', 'metaindex.cc', + 'pkgmanager.cc', 'pkgrecords.cc', 'pkgsrcrecords.cc', 'policy.cc', + 'progress.cc', 'sourcelist.cc', 'string.cc', 'tag.cc'] +files = ['python/' + fname for fname in files] apt_pkg = Extension("apt_pkg", files, libraries=["apt-pkg"]) # The apt_inst module -files = map(lambda source: "python/"+source, - sorted(parse_makefile("python/makefile")["APT_INST_SRC"].split())) +files = ["python/apt_instmodule.cc", "python/generic.cc", "python/tar.cc"] apt_inst = Extension("apt_inst", files, libraries=["apt-pkg", "apt-inst"]) # Replace the leading _ that is used in the templates for translation -templates = [] - -# build doc if len(sys.argv) > 1 and sys.argv[1] == "build": if not os.path.exists("build/data/templates/"): os.makedirs("build/data/templates") for template in glob.glob('data/templates/*.info.in'): source = open(template, "r") - build = open(os.path.join("build", template[:-3]), "w") - lines = source.readlines() - for line in lines: + build = open("build/" + template[:-3], "w") + for line in source: build.write(line.lstrip("_")) source.close() build.close() - -if len(sys.argv) > 1 and sys.argv[1] == "clean" and '-a' in sys.argv: - for dirname in "build/doc", "doc/build", "build/data", "build/mo": - if os.path.exists(dirname): - print "Removing", dirname - shutil.rmtree(dirname) - else: - print "Not removing", dirname, "because it does not exist" - setup(name="python-apt", description="Python bindings for APT", version=os.environ.get('DEBVER'), @@ -56,20 +65,6 @@ setup(name="python-apt", glob.glob('build/data/templates/*.info')), ('share/python-apt/templates', glob.glob('data/templates/*.mirrors'))], - cmdclass = {"build": build_extra.build_extra, - "build_i18n": build_i18n.build_i18n}, + cmdclass = cmdclass, license = 'GNU GPL', platforms = 'posix') - -if len(sys.argv) > 1 and sys.argv[1] == "build": - import sphinx - try: - import pygtk - except ImportError: - print >> sys.stderr, ('W: Not building documentation because python-' - 'gtk2 is not available at the moment.') - sys.exit(0) - sphinx.main(["sphinx", "-b", "html", "-d", "build/doc/doctrees", - os.path.abspath("doc/source"), "build/doc/html"]) - sphinx.main(["sphinx", "-b", "text", "-d", "build/doc/doctrees", - os.path.abspath("doc/source"), "build/doc/text"]) |
