You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building for windows with mingw-w64-ucrt and embedding the interpreter into another application I encounter the issue that when running unittests the base library search path mechanism fails. This issue itself does not matter because I already found the root of this problem:
The interpreter dumps it's system configuration where sys.PREFIX is set to sth. like: \\C\\path\\to\\buildtree\\libs
The path itself is correct but is inproperly formatted. In comparison sys.EXECUTABLE looks like C:\path\to\python3.11.exe, the way it should.
After digging into the mechanism how python determines this path I found out that after all other search mechanism See doc fails it will take a kind of fallback path hardcoded into the executable. Unfortunately exactly this hardcoded path has this faulty msys style path with double backslashes, so it will look for a network share on windows.
Then I found out that in the configure step a variable called @prefix_b2h@ is created but never used. This variable holds the same path as @prefix@ but properly formatted for the host system. When looking at getpath.c you can see that if it never gets overwritten this path then comes per define into the executable here:
Probably this issue wasn't noticable yet because if you properly deploy the installation (not like in my unittests) the libraries will be found and the prefix gets overwritten with the correct path. But the faulty fallback path would still remain hardcoded within the executable.
Your environment
CPython versions tested on: 3.11.8
Operating system and architecture: Windows11 amd64
The text was updated successfully, but these errors were encountered:
Bug report
When building for windows with mingw-w64-ucrt and embedding the interpreter into another application I encounter the issue that when running unittests the base library search path mechanism fails. This issue itself does not matter because I already found the root of this problem:
The interpreter dumps it's system configuration where sys.PREFIX is set to sth. like:
\\C\\path\\to\\buildtree\\libs
The path itself is correct but is inproperly formatted. In comparison sys.EXECUTABLE looks like
C:\path\to\python3.11.exe
, the way it should.After digging into the mechanism how python determines this path I found out that after all other search mechanism See doc fails it will take a kind of fallback path hardcoded into the executable. Unfortunately exactly this hardcoded path has this faulty msys style path with double backslashes, so it will look for a network share on windows.
Then I found out that in the configure step a variable called
@prefix_b2h@
is created but never used. This variable holds the same path as@prefix@
but properly formatted for the host system. When looking atgetpath.c
you can see that if it never gets overwritten this path then comes per define into the executable here:cpython-mingw/Modules/getpath.c
Line 930 in 9d73243
cpython-mingw/Makefile.pre.in
Line 1298 in 9d73243
So my suggestion is to use the prefix_b2h path for the compilation of
getpath.c
:Probably this issue wasn't noticable yet because if you properly deploy the installation (not like in my unittests) the libraries will be found and the prefix gets overwritten with the correct path. But the faulty fallback path would still remain hardcoded within the executable.
Your environment
The text was updated successfully, but these errors were encountered: