Skip to content
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

bpo-43567: Improved generated code refresh on Windows #25120

Merged
merged 9 commits into from Apr 6, 2021
Merged

Conversation

zooba
Copy link
Member

@zooba zooba commented Mar 31, 2021

Generated files are now refreshed automatically (based on last modified timestamp, which Git preserves) in Windows builds, or can be manually refreshed by calling "build.bat --regen".

https://bugs.python.org/issue43567

@gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented Apr 1, 2021

Can you also add the lines needed to regenerate opcode.h and other files that must ge regenerated when opcode.py changes? See "make regen-opcode regen-opcode-targets". Also, frozen imports (basically everything done by "make regen-all").

@zooba
Copy link
Member Author

@zooba zooba commented Apr 1, 2021

Opcodes are regenerated in there already, there's just no command line option. Is there a need for one? It all regens pretty quick, and not at all if the files haven't been touched.

Frozen imports still have to be generated by the built CPython, so they're still in the _freeze_importlib project.

@gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented Apr 2, 2021

Opcodes are regenerated in there already, there's just no command line option. Is there a need for one? It all regens pretty quick, and not at all if the files haven't been touched.

I tested this as follows: add a new opcode to Lib/opcode.py, add a case for it in Python/ceval.c, run PCbuild\build.bat. This gives an error in ceval.c, and opcode.h is not regenerated.

What am I missing?

Frozen imports still have to be generated by the built CPython, so they're still in the _freeze_importlib project.

Okay, that seems to be working. The workflow seems to be as follows:

  • Change something that requires updating frozen importlib files
  • PCbuild\build.bat
  • This gives an error "importlib_external.h updated. You will need to rebuild pythoncore to se
    e the changes."
  • PCbuild\build.bat
  • "Build succeeded."

I'm guessing that I was used to the Mac/Linux workflow where this is part of make regen-all. But I don't see opcode.h being regenerated.

@@ -19,6 +19,8 @@
<_ASTOutputs Include="$(PySourcePath)Python\Python-ast.c">
<Argument>-C</Argument>
</_ASTOutputs>
<_OpcodeSources Include="$(PySourcePath)Tools\scripts\generate_opcode_h.py;$(PySourcePath)Lib\opcode.py" />
<_OpcodeOutputs Include="$(PySourcePath)Include\opcode.h" />
Copy link
Member

@gvanrossum gvanrossum Apr 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also opcode_targets.h, which is generated by this snippet in Makefile.pre.in:

regen-opcode-targets:
	# Regenerate Python/opcode_targets.h from Lib/opcode.py
	# using Python/makeopcodetargets.py
	$(PYTHON_FOR_REGEN) $(srcdir)/Python/makeopcodetargets.py \
		$(srcdir)/Python/opcode_targets.h.new
	$(UPDATE_FILE) $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/opcode_targets.h.new

Copy link
Member

@gvanrossum gvanrossum left a comment

Yes! This all works now.

I still find this block of errors hard to read:

C:\Users\gvanrossum\cpython\PCbuild\_freeze_importlib.vcxproj(146,5): error : importlib.h, importlib_external.h, import
lib_zipimport.h updated. You will need to rebuild pythoncore to see the changes.
C:\Users\gvanrossum\cpython\PCbuild\_freeze_importlib.vcxproj(146,5): error :
C:\Users\gvanrossum\cpython\PCbuild\_freeze_importlib.vcxproj(146,5): error : If you are not developing on Windows but
you see this error on a continuous integration build, you need to run 'make regen-all' and commit any changes.
    1 Warning(s)
    1 Error(s)

It's a lot of text that basically means "please re-run PCbuild\build.bat again," but I understand that the error may be produced in contexts where that phrasing wouldn't work either.

We should probably add a few words to the devguide section for Windows once this lands.

@zooba
Copy link
Member Author

@zooba zooba commented Apr 6, 2021

Yes, we expanded that text because it was confusing people when it was shorter. Tweaking it to just say "rebuild everything" rather than "pythoncore" probably makes sense. I'll do that before merging.

Unfortunately, I don't think I can get rid of the full path of the project before the message...

gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented on a079ad7 Apr 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need the part @(_Updated->'%(Filename)%(Extension)',', ') updated.? That makes the first line of the error twice as long. And I'd change "You will need to" into "Please".

zooba
Copy link
Member Author

@zooba zooba commented on a079ad7 Apr 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll move the list of files into a regular message, so it gets logged, but doesn't make the important message noisy.

@zooba zooba merged commit 7482838 into python:master Apr 6, 2021
9 of 11 checks passed
@zooba zooba deleted the bpo-43567 branch Apr 6, 2021
@gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented Apr 6, 2021

Thanks!

kreathon pushed a commit to kreathon/cpython that referenced this issue May 2, 2021
Generated files are now refreshed automatically on regular build, or may be forcibly regenerated by calling `build.bat --regen`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants