msys2-contrib / cpython-mingw

A friendly fork of CPython which adds support for Mingw-w64 + clang/gcc. See https://github.com/msys2-contrib/cpython-mingw/wiki for details
https://github.com/msys2-contrib/cpython-mingw/wiki
Other
38 stars 11 forks source link

Loading _sqlite3 fails with MSYSTEM not set and /bin not in PATH #141

Closed lazka closed 1 year ago

lazka commented 1 year ago

Noticed because this makes one test in the meson test suite fail:

git clone https://github.com/mesonbuild/meson
cd meson
MSYSTEM= python3 run_unittests.py -n0 test_vsenv_option

With Python 3.11.4 and empty MSYSTEM things fail:

$ PATH= MSYSTEM= /ucrt64/bin/python3.exe -c "import _sqlite3; print(_sqlite3)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: DLL load failed while importing _sqlite3: The specified module could not be found.

$ PATH= /ucrt64/bin/python3.exe -c "import _sqlite3; print(_sqlite3)"
<module '_sqlite3' from 'C:/msys64/ucrt64/lib/python3.11/lib-dynload/_sqlite3.cp311-mingw_x86_64_ucrt.pyd'>

With Python 3.10.12 both cases work:

$ PATH= MSYSTEM= /ucrt64/bin/python3.exe -c "import _sqlite3; print(_sqlite3)"
<module '_sqlite3' from 'C:\\msys64\\ucrt64\\lib\\python3.10\\lib-dynload\\_sqlite3.cp310-mingw_x86_64_ucrt.pyd'>

$ PATH= /ucrt64/bin/python3.exe -c "import _sqlite3; print(_sqlite3)"
<module '_sqlite3' from 'C:/msys64/ucrt64/lib/python3.10/lib-dynload/_sqlite3.cp310-mingw_x86_64_ucrt.pyd'>
lazka commented 1 year ago

@naveen521kk do you have any ideas?

I guess related to getpath.py?

lazka commented 1 year ago

Setting PYTHONVERBOSE shows some differences with site packages, but this could be unrelated:

$ python3 -c "import site; print(site.getsitepackages())"
['C:/msys64/ucrt64/lib/python3.11/site-packages', 'C:\\msys64\\ucrt64/lib/python3.11/site-packages']

$ MSYSTEM= python3 -c "import site; print(site.getsitepackages())"
['C:\\msys64\\ucrt64\\lib\\python3.11\\site-packages']

edit: I think that is because sys.prefix and sys.exec_prefix don't match with MSYSTEM set, so maybe unrelated

-> https://github.com/msys2-contrib/cpython-mingw/issues/142

lazka commented 1 year ago

I've created a meson branch to skip the failing test, in case we update before this is fixed: https://github.com/lazka/meson/tree/msys2-python311-upgrade

edit: we did, so https://github.com/mesonbuild/meson/pull/12049