Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 50f28de

Browse files
authored
bpo-40334: Allow to run make regen-pegen without distutils (GH-19684)
1 parent 3e89251 commit 50f28de

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

Tools/peg_generator/pegen/__main__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
import token
1212
import traceback
1313

14-
from typing import Final
15-
16-
from pegen.build import build_parser_and_generator
17-
from pegen.testutil import print_memstats
18-
1914

2015
argparser = argparse.ArgumentParser(
2116
prog="pegen", description="Experimental PEG-like parser generator"
@@ -52,6 +47,9 @@
5247

5348

5449
def main() -> None:
50+
from pegen.build import build_parser_and_generator
51+
from pegen.testutil import print_memstats
52+
5553
args = argparser.parse_args()
5654
verbose = args.verbose
5755
verbose_tokenizer = verbose >= 3
@@ -133,4 +131,7 @@ def main() -> None:
133131

134132

135133
if __name__ == "__main__":
134+
if sys.version_info < (3, 8):
135+
print("ERROR: using pegen requires at least Python 3.8!", file=sys.stderr)
136+
sys.exit(1)
136137
main()

Tools/peg_generator/pegen/build.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66

77
from typing import Optional, Tuple
88

9-
import distutils.log
10-
from distutils.core import Distribution, Extension
11-
from distutils.command.clean import clean # type: ignore
12-
from distutils.command.build_ext import build_ext # type: ignore
13-
from distutils.tests.support import fixup_build_ext
14-
159
from pegen.c_generator import CParserGenerator
1610
from pegen.grammar import Grammar
1711
from pegen.grammar_parser import GeneratedParser as GrammarParser
@@ -47,6 +41,12 @@ def compile_c_extension(
4741
If *build_dir* is provided, that path will be used as the temporary build directory
4842
of distutils (this is useful in case you want to use a temporary directory).
4943
"""
44+
import distutils.log
45+
from distutils.core import Distribution, Extension
46+
from distutils.command.clean import clean # type: ignore
47+
from distutils.command.build_ext import build_ext # type: ignore
48+
from distutils.tests.support import fixup_build_ext
49+
5050
if verbose:
5151
distutils.log.set_verbosity(distutils.log.DEBUG)
5252

0 commit comments

Comments
 (0)