forked from jodal/pyspotify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·117 lines (107 loc) · 2.94 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#! /usr/bin/env python
from distutils.core import setup, Extension
import os
import re
import sys
def get_version():
init_py = open('spotify/__init__.py').read()
metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", init_py))
return metadata['version']
def fullsplit(path, result=None):
"""
Split a pathname into components (the opposite of os.path.join) in a
platform-neutral way.
"""
if result is None:
result = []
head, tail = os.path.split(path)
if head == '':
return [tail] + result
if head == path:
return result
return fullsplit(head, [tail] + result)
def with_mock():
"""
Checks whether 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 = [], []
root_dir = os.path.dirname(__file__)
if root_dir != '':
os.chdir(root_dir)
project_dir = 'spotify'
for dirpath, dirnames, filenames in os.walk(project_dir):
# Ignore dirnames that start with '.'
for i, dirname in enumerate(dirnames):
if dirname.startswith('.'):
del dirnames[i]
if '__init__.py' in filenames:
packages.append('.'.join(fullsplit(dirpath)))
elif filenames:
data_files.append([dirpath,
[os.path.join(dirpath, f) for f in filenames]])
spotify_ext = Extension('spotify._spotify',
[
'src/module.c',
'src/session.c',
'src/link.c',
'src/track.c',
'src/album.c',
'src/albumbrowser.c',
'src/artist.c',
'src/artistbrowser.c',
'src/search.c',
'src/playlist.c',
'src/playlistcontainer.c',
'src/playlistfolder.c',
'src/image.c',
'src/user.c',
'src/pyspotify.c',
'src/toplistbrowser.c',
],
include_dirs=['src'],
libraries=['spotify'],
)
mockspotify_ext = Extension('spotify._mockspotify',
[
'src/mockmodule.c',
'src/session.c',
'src/link.c',
'src/track.c',
'src/album.c',
'src/albumbrowser.c',
'src/artist.c',
'src/artistbrowser.c',
'src/search.c',
'src/playlist.c',
'src/playlistcontainer.c',
'src/playlistfolder.c',
'src/image.c',
'src/user.c',
'src/pyspotify.c',
'src/toplistbrowser.c',
],
include_dirs=['src'],
libraries=['mockspotify'],
)
modules = [spotify_ext]
if with_mock():
modules.append(mockspotify_ext)
setup(
name='pyspotify',
version=get_version(),
description='Python wrapper for libspotify',
long_description=open('README.rst').read(),
author='Doug Winter',
author_email='doug.winter@isotoma.com',
url='http://pyspotify.mopidy.com/',
packages=packages,
data_files=data_files,
ext_modules=modules,
)