55ifeq ($(UNAME_S ) ,Darwin)
66 PYTHON ?= ../../python.exe
77endif
8-
8+ VENVDIR ?= ./venv
9+ VENVPYTHON ?= $(VENVDIR ) /bin/python
910CPYTHON ?= ../../Lib
1011MYPY ?= mypy
1112
@@ -27,6 +28,7 @@ peg_extension/parse.c: $(GRAMMAR) $(TOKENS) pegen/*.py peg_extension/peg_extensi
2728clean :
2829 -rm -f peg_extension/* .o peg_extension/* .so peg_extension/parse.c
2930 -rm -f data/xxl.py
31+ -rm -rf $(VENVDIR )
3032
3133dump : peg_extension/parse.c
3234 cat -n $(TESTFILE )
@@ -41,6 +43,12 @@ regen-metaparser: pegen/metagrammar.gram pegen/*.py
4143
4244.PHONY : test
4345
46+ venv :
47+ $(PYTHON ) -m venv $(VENVDIR )
48+ $(VENVPYTHON ) -m pip install -U pip setuptools
49+ $(VENVPYTHON ) -m pip install -U memory_profiler
50+ @echo " The venv has been created in the $( VENVDIR) directory"
51+
4452test : run
4553
4654run : peg_extension/parse.c
@@ -61,22 +69,22 @@ stats: peg_extension/parse.c data/xxl.py
6169
6270time : time_compile
6371
64- time_compile : peg_extension/parse.c data/xxl.py
65- $(PYTHON ) scripts/benchmark.py --parser=pegen --target=xxl compile
72+ time_compile : venv peg_extension/parse.c data/xxl.py
73+ $(VENVPYTHON ) scripts/benchmark.py --parser=pegen --target=xxl compile
6674
67- time_parse : peg_extension/parse.c data/xxl.py
68- $(PYTHON ) scripts/benchmark.py --parser=pegen --target=xxl parse
75+ time_parse : venv peg_extension/parse.c data/xxl.py
76+ $(VENVPYTHON ) scripts/benchmark.py --parser=pegen --target=xxl parse
6977
70- time_check : peg_extension/parse.c data/xxl.py
71- $(PYTHON ) scripts/benchmark.py --parser=pegen --target=xxl check
78+ time_check : venv peg_extension/parse.c data/xxl.py
79+ $(VENVPYTHON ) scripts/benchmark.py --parser=pegen --target=xxl check
7280
7381time_stdlib : time_stdlib_compile
7482
75- time_stdlib_compile : data/xxl.py
76- $(PYTHON ) scripts/benchmark.py --parser=cpython --target=xxl compile
83+ time_stdlib_compile : venv peg_extension/parse.c data/xxl.py
84+ $(VENVPYTHON ) scripts/benchmark.py --parser=cpython --target=xxl compile
7785
78- time_stdlib_parse : data/xxl.py
79- $(PYTHON ) scripts/benchmark.py --parser=cpython --target=xxl parse
86+ time_stdlib_parse : venv peg_extension/parse.c data/xxl.py
87+ $(VENVPYTHON ) scripts/benchmark.py --parser=cpython --target=xxl parse
8088
8189test_local :
8290 $(PYTHON ) scripts/test_parse_directory.py \
@@ -105,8 +113,8 @@ mypy: regen-metaparser
105113format-python :
106114 black pegen scripts
107115
108- bench :
109- $(PYTHON ) scripts/benchmark.py --parser=pegen --target=stdlib check
116+ bench : venv
117+ $(VENVPYTHON ) scripts/benchmark.py --parser=pegen --target=stdlib check
110118
111119format : format-python
112120
0 commit comments