install.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/usr/bin/env python
  2. from __future__ import print_function
  3. from __future__ import division
  4. from __future__ import unicode_literals
  5. from __future__ import absolute_import
  6. import os
  7. import subprocess
  8. import sys
  9. import os.path as p
  10. import glob
  11. PY_MAJOR, PY_MINOR = sys.version_info[ 0 : 2 ]
  12. if not ( ( PY_MAJOR == 2 and PY_MINOR >= 6 ) or
  13. ( PY_MAJOR == 3 and PY_MINOR >= 3 ) or
  14. PY_MAJOR > 3 ):
  15. sys.exit( 'YouCompleteMe requires Python >= 2.6 or >= 3.3; '
  16. 'your version of Python is ' + sys.version )
  17. DIR_OF_THIS_SCRIPT = p.dirname( p.abspath( __file__ ) )
  18. DIR_OF_OLD_LIBS = p.join( DIR_OF_THIS_SCRIPT, 'python' )
  19. def CheckCall( args, **kwargs ):
  20. try:
  21. subprocess.check_call( args, **kwargs )
  22. except subprocess.CalledProcessError as error:
  23. sys.exit( error.returncode )
  24. def Main():
  25. build_file = p.join( DIR_OF_THIS_SCRIPT, 'third_party', 'ycmd', 'build.py' )
  26. if not p.isfile( build_file ):
  27. sys.exit(
  28. 'File {0} does not exist; you probably forgot to run:\n'
  29. '\tgit submodule update --init --recursive\n'.format( build_file ) )
  30. CheckCall( [ sys.executable, build_file ] + sys.argv[ 1: ] )
  31. # Remove old YCM libs if present so that YCM can start.
  32. old_libs = (
  33. glob.glob( p.join( DIR_OF_OLD_LIBS, '*ycm_core.*' ) ) +
  34. glob.glob( p.join( DIR_OF_OLD_LIBS, '*ycm_client_support.*' ) ) +
  35. glob.glob( p.join( DIR_OF_OLD_LIBS, '*clang*.*') ) )
  36. for lib in old_libs:
  37. os.remove( lib )
  38. if __name__ == "__main__":
  39. Main()