1import sys 2import os 3import logging 4 5from distutils.core import setup, Command 6from distutils.extension import Extension 7try: 8 from Cython.Distutils import build_ext 9except ImportError: 10 logging.warn("Cython is preferred over pyrex for python3 compatibility.") 11 from Pyrex.Distutils import build_ext 12 13 14 15 16 17DESCRIPTION = open('README_PYTHON.txt').read() 18CHANGES = open('CHANGES.txt').read() 19TODO = open('TODO.txt').read() 20 21EXTRAS = {} 22 23long_description = DESCRIPTION + CHANGES + TODO 24#import sys 25#if "checkdocs" in sys.argv: 26# print long_description 27 28 29METADATA = { 30 'name': 'pyportmidi', 31 'version': '0.0.7', 32 'license': 'MIT License', 33 'url': 'http://pypi.python.org/pyportmidi/', 34 'author': 'John Harrison, Roger B. Dannenberg, Rene Dudfield, others...', 35 'author_email': 'renesd@gmail.com', 36 'maintainer': 'Rene Dudfield', 37 'maintainer_email': 'renesd@gmail.com', 38 'description': 'Python Wrappings for PortMidi #python. CHANGES: new package layout.', 39 'long_description': long_description, 40 'classifiers': [ 41 'Development Status :: 2 - Pre-Alpha', 42 'Intended Audience :: Developers', 43 'Intended Audience :: Information Technology', 44 'License :: OSI Approved :: BSD License', 45 'Operating System :: MacOS :: MacOS X', 46 'Operating System :: Microsoft :: Windows', 47 'Operating System :: POSIX :: Linux', 48 'Programming Language :: Cython', 49 'Programming Language :: C', 50 'Programming Language :: Python :: 2', 51 'Programming Language :: Python :: 2.5', 52 'Programming Language :: Python :: 2.6', 53 'Programming Language :: Python :: 2.7', 54 'Programming Language :: Python :: 3', 55 'Programming Language :: Python :: 3.0', 56 'Programming Language :: Python :: 3.1', 57 'Programming Language :: Python :: 3.2', 58 'Topic :: Multimedia :: Sound/Audio :: MIDI', 59 'Topic :: Software Development :: Libraries', 60 ], 61} 62 63 64if "bdist_msi" in sys.argv: 65 # hack the version name to a format msi doesn't have trouble with 66 METADATA["version"] = METADATA["version"].replace("pre", "a0") 67 METADATA["version"] = METADATA["version"].replace("rc", "b0") 68 METADATA["version"] = METADATA["version"].replace("release", "") 69 70 71 72 73 74# allow optionally using setuptools for bdist_egg. 75using_setuptools = False 76 77if "-setuptools" in sys.argv: 78 using_setuptools = True 79 80 from setuptools import setup, Command 81 sys.argv.remove ("-setuptools") 82 83 EXTRAS.update({'include_package_data': True, 84 'install_requires': [], 85 'zip_safe': False, 86 'test_suite' : 'pyportmidi.tests', 87 } 88 ) 89 90 91# test command. For doing 'python setup.py test' 92class TestCommand(Command): 93 user_options = [ ] 94 95 def initialize_options(self): 96 self._dir = os.getcwd() 97 98 def finalize_options(self): 99 pass 100 101 def run(self): 102 ''' 103 runs the tests with default options. 104 ''' 105 import pyportmidi.tests 106 pyportmidi.tests.main() 107 108 #import subprocess 109 #return subprocess.call([sys.executable, "run_tests.py"]) 110 111 112cmdclass = {'build_ext': build_ext} 113 114# we use our test command. 115if not using_setuptools: 116 import os 117 cmdclass['test'] = TestCommand 118 119 120 121scripts = [] 122 123PACKAGEDATA = { 124 'cmdclass': cmdclass, 125 126 'package_dir': {'pyportmidi': 'pyportmidi', 127 #'pyportmidi.tests': 'test', 128 #'pyportmidi.docs': 'docs', 129 #'pyportmidi.examples': 'examples', 130 131 }, 132 'packages': ['pyportmidi', 133 'pyportmidi.tests', 134 ], 135 'scripts': scripts, 136} 137 138 139PACKAGEDATA.update(METADATA) 140PACKAGEDATA.update(EXTRAS) 141 142 143 144if sys.platform == 'win32': 145 print "Found Win32 platform" 146 EXTENSION = dict( 147 ext_modules=[ 148 Extension("pyportmidi._pyportmidi", [os.path.join("pyportmidi", "_pyportmidi.pyx")], 149 library_dirs = ["../Release"], 150 libraries = ["portmidi", "winmm"], 151 include_dirs = ["../porttime"], 152# define_macros = [("_WIN32_", None)]) # needed by portmidi.h 153 extra_compile_args = ["/DWIN32"]) # needed by portmidi.h 154 ] 155 ) 156elif sys.platform == 'darwin': 157 print "Found darwin (OS X) platform" 158 library_dirs = ["/usr/local/lib"] 159 include_dirs = ["/usr/local/include"] 160 EXTENSION = dict( 161 ext_modules=[ 162 Extension("pyportmidi._pyportmidi", [os.path.join("pyportmidi", "_pyportmidi.pyx")], 163 library_dirs = library_dirs, 164 include_dirs = include_dirs, 165 libraries = ["portmidi"], 166 extra_link_args=["-framework", "CoreFoundation", 167 "-framework", "CoreMIDI", 168 "-framework", "CoreAudio"]) 169 ] 170 ) 171else: 172 print "Assuming Linux platform" 173 EXTENSION = dict( 174 ext_modules=[ 175 Extension("pyportmidi._pyportmidi", [os.path.join("pyportmidi", "_pyportmidi.pyx")], 176 library_dirs=["./linux"], 177 libraries = ["portmidi", "asound", "pthread"] 178 ) 179 ] 180 181 ) 182 183PACKAGEDATA.update(EXTENSION) 184 185setup(**PACKAGEDATA) 186