From 45bddc1a45696feb9177cd9f850276a1b7d38744 Mon Sep 17 00:00:00 2001 From: "Pawel Hajdan, Jr" Date: Mon, 29 Nov 2010 16:54:16 +0100 Subject: Make subversion dependency optional. --- setup.py | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 14bf959..685eefe 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,11 @@ import os.path import subprocess +import sys from distutils.command.install_scripts import install_scripts from distutils.command.sdist import sdist from distutils.core import setup +from distutils.errors import * def get_version_from_file(): return open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'VERSION')).read() @@ -22,6 +24,23 @@ def get_version(): except IOError: return get_version_from_git() +def get_option(args, name, default=False): + disable_arg = "--disable-" + name + enable_arg = "--enable-" + name + if disable_arg in args and enable_arg in args: + raise DistutilsArgError( + "Conflicting flags: %s, %s" % (disable_arg, enable_arg)) + + if disable_arg in args: + args.remove(disable_arg) + return False + + if enable_arg in args: + args.remove(enable_arg) + return True + + return default + class my_sdist(sdist): def make_release_tree(self, base_dir, files): sdist.make_release_tree(self, base_dir, files) @@ -41,12 +60,21 @@ class my_install_scripts(install_scripts): self.__symlink('chromium-depot-tool', 'gcl') self.__symlink('chromium-depot-tool', 'gclient') +scripts = ["v8-extract-version"] + +cmdclass = {'sdist': my_sdist} + +args = sys.argv[1:] + +enable_subversion = get_option(args, 'subversion', default=True) +if enable_subversion: + scripts += ["chromium-depot-tool", "v8-create-tarball"] + cmdclass['install_scripts'] = my_install_scripts + setup( name="chromium-tools", version=get_version(), - scripts=["chromium-depot-tool", "v8-create-tarball", "v8-extract-version"], - cmdclass={ - 'sdist': my_sdist, - 'install_scripts': my_install_scripts, - } + scripts=scripts, + cmdclass=cmdclass, + script_args=args ) -- cgit v1.2.3-65-gdbad