Skip to content

Commit a04ac1a

Browse files
committed
fix direct dipendency
1 parent 9b4f0c7 commit a04ac1a

File tree

3 files changed

+44
-30
lines changed

3 files changed

+44
-30
lines changed

api/analyzers/python/analyzer.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import subprocess
23
from multilspy import SyncLanguageServer
34
from 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':

poetry.lock

Lines changed: 36 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ python-dotenv = "^1.0.1"
1919
multilspy = {git = "https://github.com/AviAvni/multilspy.git", rev = "python-init-params"}
2020
javatools = "^1.6.0"
2121
pygit2 = "^1.17.0"
22+
toml = "^0.10.2"
2223

2324
[tool.poetry.group.test.dependencies]
2425
pytest = "^8.2.0"

0 commit comments

Comments
 (0)