2019-04-03 10:57:23 -04:00
import urllib2
import zipfile
import subprocess
import sys
import os
2021-01-06 16:09:19 -05:00
import platform
2019-04-03 10:57:23 -04:00
2021-12-28 21:45:31 -05:00
def pip_install ( * args ) :
2022-03-27 21:01:18 -04:00
print " installing " + " , " . join ( args )
2021-12-28 21:45:31 -05:00
command = [ sys . executable , " -m " , " pip " , " install " ]
command . extend ( args )
subprocess . call ( command )
2019-04-03 10:57:23 -04:00
2020-08-01 22:15:07 -04:00
pip_install ( ' requests ' )
import requests
2019-04-03 10:57:23 -04:00
print " downloading pybass "
2020-08-01 22:15:07 -04:00
filedata = urllib2 . urlopen ( ' http://master.dl.sourceforge.net/project/pybass/pybass_055.zip ' )
2019-04-03 10:57:23 -04:00
datatowrite = filedata . read ( )
with open ( ' pybass_055.zip ' , ' wb ' ) as f :
f . write ( datatowrite )
f . close ( )
print " extracting pybass "
zip_ref = zipfile . ZipFile ( ' pybass_055.zip ' , ' r ' )
zip_ref . extractall ( )
zip_ref . close ( )
print " renaming pybass.py "
2020-08-01 22:24:37 -04:00
if os . path . exists ( " pybass/__init__.py " ) : os . remove ( ' pybass/__init__.py ' )
2019-04-03 10:57:23 -04:00
os . rename ( ' pybass/pybass.py ' , ' pybass/__init__.py ' )
2021-01-06 16:09:19 -05:00
BASSZIP = " bass24.zip "
BASSDLL = " bass.dll "
BASSOPUSZIP = " bassopus24.zip "
BASSOPUSDLL = " bassopus.dll "
2025-02-14 17:39:29 -05:00
BASSFLACZIP = " bassflac24.zip "
BASSFLACDLL = " bassflac.dll "
BASSMIDIZIP = " bassmidi24.zip "
BASSMIDIDLL = " bassmidi.dll "
2021-01-06 16:09:19 -05:00
if platform . system ( ) == " Darwin " :
BASSZIP = " bass24-osx.zip "
BASSDLL = " libbass.dylib "
BASSOPUSZIP = " bassopus24-osx.zip "
BASSOPUSDLL = " libbassopus.dylib "
2025-02-14 17:39:29 -05:00
BASSFLACZIP = " bassflac24-osx.zip "
BASSFLACDLL = " libbassflac.dylib "
BASSMIDIZIP = " bassmidi24-osx.zip "
BASSMIDIDLL = " libbassmidi.dylib "
2021-01-06 16:09:19 -05:00
elif platform . system ( ) == " Linux " :
BASSZIP = " bass24-linux.zip "
BASSDLL = " libbass.so "
BASSOPUSZIP = " bassopus24-linux.zip "
BASSOPUSDLL = " libbassopus.so "
2025-02-14 17:39:29 -05:00
BASSFLACZIP = " bassflac24-linux.zip "
BASSFLACDLL = " libbassflac.so "
BASSMIDIZIP = " bassmidi24-linux.zip "
BASSMIDIDLL = " libbassmidi.so "
2021-01-06 16:09:19 -05:00
print " downloading " , BASSZIP
filedata = urllib2 . urlopen ( ' http://us.un4seen.com/files/ ' + BASSZIP )
2019-04-03 10:57:23 -04:00
datatowrite = filedata . read ( )
2021-01-06 16:09:19 -05:00
with open ( BASSZIP , ' wb ' ) as f :
2019-04-03 10:57:23 -04:00
f . write ( datatowrite )
f . close ( )
2021-01-06 16:09:19 -05:00
print " extracting " + BASSDLL + " from " + BASSZIP
zip_ref = zipfile . ZipFile ( BASSZIP , ' r ' )
zip_ref . extract ( BASSDLL )
2019-04-03 10:57:23 -04:00
zip_ref . close ( )
2021-01-06 16:09:19 -05:00
print " downloading " , BASSOPUSZIP
filedata = urllib2 . urlopen ( ' http://us.un4seen.com/files/ ' + BASSOPUSZIP )
2020-08-02 13:03:19 -04:00
datatowrite = filedata . read ( )
2021-01-06 16:09:19 -05:00
with open ( BASSOPUSZIP , ' wb ' ) as f :
2020-08-02 13:03:19 -04:00
f . write ( datatowrite )
f . close ( )
2021-01-06 16:09:19 -05:00
print " extracting " + BASSOPUSDLL + " from " + BASSOPUSZIP
zip_ref = zipfile . ZipFile ( BASSOPUSZIP , ' r ' )
zip_ref . extract ( BASSOPUSDLL )
2020-08-02 13:03:19 -04:00
zip_ref . close ( )
2025-02-14 17:39:29 -05:00
print " downloading " , BASSFLACZIP
filedata = urllib2 . urlopen ( ' http://us.un4seen.com/files/ ' + BASSFLACZIP )
datatowrite = filedata . read ( )
with open ( BASSFLACZIP , ' wb ' ) as f :
f . write ( datatowrite )
f . close ( )
print " extracting " + BASSFLACDLL + " from " + BASSFLACZIP
zip_ref = zipfile . ZipFile ( BASSFLACZIP , ' r ' )
zip_ref . extract ( BASSFLACDLL )
zip_ref . close ( )
print " downloading " , BASSMIDIZIP
filedata = urllib2 . urlopen ( ' http://us.un4seen.com/files/ ' + BASSMIDIZIP )
datatowrite = filedata . read ( )
with open ( BASSMIDIZIP , ' wb ' ) as f :
f . write ( datatowrite )
f . close ( )
print " extracting " + BASSMIDIDLL + " from " + BASSMIDIZIP
zip_ref = zipfile . ZipFile ( BASSMIDIZIP , ' r ' )
zip_ref . extract ( BASSMIDIDLL )
zip_ref . close ( )
2021-12-28 21:45:31 -05:00
pip_install ( " apng " , " six " , " appdirs " , " packaging " )
2020-08-02 13:03:19 -04:00
try :
from PIL import Image
2020-08-08 02:59:36 -04:00
if Image . __version__ != " 5.3.0 " :
jm = raw_input ( " Pillow version 5.3.0 is recommended for compatibility with AO2XP; You have version %s \n Replace with version 5.3.0? (Y/N) > " % Image . __version__ ) . lower ( )
2020-08-02 13:03:19 -04:00
if jm == " y " :
2020-08-08 02:59:36 -04:00
pip_install ( " Pillow==5.3.0 " )
2020-08-02 20:55:19 -04:00
else :
2020-08-08 02:59:36 -04:00
print " Pillow 5.3.0 already exists, skipping "
2020-08-02 13:03:19 -04:00
except ImportError :
2020-08-08 02:59:36 -04:00
pip_install ( " Pillow==5.3.0 " )
2020-08-02 13:03:19 -04:00
2021-06-22 14:21:59 -04:00
pip_install ( ' pyinstaller==3.6 ' )
2022-03-27 21:01:18 -04:00
pip_install ( " websocket-client " )
2020-08-02 13:03:19 -04:00
2021-01-06 16:09:19 -05:00
if platform . system ( ) == " Windows " :
print " downloading pyqt4 "
2021-12-28 21:45:31 -05:00
filedata = requests . get ( ' https://pypi.anaconda.org/ales-erjavec/simple/pyqt4/4.11.4/PyQt4-4.11.4-cp27-none-win32.whl ' )
2021-01-06 16:09:19 -05:00
datatowrite = filedata . content
2019-04-03 10:57:23 -04:00
2021-01-06 16:09:19 -05:00
with open ( ' PyQt4-4.11.4-cp27-cp27m-win32.whl ' , ' wb ' ) as f :
f . write ( datatowrite )
f . close ( )
2019-04-03 10:57:23 -04:00
2021-01-06 16:09:19 -05:00
print " installing pyqt4 "
pip_install ( ' PyQt4-4.11.4-cp27-cp27m-win32.whl ' )
2025-02-11 12:08:54 -05:00
raw_input ( " Press Enter to continue... " )
2020-08-01 22:15:07 -04:00
2021-01-06 16:09:19 -05:00
elif platform . system ( ) == " Darwin " :
print " installing pyobjc "
pip_install ( " pyobjc " )
2019-04-03 10:57:23 -04:00
2021-06-22 17:56:17 -04:00
try :
import Tkinter
print " for Mac OS X, use homebrew or macports to install pyqt4. "
print " brew install cartr/qt4/pyqt "
print " sudo port install py27-pyqt4 "
except : # mac doesn't have tkinter
print " for Mac OS X, use homebrew or macports to install tkinter and pyqt4. "
print " Homebrew: "
print " brew uninstall python "
print " brew install tk "
print " brew install python --with-tcl-tk "
print " brew install cartr/qt4/pyqt "
print " MacPorts: "
print " sudo port install py27-tkinter -x11 +quartz "
print " sudo port install py27-pyqt4 "
2021-01-06 16:09:19 -05:00
elif platform . system ( ) == " Linux " :
2021-06-22 17:56:17 -04:00
print " you need to install PyQt4 and tkinter on your linux distro after this "
2019-04-03 10:57:23 -04:00
print " done "