install.py 1.4 KB

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