-
Notifications
You must be signed in to change notification settings - Fork 8
/
setup.py
executable file
·98 lines (92 loc) · 2.26 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
#!/usr/bin/env python3
# -*- Python -*-
import os
import sys
import stat
try:
from setuptools import setup, Extension
except ImportError:
from distutils.core import setup, Extension
VERSION='1.2.12'
if os.path.exists("version"):
fp = open("version", "r")
ver = fp.readline()[:-1]
fp.close()
else:
ver = None
if ver != VERSION:
fp = open("version", "w+")
fp.write(VERSION + '\n')
fp.close()
del fp
setup(
name='pyalsa',
version=VERSION,
description="Python binding for the ALSA library.",
url="http://www.alsa-project.org",
download_url="ftp://ftp.alsa-project.org/pub/pyalsa/",
license="LGPLv2+",
author="The ALSA Team",
author_email='[email protected]',
ext_modules=[
Extension('pyalsa.alsacard',
['pyalsa/alsacard.c'],
include_dirs=[],
library_dirs=[],
libraries=['asound']),
Extension('pyalsa.alsacontrol',
['pyalsa/alsacontrol.c'],
include_dirs=[],
library_dirs=[],
libraries=['asound']),
Extension('pyalsa.alsahcontrol',
['pyalsa/alsahcontrol.c'],
include_dirs=[],
library_dirs=[],
libraries=['asound']),
Extension('pyalsa.alsamixer',
['pyalsa/alsamixer.c'],
include_dirs=[],
library_dirs=[],
libraries=['asound']),
Extension('pyalsa.alsaseq',
['pyalsa/alsaseq.c'],
include_dirs=[],
library_dirs=[],
libraries=['asound']),
],
packages=['pyalsa'],
scripts=[]
)
SOFILES = [
'alsacard',
'alsacontrol',
'alsahcontrol',
'alsamixer',
'alsaseq'
]
if sys.argv[1] != 'build':
sys.exit(0)
uname = os.uname()
if sys.version_info < (3, 0):
dir = 'build/lib.%s-%s-%s/pyalsa' % (uname[0].lower(), uname[4], sys.version[:3])
else:
dir = 'build/lib.%s-%s-cpython-%s%s/pyalsa' % (uname[0].lower(), uname[4], sys.version_info.major, sys.version_info.minor)
files = os.path.exists(dir) and os.listdir(dir) or []
for f in SOFILES:
path = ''
for f2 in files:
if f2.startswith(f + '.') and f2.endswith('.so'):
path = dir + '/' + f2
break
if not path or not os.path.exists(path):
continue
p = 'pyalsa/%s.so' % f
print("%s -> %s" % (p, path))
try:
st = os.lstat(p)
if stat.S_ISLNK(st.st_mode):
os.remove(p)
except:
pass
os.symlink('../' + path, 'pyalsa/%s.so' % f)