diff --git a/PyInstaller/depend/utils.py b/PyInstaller/depend/utils.py index b1e1b2a873..04e4736012 100644 --- a/PyInstaller/depend/utils.py +++ b/PyInstaller/depend/utils.py @@ -306,7 +306,13 @@ def _restorePaths(old): # local paths to library search paths, then replaces original values. old = _setPaths() for cbin in cbinaries: - cpath = find_library(os.path.splitext(cbin)[0]) + try: + # There is an issue with find_library() where it can run into + # errors trying to locate the library. See #5734. + cpath = find_library(os.path.splitext(cbin)[0]) + except FileNotFoundError: + # In these cases, find_library() should return None. + cpath = None if is_unix: # CAVEAT: find_library() is not the correct function. Ctype's # documentation says that it is meant to resolve only the filename diff --git a/news/5734.bugfix.rst b/news/5734.bugfix.rst new file mode 100644 index 0000000000..9a784eac03 --- /dev/null +++ b/news/5734.bugfix.rst @@ -0,0 +1,2 @@ +Fix a build error triggered by scanning ``ctypes.CDLL('libc.so')`` on certain +Linux C compiler combinations. diff --git a/tests/functional/test_regression.py b/tests/functional/test_regression.py index 7c0dc6f257..b15cab8ac3 100644 --- a/tests/functional/test_regression.py +++ b/tests/functional/test_regression.py @@ -92,3 +92,13 @@ def test_issue_4141(pyi_builder): #script_dir, pyi_builder.test_script('pyi_issue_4141.py', app_name="main", run_from_path=True, pyi_args=['--path', str(extra_path)]) + + +def test_5734(): + """ + In a regression this will raise a: + FileNotFoundError: [Errno 2] No such file or directory: b'liblibc.a' + on some Linux/gcc combinations. + """ + from PyInstaller.depend.utils import _resolveCtypesImports + _resolveCtypesImports(["libc"])