Skip to content

Commit faba72c

Browse files
committed
Add feedback
1 parent 12a8138 commit faba72c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

misc/profile_self_check.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
- The tool prints a command that can be used to analyze the profile afterwards
1212
1313
You may need to adjust kernel parameters temporarily, e.g. this (note that this has security
14-
impliciations):
14+
implications):
1515
1616
sudo sysctl kernel.perf_event_paranoid=-1
1717
@@ -37,6 +37,9 @@
3737
# to also compile CPython using similar flags, but we don't enforce it in this script.
3838
CFLAGS = "-O2 -fno-omit-frame-pointer -g"
3939

40+
# Generated files, including binaries, go under this directory to avoid overwriting user state.
41+
TARGET_DIR = "mypy.profile.tmpdir"
42+
4043

4144
def _profile_self_check(target_dir: str) -> None:
4245
cache_dir = os.path.join(target_dir, ".mypy_cache")
@@ -70,13 +73,13 @@ def check_requirements() -> None:
7073

7174
try:
7275
subprocess.run(["perf", "-h"], capture_output=True)
73-
except subprocess.CalledProcessError:
76+
except (subprocess.CalledProcessError, FileNotFoundError):
7477
print("error: The 'perf' profiler is not installed")
7578
sys.exit(1)
7679

7780
try:
7881
subprocess.run(["clang", "--version"], capture_output=True)
79-
except subprocess.CalledProcessError:
82+
except (subprocess.CalledProcessError, FileNotFoundError):
8083
print("error: The clang compiler is not installed")
8184
sys.exit(1)
8285

@@ -103,9 +106,7 @@ def main() -> None:
103106
multi_file: bool = args.multi_file
104107
skip_compile: bool = args.skip_compile
105108

106-
target_dir = "."
107-
108-
target_dir = "mypy.profile.tmpdir"
109+
target_dir = TARGET_DIR
109110

110111
if not skip_compile:
111112
clone(target_dir, "HEAD")

0 commit comments

Comments
 (0)