/setup.py

http://echo-nest-remix.googlecode.com/ · Python · 127 lines · 108 code · 16 blank · 3 comment · 25 complexity · a2a45e5e63217199e1c961210b208da2 MD5 · raw file

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