Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Pyre path find when init Pysa #772

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions client/commands/initialize_pysa.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from pathlib import Path

from .. import log
from ..find_directories import find_taint_models_directory
from ..find_directories import find_pyre_directory

from . import commands
from .initialize import (
Expand Down Expand Up @@ -73,9 +73,8 @@ def _setup_environment() -> None:
run_infer = log.get_yes_no_input("Would you like to generate type annotations?")
if run_infer:
subprocess.run(["pyre", "infer", "-i"], check=True)
pyre_check_path = find_taint_models_directory()
if pyre_check_path and os.path.isdir(pyre_check_path / "pyre_check"):
pyre_check_path = pyre_check_path / "pyre_check"
pyre_check_path = find_pyre_directory()
if pyre_check_path is not None:
WangGithubUser marked this conversation as resolved.
Show resolved Hide resolved
LOG.info("Importing filters to sapp")
subprocess.run(["sapp", "filter", "import", pyre_check_path], check=True)
else:
Expand Down
19 changes: 15 additions & 4 deletions client/find_directories.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,20 @@ def find_typeshed_search_paths(
return search_path


def find_taint_models_directory() -> Optional[Path]:
def find_pyre_directory() -> Optional[Path]:
install_root = Path(sys.prefix)
bundled_taint_models = install_root / "lib/pyre_check/taint/"
if bundled_taint_models.is_dir():
return bundled_taint_models
excepted_pyre_path = install_root / "lib/pyre_check/"
if excepted_pyre_path.is_dir():
return excepted_pyre_path
return None


def find_taint_models_directory() -> Optional[Path]:
pyre_check_path = find_pyre_directory()
if pyre_check_path is not None:
bundled_taint_models = pyre_check_path / "taint/"
if bundled_taint_models.is_dir():
return bundled_taint_models
return None
else:
return None
WangGithubUser marked this conversation as resolved.
Show resolved Hide resolved
Loading