Fix test_venv
on Windows adding support for building python launchers
#422
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This pull request adds support for building the following Windows-specific Python launchers:
venvlauncher
andvenvwlauncher
. Introduced in Python ≥ 3.3, but only built when Python ≥ 3.9 to simplify resource handling.pylauncher
andpywlauncher
. Introduced and built when Python ≥ 3.11.These launchers rely on
launcher.c
andlauncher2.c
, depending on the target. They enable Python-specific runtime behavior for virtual environments and support shebang redirection on Windows.Implementation Notes
_WINDOWS
Macro HandlingTo avoid build issues related to the
_WINDOWS
macro being implicitly defined via/D_WINDOWS
(e.g., fromCMAKE_C_FLAGS
), we introduce a helper function:This function:
Adds the executable target using
add_executable(...)
Explicitly undefines
_WINDOWS
using:Avoids modifying global variables like
CMAKE_C_FLAGS
, which are unreliable and fragile during CMake generationAccepts that the following harmless MSVC warning will be emitted:
This prevents incorrect subsystem settings or entry-point mismatches that would otherwise occur if
_WINDOWS
were incorrectly defined, particularly in console-mode launchers.Manifest Handling
/MANIFEST:NO
to the linker to avoid resource duplication errors, sincepylauncher.rc
already includes an embedded manifest.Conditional Launcher Build Logic
venvlauncher
andvenvwlauncher
are only built whenPY_VERSION ≥ 3.9
.pythonnt_rc.h
."bpo-41054: Simplify resource compilation on Windows (GH-21004)".
Working toward addressing: