(module_name)
| 1904 | |
| 1905 | |
| 1906 | def _find_incompatible_extension_module(module_name): |
| 1907 | import importlib.machinery |
| 1908 | import importlib.resources.readers |
| 1909 | |
| 1910 | if not module_name or not importlib.machinery.EXTENSION_SUFFIXES: |
| 1911 | return |
| 1912 | |
| 1913 | # We assume the last extension is untagged (eg. .so, .pyd)! |
| 1914 | # tests.test_traceback.MiscTest.test_find_incompatible_extension_modules |
| 1915 | # tests that assumption. |
| 1916 | untagged_suffix = importlib.machinery.EXTENSION_SUFFIXES[-1] |
| 1917 | # On Windows the debug tag is part of the module file stem, instead of the |
| 1918 | # extension (eg. foo_d.pyd), so let's remove it and just look for .pyd. |
| 1919 | if os.name == 'nt': |
| 1920 | untagged_suffix = untagged_suffix.removeprefix('_d') |
| 1921 | |
| 1922 | parent, _, child = module_name.rpartition('.') |
| 1923 | if parent: |
| 1924 | traversable = importlib.resources.files(parent) |
| 1925 | else: |
| 1926 | traversable = importlib.resources.readers.MultiplexedPath( |
| 1927 | *map(pathlib.Path, filter(os.path.isdir, sys.path)) |
| 1928 | ) |
| 1929 | |
| 1930 | for entry in traversable.iterdir(): |
| 1931 | if entry.name.startswith(child + '.') and entry.name.endswith(untagged_suffix): |
| 1932 | return entry.name |
no test coverage detected
searching dependent graphs…