Change:
<ins> From 85991e0d7f0e631240f3f6233bd65d1128a66dec Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk <fridh@fridh.nl> Date: Thu, 14 Sep 2017 10:00:31 +0200 Subject: [PATCH] ctypes.util: support LD_LIBRARY_PATH Backports support for LD_LIBRARY_PATH from 3.6 --- Lib/ctypes/util.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py index 780cd5d21b..d7ac15070f 100644 --- a/Lib/ctypes/util.py +++ b/Lib/ctypes/util.py @@ -181,8 +181,32 @@ elif os.name == "posix": def _findSoname_ldconfig(name): return None +        def _findLib_ld(name): +            # See issue #9998 for why this is needed +            expr = r'[^()s]*lib%s.[^()s]*' % re.escape(name) +            cmd = ['ld', '-t'] +            libpath = os.environ.get('LD_LIBRARY_PATH') +            if libpath: +                for d in libpath.split(':'): +                    cmd.extend(['-L', d]) +            cmd.extend(['-o', os.devnull, '-l%s' % name]) +            result = None +            try: +                p = subprocess.Popen(cmd, stdout=subprocess.PIPE, +                                     stderr=subprocess.PIPE, +                                     universal_newlines=True) +                out, _ = p.communicate() +                res = re.search(expr, os.fsdecode(out)) +                if res: +                    result = res.group(0) +            except Exception as e: +                pass  # result will be None +            return result + def find_library(name): -            return _findSoname_ldconfig(name) or _get_soname(_findLib_gcc(name)) +            # See issue #9998 +            return _findSoname_ldconfig(name) or  +                   _get_soname(_findLib_gcc(name) or _findLib_ld(name)) ################################################################ # test code -- 2.14.1 </ins>

Discussion:
doesn't return anything on Python 3.4 and 3.5. This breaks which is needed for TensorFlow on Python 3 (prebuilt TensorFlow doesn't support Python 3.6). Nixpkgs version: (run ) cc
Yea, I noticed this. I think its caused by .
What did this function returned before? I think we can hard-code this information as it seems to already set at build time (location of libc and so on)
See result from above (Python 3.6 works okay). Hardcoding this is impossible as should resolve libraries from and other sources (if I understand correctly).
I have tried adding LDLIBRARYPATH to the cffi derivation, to no avail. Also, reverting commit does not change the test failures in cffi. My revert was on top of .
what's the plan? Should we revert the commit you linked?
Seems like I tested the wrong commit. Please ignore my previous comment.
reverting that commit does fix cffi on 3.4 but it does not fix cffi on 3.5
you would need to revert also , I suppose that it should be fine then.
that's what I did today because I noticed my mistake. I have checked out release-17.09 (at commit ) and then reverted . Doing so makes cffi build on python 3.4 but not on python 3.5. I am now building cffi on python 3.5 with reverted.
Ok, that solves the problem. Reverting both and fixes the problems on 3.4 and 3.5, but 3.6 does not need these reverts, so this needs some more manual work. Perhaps you can see what's different between these python versions, ? I suppose it's best that you fix it, because you seem to be more familiar with these changes and the reasons behind.
Yes, I'm going to have a look at this, but likely not until Wednesday.
FYI: this is blocking the darwin channel
sounds good :)
Either we hardcode paths (preferable) or we set , in which case should work. That was unrelated (Python 3.6 cffi). The seems to have caused this regression. The reason is that prior to 3.6 was not checked.

It did work before, but maybe that was because it used linker to find it? That code seems to have changed between 2.7 and 3.x. In any case, we should be able to backport the portion in 3.6 that checks .
Note that on Darwin it does not check for . We may in the future choose to support this.
Fix in