1
0

.ycm_extra_conf.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # This file is NOT licensed under the GPLv3, which is the license for the rest
  2. # of YouCompleteMe.
  3. #
  4. # Here's the license text for this file:
  5. #
  6. # This is free and unencumbered software released into the public domain.
  7. #
  8. # Anyone is free to copy, modify, publish, use, compile, sell, or
  9. # distribute this software, either in source code form or as a compiled
  10. # binary, for any purpose, commercial or non-commercial, and by any
  11. # means.
  12. #
  13. # In jurisdictions that recognize copyright laws, the author or authors
  14. # of this software dedicate any and all copyright interest in the
  15. # software to the public domain. We make this dedication for the benefit
  16. # of the public at large and to the detriment of our heirs and
  17. # successors. We intend this dedication to be an overt act of
  18. # relinquishment in perpetuity of all present and future rights to this
  19. # software under copyright law.
  20. #
  21. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  24. # IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  25. # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  26. # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  27. # OTHER DEALINGS IN THE SOFTWARE.
  28. #
  29. # For more information, please refer to <http://unlicense.org/>
  30. import os.path as p
  31. import subprocess
  32. DIR_OF_THIS_SCRIPT = p.abspath( p.dirname( __file__ ) )
  33. DIR_OF_THIRD_PARTY = p.join( DIR_OF_THIS_SCRIPT, 'third_party' )
  34. def GetStandardLibraryIndexInSysPath( sys_path ):
  35. for index, path in enumerate( sys_path ):
  36. if p.isfile( p.join( path, 'os.py' ) ):
  37. return index
  38. raise RuntimeError( 'Could not find standard library path in Python path.' )
  39. def PythonSysPath( **kwargs ):
  40. sys_path = kwargs[ 'sys_path' ]
  41. dependencies = [ p.join( DIR_OF_THIS_SCRIPT, 'python' ),
  42. p.join( DIR_OF_THIRD_PARTY, 'requests-futures' ),
  43. p.join( DIR_OF_THIRD_PARTY, 'ycmd' ),
  44. p.join( DIR_OF_THIRD_PARTY, 'requests_deps', 'idna' ),
  45. p.join( DIR_OF_THIRD_PARTY, 'requests_deps', 'chardet' ),
  46. p.join( DIR_OF_THIRD_PARTY,
  47. 'requests_deps',
  48. 'urllib3',
  49. 'src' ),
  50. p.join( DIR_OF_THIRD_PARTY, 'requests_deps', 'certifi' ),
  51. p.join( DIR_OF_THIRD_PARTY, 'requests_deps', 'requests' ) ]
  52. # The concurrent.futures module is part of the standard library on Python 3.
  53. interpreter_path = kwargs[ 'interpreter_path' ]
  54. major_version = int( subprocess.check_output( [
  55. interpreter_path, '-c', 'import sys; print( sys.version_info[ 0 ] )' ]
  56. ).rstrip().decode( 'utf8' ) )
  57. if major_version == 2:
  58. dependencies.append( p.join( DIR_OF_THIRD_PARTY, 'pythonfutures' ) )
  59. sys_path[ 0:0 ] = dependencies
  60. sys_path.insert( GetStandardLibraryIndexInSysPath( sys_path ) + 1,
  61. p.join( DIR_OF_THIRD_PARTY, 'python-future', 'src' ) )
  62. return sys_path