X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=dependencies%2Fdependencies.py;fp=dependencies%2Fdependencies.py;h=0000000000000000000000000000000000000000;hb=2e142df11d6f312a2a2b5097b8da73571ed523e8;hp=c2323802ff14747d671a470d2ff015c11426bdf7;hpb=61b3659afe961ed248f30e26f9ca8f28fcfafddc;p=cpPlugins.git diff --git a/dependencies/dependencies.py b/dependencies/dependencies.py deleted file mode 100644 index c232380..0000000 --- a/dependencies/dependencies.py +++ /dev/null @@ -1,328 +0,0 @@ -import errno, glob, os, math, mimetypes, multiprocessing -import platform, readline, tarfile -from distutils import spawn - -## ------------------------ -## -- Create directories -- -## ------------------------ - -def create_dir( path ): - try: - os.makedirs(path) - except OSError as exception: - if exception.errno != errno.EEXIST: - raise - # yrt -# fed - -## ------------------------ -## -- Filename completer -- -## ------------------------ - -def filename_completer( text, state ): - return ( glob.glob( text + '*' ) + [ None ] )[ state ] -# fed - -def get_filepath( message ): - readline.set_completer_delims( ' \t\n;' ) - readline.parse_and_bind( "tab: complete" ) - readline.set_completer( filename_completer ) - return os.path.abspath( raw_input( message ) ) -# fed - -## ---------------- -## -- Find paths -- -## ---------------- - -def find_paths( locs, progs ): - paths = [] - for prog in progs: - for loc in locs: - path = spawn.find_executable( loc + "/" + prog ) - if path <> None: - paths.append( path ) - # rof - # rof - return paths -# def - -## ------------------------------ -## -- Extract compressed files -- -## ------------------------------ - -def extract( src ): - tar_gz_type = ( "application/x-tar", "gzip" ) - src_type = mimetypes.guess_type( src ) - print( "Extracting " + src + ": " ) - if src_type == tar_gz_type: - src_dir = os.path.splitext( src )[ 0 ] - src_file = tarfile.open( src, "r|gz" ) - src_file.extractall( src_dir ) - src_file.close( ) - #elif src_type == tar_bz2_type: - #elif src_type == zip_type: - #else: - # fi - print( " done!" ) - return src_dir - -## ------------------- -## -- Choose config -- -## ------------------- - -def choose_config( paths, name ): - print( "Please choose one configuration for " + name + ":" ) - for i in range( len( paths ) ): - print( "\t" + str( i ) + ": " + paths[ i ] ) - # rof - print( "\t" + str( len( paths ) + 0 ) + ": Give another installation." ) - print( "\t" + str( len( paths ) + 1 ) + ": Build from scratch." ) - opt = -1 - while opt == -1: - opt = int( raw_input( "\t---> " ) ) - if opt < 0 or opt > len( paths ) + 1: - qmake_opt = -1 - # fi - # elihw - return opt -# def - -## -------------------- -## -- Some variables -- -## -------------------- - -home_dir = os.environ[ "HOME" ] -process_count = str( multiprocessing.cpu_count( ) / 2 ) - -## ----------------------------------------------- -## -- qmake and cmake locations and executables -- -## ----------------------------------------------- - -locations = [] -qmake_progs = [] -cmake_progs = [] -if platform.system( ) == "Linux": - locations = [ - "/usr/bin", - "/usr/local/bin", - home_dir + "/bin", - home_dir + "/local/bin" - ] - qmake_progs = [ "qmake", "qmake-qt4" ] - cmake_progs = [ "cmake" ] -# fi -qmake_paths = find_paths( locations, qmake_progs ) -cmake_paths = find_paths( locations, cmake_progs ) - -qmake_opt = choose_config( qmake_paths, "Qt4" ) -qmake_src = None -if qmake_opt == len( qmake_paths ): - qmake_exec = get_filepath( "Choose your own Qt4 installation: " ) - while not os.path.isfile( qmake_exec ): - qmake_exec = get_filepath( "Choose your own Qt4 installation: " ) - # elihw -elif qmake_opt == len( qmake_paths ) + 1: - qmake_src = get_filepath( "Choose your own Qt4 source file: " ) - while not os.path.isfile( qmake_src ): - qmake_src = get_filepath( "Choose your own Qt4 source file: " ) - # elihw -else: - qmake_exec = qmake_paths[ qmake_opt ] -# fi - -cmake_opt = choose_config( cmake_paths, "CMake" ) -cmake_src = None -if cmake_opt == len( cmake_paths ): - cmake_exec = get_filepath( "Choose your own CMake installation: " ) - while not os.path.isfile( cmake_exec ): - cmake_exec = get_filepath( "Choose your own CMake installation: " ) - # elihw -elif cmake_opt == len( cmake_paths ) + 1: - cmake_src = get_filepath( "Choose your own CMake source file: " ) - while not os.path.isfile( cmake_src ): - cmake_src = get_filepath( "Choose your own CMake source file: " ) - # elihw -else: - cmake_exec = cmake_paths[ cmake_opt ] -# fi - -## ----------------------- -## -- ITK and VTK files -- -## ----------------------- - -itk_src = get_filepath( "Choose your own ITK source file: " ) -while not os.path.isfile( itk_src ): - itk_src = get_filepath( "Choose your own ITK source file: " ) -# elihw -itk_extra = raw_input( "Type an extra configurations for ITK:" ) - -vtk_src = get_filepath( "Choose your own VTK source file: " ) -while not os.path.isfile( vtk_src ): - vtk_src = get_filepath( "Choose your own VTK source file: " ) -# elihw -vtk_extra = raw_input( "Type an extra configurations for VTK:" ) - -## ------------------------ -## -- More configuration -- -## ------------------------ - -install_prefix = get_filepath( "Choose your installation prefix: " ) -build_type = raw_input( "Type your build type [(r)elease/(d)ebug]: " ) -build_type.lower( ) -qmake_full = "n" -if qmake_src <> None: - qmake_full = raw_input( "Would you like a full Qt4 install [y/n]? " ) - qmake_full.lower( ) -# fi -qmake_build_type = "release" -kitware_build_type = "MinSizeRel" -if build_type[ 0 ] == "d": - qmake_build_type = "debug" - kitware_build_type = "Debug" -# fi - -## ----------------- -## -- Compile Qt4 -- -## ----------------- - -if qmake_src <> None: - qmake_src_dir = extract( qmake_src ) - qmake_bin_dir = qmake_src_dir + "-build" - min_size = 999999 - qmake_configure = "" - for root, dirs, files in os.walk( qmake_src_dir ): - if "configure" in files: - path = os.path.join( root, "configure" ) - if min_size > len( path ): - min_size = len( path ) - qmake_configure = path - # fi - # fi - # rof - create_dir( qmake_bin_dir ) - - # particular_options=-no-framework - particular_options = "" - - command = "cd " + qmake_bin_dir + " && " - command += qmake_configure - command += " -prefix " + install_prefix - command += " -" + qmake_build_type - command += " -opensource -shared -fast -no-webkit -optimized-qmake" - command += " -confirm-license" - if qmake_full == "y": - command += " -no-phonon -no-phonon-backend -no-openvg" - command += " -nomake demos -nomake examples" - # fi - command += particular_options - command += " && make -j" + process_count - command += " && make -j install" - os.system( command ) - qmake_exec = find_paths( [ install_prefix ], [ "qmake" ] )[ 0 ] -# fi - -## ------------------- -## -- Compile CMake -- -## ------------------- - -if cmake_src <> None: - cmake_src_dir = extract( cmake_src ) - cmake_bin_dir = cmake_src_dir + "-build" - min_size = 999999 - cmake_configure = "" - for root, dirs, files in os.walk( cmake_src_dir ): - if "bootstrap" in files: - path = os.path.join( root, "bootstrap" ) - if min_size > len( path ): - min_size = len( path ) - cmake_configure = path - # fi - # fi - # rof - create_dir( cmake_bin_dir ) - - command = "cd " + cmake_bin_dir + " && " - command += cmake_configure - command += " --prefix " + install_prefix - command += " --qt-gui --qt-qmake=" + qmake_exec - command += " && make -j" + process_count - command += " && make -j install" - os.system( command ) - cmake_exec = find_paths( [ install_prefix ], [ "cmake" ] )[ 0 ] -# fi - -## ----------------- -## -- Compile ITK -- -## ----------------- - -itk_src_dir = extract( itk_src ) -itk_bin_dir = itk_src_dir + "-build" -min_size = 999999 -itk_configure = "" -for root, dirs, files in os.walk( itk_src_dir ): - if "CMakeLists.txt" in files: - path = os.path.join( root, "CMakeLists.txt" ) - if min_size > len( path ): - min_size = len( path ) - itk_configure = path - # fi - # fi -# rof -create_dir( itk_bin_dir ) - -command = "cd " + itk_bin_dir + " && " -command += cmake_exec -command += " -DCMAKE_CXX_FLAGS:STRING=-std=c++11" -command += " -DBUILD_DOCUMENTATION:BOOL=OFF" -command += " -DBUILD_EXAMPLES:BOOL=OFF" -command += " -DBUILD_SHARED_LIBS:BOOL=ON" -command += " -DBUILD_TESTING:BOOL=OFF" -command += " -DModule_ITKReview:BOOL=ON" -command += " -DModule_ITKVtkGlue:BOOL=OFF" -command += " -DModule_ParabolicMorphology:BOOL=ON" -command += " -DCMAKE_BUILD_TYPE:STRING=" + kitware_build_type -command += " -DCMAKE_INSTALL_PREFIX:PATH=" + install_prefix -command += " " + itk_src_dir -command += " && make -j" + process_count -command += " && make -j install" -os.system( command ) - -## ----------------- -## -- Compile VTK -- -## ----------------- - -vtk_src_dir = extract( vtk_src ) -vtk_bin_dir = vtk_src_dir + "-build" -min_size = 999999 -vtk_configure = "" -for root, dirs, files in os.walk( vtk_src_dir ): - if "CMakeLists.txt" in files: - path = os.path.join( root, "CMakeLists.txt" ) - if min_size > len( path ): - min_size = len( path ) - vtk_configure = path - # fi - # fi -# rof -create_dir( vtk_bin_dir ) - -command = "cd " + vtk_bin_dir + " && " -command += cmake_exec -command += " -DCMAKE_CXX_FLAGS:STRING=-std=c++11" -command += " -DBUILD_DOCUMENTATION:BOOL=OFF" -command += " -DBUILD_EXAMPLES:BOOL=OFF" -command += " -DBUILD_SHARED_LIBS:BOOL=ON" -command += " -DBUILD_TESTING:BOOL=OFF" -command += " -DModule_vtkGUISupportQt:BOOL=ON" -command += " -DModule_vtkGUISupportQtOpenGL:BOOL=ON" -command += " -DModule_vtkGUISupportQtSQL:BOOL=OFF" -command += " -DModule_vtkGUISupportQtWebkit:BOOL=OFF" -command += " -DQT_QMAKE_EXECUTABLE:PATH=" + qmake_exec -command += " -DCMAKE_BUILD_TYPE:STRING=" + kitware_build_type -command += " -DCMAKE_INSTALL_PREFIX:PATH=" + install_prefix -command += " " + vtk_src_dir -command += " && make -j" + process_count -command += " && make -j install" -os.system( command ) - -## eof - $RCSfile$