mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-97669: Create Tools/build/ directory (#97963)
Create Tools/build/ directory. Move the following scripts from Tools/scripts/ to Tools/build/: * check_extension_modules.py * deepfreeze.py * freeze_modules.py * generate_global_objects.py * generate_levenshtein_examples.py * generate_opcode_h.py * generate_re_casefix.py * generate_sre_constants.py * generate_stdlib_module_names.py * generate_token.py * parse_html5_entities.py * smelly.py * stable_abi.py * umarshal.py * update_file.py * verify_ensurepip_wheels.py Update references to these scripts.
This commit is contained in:
parent
eae7dad402
commit
1863302d61
41 changed files with 102 additions and 84 deletions
|
@ -581,7 +581,7 @@ def regen_makefile(modules):
|
|||
frozenfiles = []
|
||||
rules = ['']
|
||||
deepfreezerules = ["Python/deepfreeze/deepfreeze.c: $(DEEPFREEZE_DEPS)",
|
||||
"\t$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py \\"]
|
||||
"\t$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/build/deepfreeze.py \\"]
|
||||
for src in _iter_sources(modules):
|
||||
frozen_header = relpath_for_posix_display(src.frozenfile, ROOT_DIR)
|
||||
frozenfiles.append(f'\t\t{frozen_header} \\')
|
||||
|
@ -646,7 +646,7 @@ def regen_pcbuild(modules):
|
|||
projlines = []
|
||||
filterlines = []
|
||||
corelines = []
|
||||
deepfreezerules = ['\t<Exec Command=\'$(PythonForBuild) "$(PySourcePath)Tools\\scripts\\deepfreeze.py" ^']
|
||||
deepfreezerules = ['\t<Exec Command=\'$(PythonForBuild) "$(PySourcePath)Tools\\build\\deepfreeze.py" ^']
|
||||
for src in _iter_sources(modules):
|
||||
pyfile = relpath_for_windows_display(src.pyfile, ROOT_DIR)
|
||||
header = relpath_for_windows_display(src.frozenfile, ROOT_DIR)
|
|
@ -3,6 +3,7 @@ import io
|
|||
import os.path
|
||||
import re
|
||||
|
||||
SCRIPT_NAME = 'Tools/build/generate_global_objects.py'
|
||||
__file__ = os.path.abspath(__file__)
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
|
||||
INTERNAL = os.path.join(ROOT, 'Include', 'internal')
|
||||
|
@ -213,7 +214,7 @@ def open_for_changes(filename, orig):
|
|||
#######################################
|
||||
# the global objects
|
||||
|
||||
START = '/* The following is auto-generated by Tools/scripts/generate_global_objects.py. */'
|
||||
START = f'/* The following is auto-generated by {SCRIPT_NAME}. */'
|
||||
END = '/* End auto-generated code */'
|
||||
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
import sys
|
||||
import tokenize
|
||||
|
||||
SCRIPT_NAME = "Tools/scripts/generate_opcode_h.py"
|
||||
SCRIPT_NAME = "Tools/build/generate_opcode_h.py"
|
||||
PYTHON_OPCODE = "Lib/opcode.py"
|
||||
|
||||
header = f"""
|
|
@ -5,6 +5,8 @@ import collections
|
|||
import sys
|
||||
import unicodedata
|
||||
|
||||
SCRIPT_NAME = 'Tools/build/generate_re_casefix.py'
|
||||
|
||||
def update_file(file, content):
|
||||
try:
|
||||
with open(file, 'r', encoding='utf-8') as fobj:
|
||||
|
@ -16,8 +18,8 @@ def update_file(file, content):
|
|||
fobj.write(content)
|
||||
return True
|
||||
|
||||
re_casefix_template = """\
|
||||
# Auto-generated by Tools/scripts/generate_re_casefix.py.
|
||||
re_casefix_template = f"""\
|
||||
# Auto-generated by {SCRIPT_NAME}.
|
||||
|
||||
# Maps the code of lowercased character to codes of different lowercased
|
||||
# characters which have the same uppercase.
|
|
@ -1,6 +1,8 @@
|
|||
#! /usr/bin/env python3
|
||||
# This script generates Modules/_sre/sre_constants.h from Lib/re/_constants.py.
|
||||
|
||||
SCRIPT_NAME = 'Tools/build/generate_sre_constants.py'
|
||||
|
||||
|
||||
def update_file(file, content):
|
||||
try:
|
||||
|
@ -13,13 +15,13 @@ def update_file(file, content):
|
|||
fobj.write(content)
|
||||
return True
|
||||
|
||||
sre_constants_header = """\
|
||||
sre_constants_header = f"""\
|
||||
/*
|
||||
* Secret Labs' Regular Expression Engine
|
||||
*
|
||||
* regular expression matching engine
|
||||
*
|
||||
* Auto-generated by Tools/scripts/generate_sre_constants.py from
|
||||
* Auto-generated by {SCRIPT_NAME} from
|
||||
* Lib/re/_constants.py.
|
||||
*
|
||||
* Copyright (c) 1997-2001 by Secret Labs AB. All rights reserved.
|
|
@ -10,6 +10,8 @@ import sysconfig
|
|||
from check_extension_modules import ModuleChecker
|
||||
|
||||
|
||||
SCRIPT_NAME = 'Tools/build/generate_stdlib_module_names.py'
|
||||
|
||||
SRC_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
|
||||
STDLIB_PATH = os.path.join(SRC_DIR, 'Lib')
|
||||
|
||||
|
@ -112,7 +114,7 @@ def list_modules():
|
|||
|
||||
|
||||
def write_modules(fp, names):
|
||||
print("// Auto-generated by Tools/scripts/generate_stdlib_module_names.py.",
|
||||
print(f"// Auto-generated by {SCRIPT_NAME}.",
|
||||
file=fp)
|
||||
print("// List used to create sys.stdlib_module_names.", file=fp)
|
||||
print(file=fp)
|
|
@ -7,6 +7,8 @@
|
|||
# Lib/token.py
|
||||
|
||||
|
||||
SCRIPT_NAME = 'Tools/build/generate_token.py'
|
||||
AUTO_GENERATED_BY_SCRIPT = f'Auto-generated by {SCRIPT_NAME}'
|
||||
NT_OFFSET = 256
|
||||
|
||||
def load_tokens(path):
|
||||
|
@ -47,8 +49,10 @@ def update_file(file, content):
|
|||
return True
|
||||
|
||||
|
||||
token_h_template = """\
|
||||
/* Auto-generated by Tools/scripts/generate_token.py */
|
||||
token_h_template = f"""\
|
||||
/* {AUTO_GENERATED_BY_SCRIPT} */
|
||||
"""
|
||||
token_h_template += """\
|
||||
|
||||
/* Token types */
|
||||
#ifndef Py_INTERNAL_TOKEN_H
|
||||
|
@ -105,8 +109,10 @@ def make_h(infile, outfile='Include/internal/pycore_token.h'):
|
|||
print("%s regenerated from %s" % (outfile, infile))
|
||||
|
||||
|
||||
token_c_template = """\
|
||||
/* Auto-generated by Tools/scripts/generate_token.py */
|
||||
token_c_template = f"""\
|
||||
/* {AUTO_GENERATED_BY_SCRIPT} */
|
||||
"""
|
||||
token_c_template += """\
|
||||
|
||||
#include "Python.h"
|
||||
#include "pycore_token.h"
|
||||
|
@ -189,8 +195,8 @@ def make_c(infile, outfile='Parser/token.c'):
|
|||
print("%s regenerated from %s" % (outfile, infile))
|
||||
|
||||
|
||||
token_inc_template = """\
|
||||
.. Auto-generated by Tools/scripts/generate_token.py
|
||||
token_inc_template = f"""\
|
||||
.. {AUTO_GENERATED_BY_SCRIPT}
|
||||
%s
|
||||
.. data:: N_TOKENS
|
||||
|
||||
|
@ -213,10 +219,11 @@ def make_rst(infile, outfile='Doc/library/token-list.inc'):
|
|||
print("%s regenerated from %s" % (outfile, infile))
|
||||
|
||||
|
||||
token_py_template = '''\
|
||||
token_py_template = f'''\
|
||||
"""Token constants."""
|
||||
# Auto-generated by Tools/scripts/generate_token.py
|
||||
|
||||
# {AUTO_GENERATED_BY_SCRIPT}
|
||||
'''
|
||||
token_py_template += '''
|
||||
__all__ = ['tok_name', 'ISTERMINAL', 'ISNONTERMINAL', 'ISEOF']
|
||||
|
||||
%s
|
|
@ -18,6 +18,7 @@ import json
|
|||
from urllib.request import urlopen
|
||||
from html.entities import html5
|
||||
|
||||
SCRIPT_NAME = 'Tools/build/parse_html5_entities.py'
|
||||
PAGE_URL = 'https://html.spec.whatwg.org/multipage/named-characters.html'
|
||||
ENTITIES_URL = 'https://html.spec.whatwg.org/entities.json'
|
||||
HTML5_SECTION_START = '# HTML5 named character references'
|
||||
|
@ -69,7 +70,7 @@ def write_items(entities, file=sys.stdout):
|
|||
keys = sorted(entities.keys())
|
||||
keys = sorted(keys, key=str.lower)
|
||||
print(HTML5_SECTION_START, file=file)
|
||||
print(f'# Generated by {sys.argv[0]!r}\n'
|
||||
print(f'# Generated by {SCRIPT_NAME}\n'
|
||||
f'# from {ENTITIES_URL} and\n'
|
||||
f'# {PAGE_URL}.\n'
|
||||
f'# Map HTML5 named character references to the '
|
11
Tools/scripts/stable_abi.py → Tools/build/stable_abi.py
Executable file → Normal file
11
Tools/scripts/stable_abi.py → Tools/build/stable_abi.py
Executable file → Normal file
|
@ -24,6 +24,7 @@ import io
|
|||
import re
|
||||
import csv
|
||||
|
||||
SCRIPT_NAME = 'Tools/build/stable_abi.py'
|
||||
MISSING = object()
|
||||
|
||||
EXCLUDED_HEADERS = {
|
||||
|
@ -182,11 +183,12 @@ def generator(var_name, default_path):
|
|||
def gen_python3dll(manifest, args, outfile):
|
||||
"""Generate/check the source for the Windows stable ABI library"""
|
||||
write = partial(print, file=outfile)
|
||||
write(textwrap.dedent(r"""
|
||||
content = f"""
|
||||
/* Re-export stable Python ABI */
|
||||
|
||||
/* Generated by Tools/scripts/stable_abi.py */
|
||||
|
||||
/* Generated by {SCRIPT_NAME} */
|
||||
"""
|
||||
content += r"""
|
||||
#ifdef _M_IX86
|
||||
#define DECORATE "_"
|
||||
#else
|
||||
|
@ -197,7 +199,8 @@ def gen_python3dll(manifest, args, outfile):
|
|||
__pragma(comment(linker, "/EXPORT:" DECORATE #name "=" PYTHON_DLL_NAME "." #name))
|
||||
#define EXPORT_DATA(name) \
|
||||
__pragma(comment(linker, "/EXPORT:" DECORATE #name "=" PYTHON_DLL_NAME "." #name ",DATA"))
|
||||
"""))
|
||||
"""
|
||||
write(textwrap.dedent(content))
|
||||
|
||||
def sort_key(item):
|
||||
return item.name.lower()
|
Loading…
Add table
Add a link
Reference in a new issue