mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.64k stars 1.64k forks source link

Static link of python in windows fails due to gcc style static library name. #13848

Open dcrowe777 opened 3 weeks ago

dcrowe777 commented 3 weeks ago

https://github.com/mesonbuild/meson/blob/1feb771f06ade5d0c721022c11fa76f5a7dd8fcb/mesonbuild/dependencies/python.py#L220

statically linked python fails on windows with :

Program python3 found: YES Program C:\Python311\python found: YES (C:\Python311\python.exe) Could not find Python3 library 'C:\Python311\libs\libpython311.a' Run-time dependency python found: NO (tried sysconfig)

meson.build:33:12: ERROR: Python dependency not found

rgommers commented 3 weeks ago

Thanks for the report @dcrowe777. We were just looking at that exact line in gh-13851 and wondering if it was used at all. I'm curious about your use case, could you elaborate?

It seems like we may need:

  1. Cygwin/MinGW support, both Python and the package depending on it built with 'gcc': .a
  2. All built with MSVC/Clang-cl/Intel: .lib

For each of those, we will then need libpython{vernum} or libpython{vernum}t, depending on is_freethreaded. Unclear to me if we also need stable ABI variants. And I guess we probably shouldn't support the "mixed compilers" use case for static linking (libpython313.lib + 'gcc').

dcrowe777 commented 1 week ago

My use case is MSVC with the following lines in meson.build :

pymod = import('python') py = pymod.find_installation('python3') py_dep = py.dependency(embed: 'true', static: true)