forked from jodal/pyspotify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.py
92 lines (70 loc) · 2.31 KB
/
tasks.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
from __future__ import print_function, unicode_literals
import shutil
import sys
from invoke import run, task
@task
def docs(watch=False, warn=False):
if watch:
return watcher(docs)
run('make -C docs/ html', warn=warn)
@task
def test(coverage=False, watch=False, warn=False):
if watch:
return watcher(test, coverage=coverage)
cmd = 'py.test'
if coverage:
cmd += ' --cov=spotify --cov-report=term-missing'
run(cmd, pty=True, warn=warn)
@task
def preprocess_header():
run(
'cpp -nostdinc spotify/api.h | egrep -v "(^#)|(^$)" '
'> spotify/api.processed.h || true')
@task
def update_authors():
# Keep authors in the order of appearance and use awk to filter out dupes
run("git log --format='- %aN <%aE>' --reverse | awk '!x[$0]++' > AUTHORS")
@task
def update_sp_constants():
import spotify
constants = [
'%s,%s\n' % (attr, getattr(spotify.lib, attr))
for attr in dir(spotify.lib)
if attr.startswith('SP_')]
with open('docs/sp-constants.csv', 'w+') as fh:
fh.writelines(constants)
def watcher(task, *args, **kwargs):
while True:
run('clear')
kwargs['warn'] = True
task(*args, **kwargs)
try:
run(
'inotifywait -q -e create -e modify -e delete '
'--exclude ".*\.(pyc|sw.)" -r docs/ spotify/ tests/')
except KeyboardInterrupt:
sys.exit()
@task
def mac_wheels():
"""
Create wheel packages compatible with:
- OS X 10.6+
- 32-bit and 64-bit
- Apple-Python, Python.org-Python, Homebrew-Python
Based upon https://github.com/MacPython/wiki/wiki/Spinning-wheels
"""
prefix = '/Library/Frameworks/Python.framework/Versions'
versions = [
('2.7', ''),
('3.4', '3'),
]
# Build wheels for all Python versions
for version, suffix in versions:
run('%s/%s/bin/pip%s install -U pip wheel' % (prefix, version, suffix))
shutil.rmtree('./build', ignore_errors=True)
run('%s/%s/bin/python%s setup.py bdist_wheel' % (
prefix, version, suffix))
# Bundle libspotify into the wheels
shutil.rmtree('./fixed_dist', ignore_errors=True)
run('delocate-wheel -w ./fixed_dist ./dist/*.whl')
print('To upload wheels, run: twine upload fixed_dist/*')