PageRenderTime 686ms CodeModel.GetById 201ms app.highlight 14ms RepoModel.GetById 245ms app.codeStats 0ms

/setup.py

http://echo-nest-remix.googlecode.com/
Python | 127 lines | 108 code | 16 blank | 3 comment | 27 complexity | a2a45e5e63217199e1c961210b208da2 MD5 | raw file
  1#!/usr/bin/env python
  2
  3__version__ = "$Revision: 0 $"
  4# $Source$
  5
  6from distutils.core import setup, Extension
  7import os, glob
  8import numpy
  9
 10def get_os():
 11    """returns is_linux, is_mac, is_windows"""
 12    if hasattr(os, 'uname'):
 13        if os.uname()[0] == "Darwin":
 14            return False, True, False
 15        return True, False, False
 16    return False, False, True
 17    
 18is_linux, is_mac, is_windows = get_os()
 19
 20def get_action():
 21    cAction = os.path.join('external', 'cAction')   
 22    compile_args = [] if is_windows else ['-Wno-unused']
 23    return Extension("cAction",
 24                        sources = [os.path.join(cAction, 'actionmodule.cpp')],
 25                        extra_compile_args = compile_args,
 26                        include_dirs = [numpy.get_include(), numpy.get_numarray_include()],
 27                     )
 28    
 29def get_dirac():
 30    link_args = ['-framework', 'Carbon'] if is_mac else []
 31    compile_args = [] if is_windows else ['-Wno-unused']
 32    
 33    pydirac = os.path.join('external', 'pydirac225')
 34    lib_sources = [os.path.join(pydirac,'diracmodule.cpp'), os.path.join(pydirac, 'source', 'Dirac_LE.cpp')]
 35    
 36    platform = os.uname()[0] if hasattr(os, 'uname') else 'Windows'
 37    libname = 'Dirac64' if platform == 'Linux' and os.uname()[-1] == 'x86_64' else 'Dirac'
 38    return Extension(   'dirac',
 39                        sources = lib_sources,
 40                        extra_compile_args = compile_args,
 41                        include_dirs = ['source', numpy.get_include(), numpy.get_numarray_include()],
 42                        libraries = [libname],
 43                        library_dirs = [os.path.join(pydirac, 'libs', platform)],
 44                        extra_link_args = link_args,
 45                     )
 46
 47def get_soundtouch():
 48    sources = ['AAFilter.cpp',
 49               'FIFOSampleBuffer.cpp',
 50               'FIRFilter.cpp',
 51               'RateTransposer.cpp',
 52               'SoundTouch.cpp',
 53               'TDStretch.cpp',
 54               'BPMDetect.cpp',
 55               'PeakFinder.cpp',
 56               'mmx_optimized.cpp',
 57               'sse_optimized.cpp'
 58               ]
 59    
 60    extra_compile_args = []
 61    
 62    if is_linux or is_mac:
 63        sources += ['cpu_detect_x86_gcc.cpp']
 64        extra_compile_args=['-fcheck-new', '-O3', '-Wno-unused']
 65    else:
 66        sources += ['cpu_detect_x86_win.cpp', '3dnow_win.cpp']
 67    pysoundtouch = os.path.join('external','pysoundtouch14','libsoundtouch')
 68    lib_sources = [os.path.join(pysoundtouch, i) for i in sources]
 69    lib_sources += [os.path.join('external','pysoundtouch14','soundtouchmodule.cpp')]
 70    return Extension(   'soundtouch', 
 71                        sources = lib_sources,
 72                        extra_compile_args = extra_compile_args, 
 73                        include_dirs = [numpy.get_include(), numpy.get_numarray_include()]
 74                    )
 75
 76all_data_files = []
 77if is_mac:
 78    all_data_files  = [('/usr/local/bin',['external/en-ffmpeg/mac/en-ffmpeg','external/youtube-dl/youtube-dl'])]
 79if is_linux:
 80    all_data_files  = [('/usr/local/bin',['external/youtube-dl/youtube-dl'])]
 81if is_windows:
 82    all_data_files  = [('.',['external\\en-ffmpeg\\win\\en-ffmpeg.exe',
 83                             'external\\youtube-dl\\youtube-dl',
 84                             'external\\pydirac225\\libs\\Windows\\DiracLE.dll'])]
 85
 86
 87dest_prefix = 'echo-nest-remix-'
 88for example_dir in glob.glob(os.path.join('examples', '*')):
 89    example_files = glob.glob(os.path.join(example_dir, '*'))
 90    actual_files = []
 91    sub_path_tuples = []
 92    for example_file in example_files:
 93        files_within_example_file = glob.glob(os.path.join(example_file, '*'))
 94        if not any(files_within_example_file):
 95            actual_files.append(example_file)
 96        else:
 97            sub_path_tuples.append((dest_prefix+example_file, files_within_example_file))
 98    all_data_files.append((dest_prefix + example_dir, actual_files))
 99    if any(sub_path_tuples):
100        all_data_files.extend(sub_path_tuples)
101
102
103setup(name='The Echo Nest Remix API',
104      ext_modules = [get_soundtouch(), get_dirac(), get_action()],
105      version='1.4',
106      description='Make things with music.',
107      author='Ben Lacker',
108      author_email='blacker@echonest.com',
109      maintainer='Brian Whitman',
110      maintainer_email='brian@echonest.com',
111      url='http://developer.echonest.com/',
112      download_url='http://code.google.com/p/echo-nest-remix',
113      data_files= all_data_files,
114      package_dir={'echonest':'src/echonest', 'pyechonest':'src/pyechonest/pyechonest'},
115      packages=['echonest', 'echonest.support', 'echonest.support.midi', 'pyechonest'],
116      requires=['os',
117                'urllib',
118                'httplib',
119                'mimetypes',
120                'tempfile',
121                'commands',
122                'struct',
123                'wave',
124                'numpy',
125                'Numeric'
126                ]
127     )