python / python/mypy

Stubgen does not respect RPath for transitive dependencies

Open
#21,543 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Bug Report
I have a library built with pybind11 that transitively links to libssl. Libssl in turn goes to load libcrypto, but gets the wrong version because it loads the system version, rather than using the $ORIGIN rpath in libssl. I ran stubgen under the debugger instead and found more strange behavior. The debugger stops on with ModuleInspect() as inspect: inside find_module_paths_using_imports but gives me a stack trace into the forkserver code. If I just put a breakpoint on that line in stubgen, and import my module, everything imports fine. However, stubgen gives me "Failed to import, skipping with error: /usr/lib/x86_64-linux-gnu/libcrypto.so.3: version `OPENSSL_3.6.0' not found (required by vcpkg/installed/x64-linux-dynamic/lib/libssl.so.3)"

To Reproduce

TODO: this might take some time for me to create a minimal example to reproduce it.

Actual Behavior

Failed to import, skipping with error: /usr/lib/x86_64-linux-gnu/libcrypto.so.3: version `OPENSSL_3.6.0' not found (required by vcpkg/installed/x64-linux-dynamic/lib/libssl.so.3)

Your Environment

  • Mypy version used: 2.1.0
  • Mypy command-line flags: stubgen.py -o ./stubs -m my_module
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: 3.14.4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin at find_module_paths_using_imports and the with ModuleInspect() as inspect: line, using the reported stubgen.py -o ./stubs -m my_module command. First create the promised minimal reproduction around the pybind11/libssl/libcrypto setup; done is reproducing and then preventing the version-mismatch import failure without changing normal imports.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.