-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·314 lines (288 loc) · 7.4 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
#!/bin/env python
import sys, config, os, glob
try:
from distutils.core import setup, Extension
except:
print( 'There is a failure to open the Makefile options. Please install python-devel package before installing PyMedia' )
raise
MODULE_NAME= 'pymedia'
VERSION= '1.3.8.0'
def disable_fPIC():
"""Disable -fPIC in the c compiler command line.
Some unix setups need -fPIC turned off to successfully compile
video/libavcodec/i386/dsputil_mmx.c (and other files). Distutils
gets the flag by parsing python2.3/config/Makefile and storing the
result in a cache.
This function is a hack that depends on that internal distutils
behavior, so it may someday stop working or corrupt distutils in an
unexpected way."""
import distutils.sysconfig
try:
distutils.sysconfig.get_config_vars() # parse Makefile and fill the _config_vars cache
except:
print( 'There is a failure to open the Makefile options. Please install python-devel package before installing PyMedia' )
raise
cv = distutils.sysconfig._config_vars
for var in cv: #"CCSHARED","GCCSHARED","CFLAGS","OPT","CONFIG_ARGS":
if type(cv[var])== str:
cv[var] = cv[var].replace('-fPIC','')
for var in ("CXX",):
if var in cv:
if type(cv[var])== str:
cv[var] = cv[var].replace('gcc','g++')
MMX_FILES= [
'i386/cputest.c',
'i386/dsputil_mmx.c',
'i386/fdct_mmx.c',
'i386/idct_mmx.c',
'i386/idct_mmx_xvid.c',
'imgconvert.c',
'imgresample.c',
'resample2.c',
'i386/motion_est_mmx.c',
'i386/mpegvideo_mmx.c',
'i386/simple_idct_mmx.c',
]
NONMMX_FILES= [
'fdctref.c',
'fft.c',
'mdct.c',
]
FILES={
'audio.acodec':
{
'#dir': 'audio',
'':
(
'acodec/acodec.c',
'mem.c'
),
'libavcodec':
(
'utils.c',
'wmadec.c',
'a52dec.c',
'liba52/bit_allocate.c',
'liba52/bitstream.c',
'liba52/downmix.c',
'liba52/imdct.c',
'liba52/parse.c',
'liba52/crc.c',
'faad.c',
'oggvorbis.c',
'common.c',
'mpegaudiodec.c',
'mpegaudio.c',
'mp3lameaudio.c',
'fft.c',
'pcm.c',
'mdct.c',
'ac3enc.c',
'flac.c',
'adpcm.c',
),
},
'muxer':
{
'#dir': 'video',
'':
(
'muxer/demuxer.c',
'muxer/muxer.c',
),
'libavformat':
(
'asf.c',
'avidec.c',
'avienc.c',
'aviobuf.c',
'common.c',
'crc.c',
'cutils.c',
#'flvdec.c',
'integer.c',
'mem.c',
'mov.c',
'mpeg.c',
'mpegts.c',
'mpegtsenc.c',
'ogg.c',
'raw.c',
'utils.c',
'wav.c',
),
},
'video.vcodec':
{
'#dir': 'video',
'':
(
'vcodec/vcodec.c',
),
'libavcodec':
[
'bitstream.c',
'cabac.c',
'crc.c',
'dsputil.c',
'error_resilience.c',
'eval.c',
'golomb.c',
'h263.c',
'h263_parser.c',
'h263dec.c',
'h264.c',
'h264_parser.c',
'h264idct.c',
'h264pred.c',
'jfdctfst.c',
'jfdctint.c',
'jrevdct.c',
'log.c',
'mathematics.c',
'mem.c',
'mjpeg.c',
'motion_est.c',
'mpeg12.c',
'mpeg12data.c',
'mpeg12enc.c',
'mpeg4video_parser.c',
'mpegvideo.c',
'mpegvideo_enc.c',
'msmpeg4.c',
'msmpeg4data.c',
'opt.c',
'parser.c',
'ratecontrol.c',
'rational.c',
'rv10.c',
'simple_idct.c',
'svq1.c',
'svq1dec.c',
'utils.c',
],
},
'removable.cd':
{
'#dir': 'removable',
'cd':
(
'cd.cpp',
'dvdcd.cpp',
'audiocd.cpp'
),
'cd/dvdlibs/dvdcss':
(
'device.c',
'libdvdcss.c',
'error.c',
'css.c',
'ioctl.c'
),
'cd/dvdlibs/dvdread':
(
'dvd_reader.c',
'dvd_udf.c',
'ifo_read.c',
'md5.c',
'nav_read.c'
)
},
'audio.sound':
{
'#dir': 'sound',
'': ( 'sound.cpp', 'resample.c', 'fft.cpp' )
}
}
try:
f= open( 'build.dat' )
buildNum= f.readlines()[ 0 ]
f.close()
except:
buildNum= 1
f= open( 'build.dat', 'wt' )
f.write( str( int( buildNum )+ 1 ) )
f.close()
DEFINES= [( 'BUILD_NUM', buildNum ),]
if sys.platform == 'win32':
print( 'Using WINDOWS configuration...\n' )
dep= config.Dependency_win
inc_hunt = ['include']
lib_hunt = [
'win32\\Static_Release',
'win32\\VorbisEnc_Static_Release',
'win32\\Vorbis_Static_Release',
'libmp3lame\\Release',
'libfaad\\Release',
'VisualC\\SDL\Release']
DEFINES+= [ ('WIN32', None ) ]
LIBS= [ 'winmm' ]
FILES[ 'video.vcodec' ][ 'libavcodec' ]+= NONMMX_FILES
else:
print( 'Using UNIX configuration...\n' )
disable_fPIC()
dep= config.Dependency_unix
inc_hunt = [
'/usr/include',
'/usr/include/lame',
'/usr/local/include',
'/usr/local/include/lame',]
lib_hunt = [ '/usr/lib64', '/usr/lib', '/usr/local/lib64', '/usr/local/lib' ]
LIBS= []
DEFINES+= [
('PATH_DEV_DSP', '"/dev/dsp"' ),
('PATH_DEV_MIXER','"/dev/mixer"' ),
('_FILE_OFFSET_BITS',64),
('ACCEL_DETECT',1),
('HAVE_MMX', '1' ),
]
if sys.platform== 'cygwin':
DEFINES+= [
('SYS_CYGWIN', '1' ),
]
LIBS= [ 'winmm' ]
else:
DEFINES+= [
('HAVE_LINUX_DVD_STRUCT', '1' ),
('DVD_STRUCT_IN_LINUX_CDROM_H', '1' ),
]
FILES[ 'video.vcodec' ][ 'libavcodec' ]+= MMX_FILES
DEPS = [
#dep('OGG', 'libogg-[1-9].*', 'ogg/ogg.h', 'libogg', 'CONFIG_VORBIS').configure(inc_hunt,lib_hunt),
#dep('VORBIS', 'libvorbis-[1-9].*', 'vorbis/codec.h', 'libvorbis', 'CONFIG_VORBIS' ).configure(inc_hunt,lib_hunt),
#dep('FAAD', 'libfaad2', 'faad.h', 'libfaad', 'CONFIG_FAAD').configure(inc_hunt,lib_hunt),
#dep('MP3LAME', 'lame-3.95.*', 'lame.h', 'libmp3lame', 'CONFIG_MP3LAME').configure(inc_hunt,lib_hunt),
#dep('VORBISENC', 'libvorbis-[1-9].*','vorbis/vorbisenc.h','libvorbisenc', 'CONFIG_VORBIS').configure(inc_hunt,lib_hunt),
#dep('ALSA', 'libasound','alsa/asoundlib.h','libasound', 'CONFIG_ALSA').configure(inc_hunt,lib_hunt),
]
DEPS= filter( lambda x: x.found, DEPS )
INC_DIRS= [ x.inc_dir for x in DEPS ]+ [ os.getcwd() ]
LIB_DIRS= [ x.lib_dir for x in DEPS ]
DEFINES+= [ ( x.define, None ) for x in DEPS ]+ [ ( 'HAVE_AV_CONFIG_H', None ), ( 'UDF_CACHE', 1 ) ]
LIBS+= [ x.lib for x in DEPS ]
if sys.version_info[ 0 ]== 2:
choice = raw_input('Continue building '+MODULE_NAME+' ? [Y,n]:')
else:
choice = input('Continue building '+MODULE_NAME+' ? [Y,n]:')
if choice== 'n':
print( 'To start installation please run: \n\tsetup.py install and press Enter when prompted\n' )
sys.exit()
METADATA = {
"name": "pymedia",
"version": VERSION,
"license": "LGPL/GPL",
"url": "http://pymedia.org/",
"author": "Dmitry Borisov",
"author_email": "dborisov@pymedia.org",
"description": "Pymedia library for multimedia easy experience"
}
MODULE= 'pymedia' #+ VERSION.replace( '.', '' )
PACKAGEDATA = {
"packages": [MODULE,MODULE+'.audio',MODULE+'.video', MODULE+'.video.ext_codecs', MODULE+'.removable', 'pymedia'],
"package_dir":
{MODULE: 'inst_lib',MODULE+'.audio': 'inst_lib/audio',MODULE+'.video.ext_codecs': 'inst_lib/video/ext_codecs',MODULE+'.video': 'inst_lib/video',MODULE+'.removable': 'inst_lib/removable'},
"ext_modules": config.extensions( MODULE, FILES, INC_DIRS, LIB_DIRS, DEFINES, LIBS ),
"py_modules": ['config'],
}
PACKAGEDATA.update(METADATA)
apply(setup, [], PACKAGEDATA)