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
Python 3.6 depends on ld at run-time #25763
Comments
CC @FRidh |
Did you check that OpenSSL or something else non-default also gets found when binutils are in PATH? Or does empty LD_LIBRARY_PATH break the test? Because libm could be found for wrong reasons. |
OK, another example:
|
It seems that this was already bugged before; Python (all versions) also tries to use the following programs, none of which are available in
|
I think it is OK if some of its attempts fail, we just need one approach to succeed reliably. |
Within Nixpkgs we do not use Adding How about we instead patch the interpreter to error when none of these programs are on PATH? |
There is also «fakeld» path, we don't need `ld` to work, just to search
for libraries in LD_LIBRARY_PATH, which can be implemented by a small
shell script.
|
@FRidh I agree, as it can become very difficult and time intensive to keep large/complicated projects (like glusterfs, packaging which I found this issue) patched.
@FRidh Hmm, this sounds problematic to me. If upstream says "requires one of {ld,objdump,gcc} to run as intended", I don't think we should say "no, it doesn't" in the name of closure sizes. Especially not because it is easy to go unnoticed; Python devs may think "we already have a dependency on ld, so we can use it in this other place for this other feature as well", and then we might have another thing that silently fails at run-time on NixOS. Another solution might be to make Python 3.6 depend on a slimmed down version of
@FRidh I don't understand this part, what do you mean here? It (Python 3.6) ... would require a Python interpreter? |
@7c6f434c I am not quite sure what exactly you have in mind, but the Python docs for |
These are not hard dependencies. If they were, they would either require them already at build-time or at the least cause an error when none were found during run-time.
Fixed it. I meant I do not think we should wrap the interpreter to add these tools to PATH. |
Note that expressions inside Nixpkgs should patch references to libraries when possible, instead of wrapping |
will actually be close enough. |
@7c6f434c That seems to simply resolve symlinks, which is not enough: Have a look into what the contents of
It's a text file! (A linker script.) Loading this with This is why I'd shy away from replacing upstream logic with "simpler solutions" in NixOS: If it was that simple, upstream could do the simple way themselves. |
Well, I wonder if taking the longest |
As another data point, wrapping the python interpreter would be a big annoyance on Darwin, which doesn't allow shebang destinations (which is pretty much the main thing the python interpreter is used for) to themselves be shebang'd scripts. So basically it would break everything unless we did #23018 as well. |
Oh well, that sounds like a harder issue to tackle. Then I guess we should patch python (and maybe afterwards upstream a configure option to pass in the path to Does everybody agree with this? |
@nh2 what exactly do you want to modify then? Python can work fine without these optional dependencies, as long as they're on The only patch I could imagine is to make it fail loudly if it needs to find a library and none of these tools are available. |
👎 on adding binutils to the closure. The few Python programs that need this can easily add Python's way to find libraries is batshit insane. It will even run BTW, wrapper scripts are generally a kludge. We have the source of Python, so we can patch the problem in Python itself (as de1b4e7 does). It would be more efficient to patch Python to check the elements of |
Done by setting PATH and PYTHONPATH appropriately. Adds the following patches: * One that removes hardcodes to /sbin, /usr/bin, etc. from gluster, so that programs like `lvm` and `xfs_info` can be called at runtime; see https://bugzilla.redhat.com/show_bug.cgi?id=1450546. * One that fixes unsubstituted autoconf macros in paths (a problem in the 3.10 release); see https://bugzilla.redhat.com/show_bug.cgi?id=1450588. * One that removes uses of the `find_library()` Python function that does not behave as expected in Python < 3.6 (and would not behave correctly even on 3.6 in nixpkgs due to NixOS#25763); see https://bugzilla.redhat.com/show_bug.cgi?id=1450593. I think that all of these patches should be upstreamed. Also adds tests to check that none of the Python based utilities throw import errors, calling `--help` or equivalent on them.
Done by setting PATH and PYTHONPATH appropriately. Adds the following patches: * One that removes hardcodes to /sbin, /usr/bin, etc. from gluster, so that programs like `lvm` and `xfs_info` can be called at runtime; see https://bugzilla.redhat.com/show_bug.cgi?id=1450546. * One that fixes unsubstituted autoconf macros in paths (a problem in the 3.10 release); see https://bugzilla.redhat.com/show_bug.cgi?id=1450588. * One that removes uses of the `find_library()` Python function that does not behave as expected in Python < 3.6 (and would not behave correctly even on 3.6 in nixpkgs due to #25763); see https://bugzilla.redhat.com/show_bug.cgi?id=1450593. I think that all of these patches should be upstreamed. Also adds tests to check that none of the Python based utilities throw import errors, calling `--help` or equivalent on them.
Closing this since this won't be changed. Do see #27751. |
Issue description
Python 3.6 fixed Python bug ctypes
find_library
should searchLD_LIBRARY_PATH
on Linux.When you call e.g.
find_library("m")
, it splitsLD_LIBRARY_PATH
by colons (:
), and for each entry/path/to/entry/e
shelling out told
, like:ld -t -L /path/to/entry/e -o /dev/null -lm
The code: https://hg.python.org/cpython/rev/385181e809bc
Note that the code fails silently:
We must add
binutils
topython36
's (and newer) runtime to make itfind_library()
work.Steps to reproduce
With
binutils
providingld
in PATH:Without:
Technical details
The text was updated successfully, but these errors were encountered: