From d83b1597c3410910fe68d67ee20ed72f27ec1058 Mon Sep 17 00:00:00 2001 From: Antoine Pierlot-Garcin Date: Sat, 25 Feb 2012 17:34:38 +0100 Subject: [PATCH] Add a --with-mock switch to the setup.py script. The switch enables the optional compilation of the mock C extension, which depends on libmockspotify. --- setup.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fe5e144a..9832101b 100755 --- a/setup.py +++ b/setup.py @@ -3,6 +3,7 @@ from distutils.core import setup, Extension import os import re +import sys def get_version(): init_py = open('spotify/__init__.py').read() @@ -23,6 +24,16 @@ def fullsplit(path, result=None): return result return fullsplit(head, [tail] + result) +def with_mock(): + """ + Checks wether the user wants to build the mockmodule (off by default). + """ + try: + sys.argv.remove('--with-mock') + return True + except ValueError: + return False + # Compile the list of packages available, because distutils doesn't have # an easy way to do this. packages, data_files = [], [] @@ -88,6 +99,10 @@ def fullsplit(path, result=None): libraries=['mockspotify'], ) +modules = [spotify_ext] +if with_mock(): + modules.append(mockspotify_ext) + setup( name='pyspotify', version=get_version(), @@ -98,5 +113,5 @@ def fullsplit(path, result=None): url='http://pyspotify.mopidy.com/', packages=packages, data_files=data_files, - ext_modules=[spotify_ext, mockspotify_ext], + ext_modules=modules, )