1+ import os
12import subprocess
23from multilspy import SyncLanguageServer
34from pathlib import Path
@@ -20,20 +21,20 @@ def __init__(self) -> None:
2021 def add_dependencies (self , path : Path , files : list [Path ]):
2122 if Path (f"{ path } /venv" ).is_dir ():
2223 return
23- subprocess .run (["python3" , "-m" , "venv" , f" { path } / venv" ])
24+ subprocess .run (["python3" , "-m" , "venv" , " venv" ], cwd = str ( path ) )
2425 if Path (f"{ path } /pyproject.toml" ).is_file ():
25- subprocess .run ([f"{ path } /venv/bin/pip " , "install" , "poetry" ] )
26- subprocess .run ([f"{ path } /venv/bin/poetry " , "install" ] )
26+ subprocess .run (["pip" , "install" , "poetry" ], cwd = str ( path ), env = { "VIRTUAL_ENV" : f"{ path } /venv" , "PATH" : f" { path } /venv/bin: { os . environ [ 'PATH' ] } " } )
27+ subprocess .run (["poetry" , "install" ], cwd = str ( path ), env = { "VIRTUAL_ENV" : f"{ path } /venv" , "PATH" : f" { path } /venv/bin: { os . environ [ 'PATH' ] } " } )
2728 with open (f"{ path } /pyproject.toml" , 'r' ) as file :
2829 pyproject_data = toml .load (file )
2930 for requirement in pyproject_data .get ("tool" ).get ("poetry" ).get ("dependencies" ):
30- files .extend (Path (f"{ path } /venv/{ requirement } " ).rglob (" *.py" ))
31+ files .extend (Path (f"{ path } /venv/lib " ).rglob (f"**/site-packages/ { requirement } / *.py" ))
3132 elif Path (f"{ path } /requirements.txt" ).is_file ():
32- subprocess .run ([f" { path } /venv/bin/ pip" , "install" , "-r" , "requirements.txt" ])
33+ subprocess .run ([" pip" , "install" , "-r" , "requirements.txt" ], cwd = str ( path ), env = { "VIRTUAL_ENV" : f" { path } /venv" , "PATH" : f" { path } /venv/bin: { os . environ [ 'PATH' ] } " } )
3334 with open (f"{ path } /requirements.txt" , 'r' ) as file :
3435 requirements = [line .strip ().split ("==" ) for line in file if line .strip ()]
3536 for requirement in requirements :
36- files .extend (Path (f"{ path } /venv/{ requirement } " ).rglob (" *.py" ))
37+ files .extend (Path (f"{ path } /venv/lib/ " ).rglob (f"**/site-packages/ { requirement } / *.py" ))
3738
3839 def get_entity_label (self , node : Node ) -> str :
3940 if node .type == 'class_definition' :
0 commit comments