Auto merge of #3266 - micbou:fix-run_tests-dependencies, r=micbou

[READY] Fix run_tests.py dependencies

The dependencies are now explicitly added to `PYTHONPATH` in the `run_tests.py` script. Adding the `argparse` module to `sys.path` is not needed anymore.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/3266)
<!-- Reviewable:end -->
This commit is contained in:
zzbot 2018-12-11 16:59:43 -08:00 committed by GitHub
commit 0790dc99b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,40 +1,37 @@
#!/usr/bin/env python #!/usr/bin/env python
import os import argparse
import subprocess
import os.path as p
import glob import glob
import os
import os.path as p
import subprocess
import sys import sys
DIR_OF_THIS_SCRIPT = p.dirname( p.abspath( __file__ ) ) DIR_OF_THIS_SCRIPT = p.dirname( p.abspath( __file__ ) )
DIR_OF_THIRD_PARTY = p.join( DIR_OF_THIS_SCRIPT, 'third_party' ) DIR_OF_THIRD_PARTY = p.join( DIR_OF_THIS_SCRIPT, 'third_party' )
DIR_OF_YCMD_THIRD_PARTY = p.join( DIR_OF_THIRD_PARTY, 'ycmd', 'third_party' )
python_path = [] # We don't include python-future (not to be confused with pythonfutures) because
for folder in os.listdir( DIR_OF_THIRD_PARTY ): # it needs to be inserted in sys.path AFTER the standard library imports but we
python_path.append( p.abspath( p.join( DIR_OF_THIRD_PARTY, folder ) ) ) # can't do that with PYTHONPATH because the std lib paths are always appended to
for folder in os.listdir( DIR_OF_YCMD_THIRD_PARTY ): # PYTHONPATH. We do it correctly inside Vim because we have access to the right
# We skip python-future because it needs to be inserted in sys.path AFTER # sys.path. So for dev, we rely on python-future being installed correctly with
# the standard library imports but we can't do that with PYTHONPATH because #
# the std lib paths are always appended to PYTHONPATH. We do it correctly in # pip install -r python/test_requirements.txt
# prod in ycmd/utils.py because we have access to the right sys.path. #
# So for dev, we rely on python-future being installed correctly with # Pip knows how to install this correctly so that it doesn't matter where in
# pip install -r test_requirements.txt # sys.path the path is.
# python_path = [ p.join( DIR_OF_THIRD_PARTY, 'pythonfutures' ),
# Pip knows how to install this correctly so that it doesn't matter where in p.join( DIR_OF_THIRD_PARTY, 'requests-futures' ),
# sys.path the path is. p.join( DIR_OF_THIRD_PARTY, 'requests_deps', 'chardet' ),
if folder == 'python-future': p.join( DIR_OF_THIRD_PARTY, 'requests_deps', 'certifi' ),
continue p.join( DIR_OF_THIRD_PARTY, 'requests_deps', 'idna' ),
python_path.append( p.abspath( p.join( DIR_OF_YCMD_THIRD_PARTY, folder ) ) ) p.join( DIR_OF_THIRD_PARTY, 'requests_deps', 'requests' ),
p.join( DIR_OF_THIRD_PARTY, 'requests_deps', 'urllib3', 'src' ),
p.join( DIR_OF_THIRD_PARTY, 'ycmd' ) ]
if os.environ.get( 'PYTHONPATH' ): if os.environ.get( 'PYTHONPATH' ):
python_path.append( os.environ[ 'PYTHONPATH' ] ) python_path.append( os.environ[ 'PYTHONPATH' ] )
os.environ[ 'PYTHONPATH' ] = os.pathsep.join( python_path ) os.environ[ 'PYTHONPATH' ] = os.pathsep.join( python_path )
sys.path.insert( 1, p.abspath( p.join( DIR_OF_YCMD_THIRD_PARTY,
'argparse' ) ) )
import argparse
def RunFlake8(): def RunFlake8():
print( 'Running flake8' ) print( 'Running flake8' )