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

Analysis: ctypes: Guard against errors triggered by find_library(). (#5734) #5740

Merged
merged 1 commit into from Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion PyInstaller/depend/utils.py
Expand Up @@ -304,7 +304,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
Expand Down
2 changes: 2 additions & 0 deletions 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.
10 changes: 10 additions & 0 deletions tests/functional/test_regression.py
Expand Up @@ -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"])