Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python(MSVC): can't generate stubgen for some native python modules #4512

Closed
Mizux opened this issue Jan 24, 2025 · 0 comments
Closed

python(MSVC): can't generate stubgen for some native python modules #4512

Mizux opened this issue Jan 24, 2025 · 0 comments
Assignees
Labels
Bug Build: CMake CMake based build issue Lang: Python Python wrapper issue OS: Windows Windows OS
Milestone

Comments

@Mizux
Copy link
Collaborator

Mizux commented Jan 24, 2025

disclaimer: on my way to fix, just dumping the investigation process

Protocol

$ cmake --build temp_python39 --config Release --target python_package
...
$ rm temp_python39\python\stub_timestamp
$ cmake --build temp_python39 --config Release --target python_package

Observed

trace error:

...
 load C:\Users\corentinl\work\or-tools\temp_python39\python\ortools\.libs\zlib1.dll...
  load C:\Users\corentinl\work\or-tools\temp_python39\python\ortools\.libs\abseil_dll.dll...
  load C:\Users\corentinl\work\or-tools\temp_python39\python\ortools\.libs\utf8_validity.dll...
  load C:\Users\corentinl\work\or-tools\temp_python39\python\ortools\.libs\libprotobuf.dll...
  load C:\Users\corentinl\work\or-tools\temp_python39\python\ortools\.libs\highs.dll...
  Processed 1 modules
  Generated .\ortools/graph/python/min_cost_flow.pyi
  Processed 1 modules
  Generated .\ortools/constraint_solver/pywrapcp.pyi
  Processed 1 modules
  Generated .\ortools/linear_solver/pywraplp.pyi
ortools.linear_solver.python.model_builder_helper: Failed to import, skipping
...
ortools.sat.python.cp_model_helper: Failed to import, skipping

Investigation

Using dumpbin to figure out why it doesn't load.

$ cd temp_python39\python\ortools\linear_solver\python
$ dumpbin /imports model_build_helper.cp39-win_amd64.pyd | grep .dll
...
    re2.dll
    highs.dll
    libprotobuf.dll
    zlib1.dll
    abseil_dll.dll
    KERNEL32.dll
    MSVCP140.dll
    VCRUNTIME140_1.dll
    VCRUNTIME140.dll
...
$ cd temp_python39\python\ortools\sat\python
$ dumpbin /imports cp_model_helper.cp39-win_amd64.pyd  | grep .dll
   python39.dll
    libprotobuf.dll
    highs.dll
    zlib1.dll
    abseil_dll.dll
    KERNEL32.dll
    MSVCP140.dll
...

So it seems this module depends on re2.dll but we don't load it

for dll in ["zlib1.dll", "abseil_dll.dll", "utf8_validity.dll", "libprotobuf.dll", "highs.dll"]:
dll_path = os.path.join(basedir, ".libs", dll)
if os.path.exists(dll_path):
print(f"load {dll_path}...")
WinDLL(dll_path)

and

or-tools/cmake/python.cmake

Lines 558 to 569 in c330aec

COMMAND ${CMAKE_COMMAND} -E
$<IF:${need_unix_re2_lib},copy,true>
$<${need_unix_re2_lib}:$<TARGET_SONAME_FILE:re2::re2>>
${PYTHON_PROJECT}/.libs
COMMAND ${CMAKE_COMMAND} -E
$<IF:$<BOOL:${BUILD_Protobuf}>,copy,true>
$<${need_unix_protobuf_lib}:$<TARGET_SONAME_FILE:protobuf::libprotobuf>>
$<${need_unix_protobuf_lib}:$<TARGET_SONAME_FILE:utf8_validity>>
$<${need_windows_protobuf_lib}:$<TARGET_FILE:protobuf::libprotobuf>>
$<${need_windows_protobuf_lib}:$<TARGET_FILE:utf8_validity>>
${PYTHON_PROJECT}/.libs

@Mizux Mizux added Bug Build: CMake CMake based build issue Lang: Python Python wrapper issue OS: Windows Windows OS labels Jan 24, 2025
@Mizux Mizux added this to the v9.12 milestone Jan 24, 2025
@Mizux Mizux self-assigned this Jan 24, 2025
@Mizux Mizux changed the title python(MSVC): can't generate stubgen for some pybind11 natie python modules python(MSVC): can't generate stubgen for some native python modules Jan 24, 2025
@Mizux Mizux closed this as completed Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Build: CMake CMake based build issue Lang: Python Python wrapper issue OS: Windows Windows OS
Projects
None yet
Development

No branches or pull requests

1 participant