Skip to content

Commit

Permalink
Add a --with-mock switch to the setup.py script.
Browse files Browse the repository at this point in the history
The switch enables the optional compilation of the mock C extension, which
depends on libmockspotify.
  • Loading branch information
bok committed Feb 25, 2012
1 parent 40f5681 commit d83b159
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 = [], []
Expand Down Expand Up @@ -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(),
Expand All @@ -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,
)

0 comments on commit d83b159

Please sign in to comment.