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

ctypes test_macholib fails if libz is not installed in /usr/lib #65292

Closed
nullpex mannequin opened this issue Mar 29, 2014 · 4 comments
Closed

ctypes test_macholib fails if libz is not installed in /usr/lib #65292

nullpex mannequin opened this issue Mar 29, 2014 · 4 comments

Comments

@nullpex
Copy link
Mannequin

nullpex mannequin commented Mar 29, 2014

BPO 21093
Nosy @ronaldoussoren, @ned-deily

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2014-03-29.07:14:55.261>
created_at = <Date 2014-03-29.02:31:12.898>
labels = ['ctypes']
title = 'ctypes test_macholib fails if libz is not installed in /usr/lib'
updated_at = <Date 2014-03-29.07:14:55.249>
user = 'https://bugs.python.org/nullpex'

bugs.python.org fields:

activity = <Date 2014-03-29.07:14:55.249>
actor = 'ned.deily'
assignee = 'none'
closed = True
closed_date = <Date 2014-03-29.07:14:55.261>
closer = 'ned.deily'
components = ['ctypes']
creation = <Date 2014-03-29.02:31:12.898>
creator = 'nullpex'
dependencies = []
files = []
hgrepos = []
issue_num = 21093
keywords = []
message_count = 4.0
messages = ['215107', '215111', '215118', '215119']
nosy_count = 4.0
nosy_names = ['ronaldoussoren', 'ned.deily', 'python-dev', 'nullpex']
pr_nums = []
priority = 'low'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue21093'
versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

@nullpex
Copy link
Mannequin Author

nullpex mannequin commented Mar 29, 2014

I'm compiling on a Mac OS X 10.9.2.
Python version 3.4.0.
My libz --prefix is $HOME so the library is in $HOME/lib/
The issue is line 53 of Lib/ctypes/test/test_macholib.py which has /usr/lib/libz.1 hardcoded:

======================================================================
FAIL: test_find (ctypes.test.test_macholib.MachOTest)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/Users/machados/src/Python-3.4.0/Lib/ctypes/test/test_macholib.py", line 53, in test_find
    self.assertTrue(result.startswith('/usr/lib/libz.1'))
AssertionError: False is not true

I've added a print before the assert command and the library is successfully found:

$ ./python.exe ./Lib/ctypes/test/test_macholib.py
/Users/machados/lib/libz.1.2.8.dylib
F

======================================================================
FAIL: test_find (main.MachOTest)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/Users/machados/src/Python-3.4.0/Lib/ctypes/test/test_macholib.py", line 54, in test_find
    self.assertTrue(result.startswith('/usr/lib/libz.1'))
AssertionError: False is not true

Ran 1 test in 0.001s

As you can see the library is found in /Users/machados/lib/libz.1.2.8.dylib which is correct.

@nullpex nullpex mannequin added build The build process and cross-build topic-ctypes labels Mar 29, 2014
@ned-deily
Copy link
Member

Thanks for the report. It seems to me this is a very rare case here: since libz is supplied by OS X, it would be untypical for someone building Python to supply their own version in $HOME/lib. But, further, the point of the test is not to find the copy of libz that Python was built with, rather it is just to verify that the darwin version of ctypes.find_library() can find system libraries at their well-known locations. It would be somewhat difficult to set up a test of all of the search paths that are used, emulating the behavior of the system dynamic loader, dyld. As documented in the code and in the man page for dyld, the relevant search path is DYLD_FALLBACK_LIBRARY_PATH, which is $(HOME)/lib:/usr/local/lib:/lib:/usr/lib. So the test will unexpectedly find libz in $HOME/lib first, as it did for you.

I was going to assert that you were the first person to ever report running into this issue but, searching a bit, I found bpo-1544102 which was never resolved but, thanks to your analysis, I now suspect was another instance with the same root cause. I guess we could change the test to accept a libz found in $HOME/lib or /usr/local/lib as well. Or we could just search for a different versioned system library less likely to shadowed in those locations, e.g. one not used in a Python build.

@ned-deily ned-deily removed the build The build process and cross-build label Mar 29, 2014
@python-dev
Copy link
Mannequin

python-dev mannequin commented Mar 29, 2014

New changeset e30142fde075 by Ned Deily in branch '2.7':
Issue bpo-21093: Prevent failures of ctypes test_macholib on OS X if a
http://hg.python.org/cpython/rev/e30142fde075

New changeset 831bd1a1cf6c by Ned Deily in branch '3.4':
Issue bpo-21093: Prevent failures of ctypes test_macholib on OS X if a
http://hg.python.org/cpython/rev/831bd1a1cf6c

New changeset 33c4c01404cd by Ned Deily in branch 'default':
Issue bpo-21093: merge from 3.4
http://hg.python.org/cpython/rev/33c4c01404cd

@ned-deily
Copy link
Member

test_macholib has been changed to no longer fail if a local copy of libz is encountered on the dyld search path ($HOME/lib or /usr/local/lib). Applied for release in 3.5.0, 3.4.1, and 2.7.7.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant