Repository navigation
Load the release CPython in Windows Debug builds - #261
Merged
Merged
Conversation
Debug Windows builds (flutter test, flutter run) bundled a debug build of CPython (python3XY_d.dll, loaded through dart_bridge_d.dll). A debug CPython only imports extension modules named *_d.pyd, which PyPI wheels don't ship, so every compiled package (pydantic-core, numpy, ...) failed with ModuleNotFoundError although its .pyd was installed. The debug variant dates from when the plugin itself compiled against Python.h. Since 3.0.0 only dart_bridge touches Python, through FFI, so every build configuration now bundles python3XY.dll, python3.dll and dart_bridge.dll, and the Dart side always opens dart_bridge.dll.
Every build configuration loads the release CPython now, so nothing imports the *_d.pyd, *_d.dll and *_d.pdb files in DLLs/. Remove them from Debug builds as well, not only from Release and Profile builds.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Reported in flet-dev/flet#7022:
flet teston Windows fails withModuleNotFoundError: No module named 'pydantic_core._pydantic_core'.Cause
Debug Windows builds (
flutter test,flutter run, and Flet'sflet testandflet debug windows) bundle a debug build of CPython:python3XY_d.dllandpython3_d.dll, loaded throughdart_bridge_d.dll. A debug CPython only imports extension modules named*_d.pyd:PyPI wheels only ship the release
.pyd(_pydantic_core.cp314-win_amd64.pyd), so every package with compiled code (pydantic-core, numpy, cryptography, …) fails to import in Debug builds, even though its.pydis installed. Release builds (flet build windows) aren't affected.The debug variant comes from the original Windows support, when the plugin itself included
Python.hand MSVC Debug builds had to linkpython3X_d.lib. Since 3.0.0 (#209), onlydart_bridgetouches Python, through FFI, so nothing needs the debug CPython any more.#260 doesn't change this: it only removes CPython's debug modules from Release and Profile builds.
Changes
CMakeLists.txtbundlespython3XY.dll,python3.dllanddart_bridge.dllin every configuration and stops downloadingdart_bridge_d.dll.dart_bridge_ffi.dartalways opensdart_bridge.dll. A Debug runner loads the release DLLs as they are: nothing it builds links Python, and the CRTs stay inside their own DLLs.*_dmodules from Debug builds too. Nothing imports them now, so the*_d.*cleanup from Bump to 6.1.1: Release Windows apps drop Python's debug modules again #260 runs in every configuration.serious_python,serious_python_windowsandserious_python_platform_interface. Versions aren't bumped.Testing
On Windows 11 (x64 Flutter 3.47.7), a Flet 1.1.0 project built from source (
flet-1.1.0ate660c80) that depends onpydantic, run withflet test:python314_d.dll+dart_bridge_d.dll,EXTENSION_SUFFIXES == ['_d.cp314-win_amd64.pyd', '_d.pyd']ModuleNotFoundError: No module named 'pydantic_core._pydantic_core', test failsed45d2c, viadependency_overrides)python314.dll+dart_bridge.dll1 passedWith a clean Debug output folder, the build bundles only
dart_bridge.dll,python3.dllandpython314.dllnext to the exe, andDLLs\has no*_d.*files.The same changes applied to serious_python 5.0.0 also fix a Flet 1.0.5 project.
Not tested:
flet debug windows, which builds through the same Debug path.The trade-off is that a Debug Flutter build can no longer step into CPython's own C code, which Flet apps don't need.
Follow-ups (other repos)
windows/runner/main.cpp) falls back todart_bridge_d.dllwhendart_bridge.dllis missing. With this change that branch is never taken; it can go when Flet bumps to this release.dart_bridge_d-windows-x86_64.dllonce no serious_python release downloads it.