Skip to content

PCBuild needs an analog of make regen-cases #104055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
arhadthedev opened this issue May 1, 2023 · 1 comment
Open

PCBuild needs an analog of make regen-cases #104055

arhadthedev opened this issue May 1, 2023 · 1 comment
Labels
3.13 bugs and security fixes build The build process and cross-build OS-windows type-feature A feature request or enhancement

Comments

@arhadthedev
Copy link
Member

Feature or enhancement

Windows developers need a way to invoke Tools/cases_generator/generate_cases.py with all necessary flags (and, probably, environment variables) skipping the challenge of manual typing.

On non-Windows platforms it's achieved with make regen-all that depends on the regen-cases target:

cpython/Makefile.pre.in

Lines 1490 to 1503 in a679c3d

regen-cases:
# Regenerate Python/generated_cases.c.h
# and Python/opcode_metadata.h
# from Python/bytecodes.c
# using Tools/cases_generator/generate_cases.py
PYTHONPATH=$(srcdir)/Tools/cases_generator \
$(PYTHON_FOR_REGEN) \
$(srcdir)/Tools/cases_generator/generate_cases.py \
--emit-line-directives \
-o $(srcdir)/Python/generated_cases.c.h.new \
-m $(srcdir)/Python/opcode_metadata.h.new \
$(srcdir)/Python/bytecodes.c
$(UPDATE_FILE) $(srcdir)/Python/generated_cases.c.h $(srcdir)/Python/generated_cases.c.h.new
$(UPDATE_FILE) $(srcdir)/Python/opcode_metadata.h $(srcdir)/Python/opcode_metadata.h.new

By analogy, PCBuild\regen.targets could do the same for MSBuild.

Pitch

When I tried to resolve a Python/generated_cases.c.h conflict in gh-103976, I found out that I cannot do it easily. An attempt to port the regen-cases target was unsuccessfull:

D:\Oleg\cpython>set PYTHONPATH=D:\Oleg\cpython\Tools\cases_generator

D:\Oleg\cpython>python Tools/cases_generator/generate_cases.py --emit-line-directives Python/generated_cases.c.h.new Python/opcode_metadata.h.new
Running Release|x64 interpreter...
Traceback (most recent call last):
  File "D:\Oleg\cpython\Tools\cases_generator\generate_cases.py", line 1259, in 
    main()
  File "D:\Oleg\cpython\Tools\cases_generator\generate_cases.py", line 1250, in main
    a.parse()  # Raises SyntaxError on failure
    ^^^^^^^^^
  File "D:\Oleg\cpython\Tools\cases_generator\generate_cases.py", line 557, in parse
    self.parse_file(filename, instrs_idx)
  File "D:\Oleg\cpython\Tools\cases_generator\generate_cases.py", line 568, in parse_file
    with open(filename) as file:
         ^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'Python/generated_cases.c.h.new'

D:\Oleg\cpython>python Tools/cases_generator/generate_cases.py --emit-line-directives Python/generated_cases.c.h Python/opcode_metadata.h
Running Release|x64 interpreter...
Traceback (most recent call last):
  File "D:\Oleg\cpython\Tools\cases_generator\generate_cases.py", line 1259, in 
    main()
  File "D:\Oleg\cpython\Tools\cases_generator\generate_cases.py", line 1250, in main
    a.parse()  # Raises SyntaxError on failure
    ^^^^^^^^^
  File "D:\Oleg\cpython\Tools\cases_generator\generate_cases.py", line 557, in parse
    self.parse_file(filename, instrs_idx)
  File "D:\Oleg\cpython\Tools\cases_generator\generate_cases.py", line 583, in parse_file
    raise psr.make_syntax_error(
  File "Python/generated_cases.c.h", line 4658
    }
    ^
SyntaxError: Couldn't find '// BEGIN BYTECODES //' in Python/generated_cases.c.h

Autogenegeration would lift off a need to write a private batch-file, debug it, and use it each time Python/bytecodes.c is touched.

Your environment

  • CPython versions tested on: Python 3.12.0a7+ (heads/main:5078eedc5b, May 1 2023, 23:20:56) [MSC v.1929 64 bit (AMD64)] on win32
@arhadthedev arhadthedev added type-feature A feature request or enhancement OS-windows build The build process and cross-build 3.13 bugs and security fixes labels May 1, 2023
@Fidget-Spinner
Copy link
Member

For anyone working around this: I've always let the cases generator use its defaults (which will generate the CPython cases and opcode metadata). py -3.11 Tools/cases_generator/generate_cases.py --emit-line-directives is sufficient.

The extra arguments for files are for forks of CPython (IIRC, Cinder is planning to use it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes build The build process and cross-build OS-windows type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants