mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
19 lines
470 B
Python
19 lines
470 B
Python
from pathlib import Path
|
|
from typing import TextIO
|
|
|
|
ROOT = Path(__file__).parent.parent.parent
|
|
DEFAULT_INPUT = (ROOT / "Python/bytecodes.c").absolute()
|
|
|
|
|
|
def root_relative_path(filename: str) -> str:
|
|
return Path(filename).relative_to(ROOT).as_posix()
|
|
|
|
|
|
def write_header(generator: str, source: str, outfile: TextIO) -> None:
|
|
outfile.write(
|
|
f"""// This file is generated by {root_relative_path(generator)}
|
|
// from:
|
|
// {source}
|
|
// Do not edit!
|
|
"""
|
|
)
|