-
Notifications
You must be signed in to change notification settings - Fork 559
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
Downloaded python toolchain has shared library dependencies #1211
Comments
What version of pre-packaged Python do you recommend that runs on multiple platforms? We are using https://github.com/indygreg/python-build-standalone/, and they also would need to address this issue. You can also define The other option is to use a system interpreter instead of a hermetic interpreter. |
Looking at python-build-standalone, I would like to select |
So first off I agree with you that we should change the rules to use a statically linked python. Secondly you probably can use https://blog.aspect.dev/configuring-bazels-downloader to rewrite the downloaded package. |
Just since the static version is unable to load .so libraries at runtime, it may still be required to let users choose. |
At this point the rules decide for the user which binary to use, and we also test against those binaries. If you feel that users should have the choice, then at this point users can decide through configuring the downloadeder. I think you can override the name of the binary and even download it from GitHub. Why would a user want to use a binary that is linked the older libraries? We have a Python special interest group, and if you would want to join us it is a great topic for us to discuss. |
I'm not super deep in the inner workings of python libraries, but if I understand it correctly, some python libraries ship precompiled shared libraries that the python interpreter will load dynamically. |
This level of C and platform stuff is a bit outside my expertise, so I asked a couple coworkers who know more. re: using musl: I'm told musl is a different implementation of libc, so there are potential ABI issues with something on PyPI (which, iiuc, assumes glibc as part of a wheel's "manylinux" definition). This means we can't use musl as the default. That said, I think it should be easier to use a musl-based interpreter than patching and overriding URLs. Is this something we can auto detect and use? The info I found says that certain platforms use musl. Can, should, the toolchain logic detect if you're running e.g. fedora or alpine, and use musl if so? re: using static linking: Maybe? I think this depends on what is being statically linked into the interpreter and what prebuilt things on PyPI expect. I'm also told that you generally don't want to statically link certain libraries (e.g. libc) because those are how you interact with the host system APIs. Again, this is a bit outside my expertise. If standalone python doesn't provide a glibc-based statically linked interpreter build, then this is a bit moot. |
FYI, some PyPI packages have We should probably add a |
Yeah the musl platform and in theory also auto detection would work in cases where you have a dynamically linked musl libc and are on alpine or similar.
This is definitely true for glibc. With musl this is not a problem if the kernel is recent enough. |
Where is this issue at? |
Nobody has attempted to implement this yet. |
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. |
From some discussions on slack and other issues, I think there's two ways forward on this: Long term, get these alternative runtimes part of what rules_python inherently understands. This just requires (a) adding all the URLs and (b) having those runtimes registered as toolchains with the appropriate constraints. Then one can do e.g. A shorter term alternative is do to do (a) above, and then add a |
Is it somewhere clearly documented how to escape this, and tell the |
With #1837 I have added As for the local system interpreter, it will be used by the autodetecting toolchain if no hermetic toolchain is registered. Maybe this could be facilitated in a more easy way if we had a |
OK, since #1837 has landed and the bugs with toolchain selection got squashed, adding extra I personally don't have time to do this right now, so if anyone comes along and does it, add me as a reviewer. :) |
With this users can target `musl` platforms in `whl`-only setups. Fixes bazelbuild#1211
…2406) Before this PR we would shell out to `uname` on UNIX systems to get the `arch` of the toolchain - on Windows we would not need to do it because there used to be only a single Windows platform. With this change we can correctly support the resolution of the python interpreter on various platforms and I have also added an env variable to customize the selection, so that users can use `musl` or a `freethreaded` interpreter if they wish. As part of this change, I have restricted visibility of the config settings used in the toolchain alias repo so that we are creating fewer targets. This is a very good time to do this before `1.0.0`. Fixes #2145 Work towards #2276 Work towards #2386 Work towards #1211 to unblock #2402 Work towards #1361 --------- Co-authored-by: Richard Levasseur <richardlev@gmail.com>
🐞 bug report
Affected Rule
n/a
Is this a regression?
no
Description
The python toolchains downloaded by this rule depend on an (outdated) version of the glibc.
This does not work for a number of environments.
Maybe a statically linked python binary or different versions of the toolchains could be provided instead.
I'd be happy to help work on a more hermetic (as in: not relying on system-wide libraries) python toolchain.
🔬 Minimal Reproduction
Register any of the builtin python toolchain for download, find thy
python3
binary in the cache and run:As you can see, the library has versioned glibc dependencies. This is problematic in environments with newer glibcs (arch linux, fedora) or environments that use different libcs (alpine) or don't always provide a "default" glibc for tools (nix / nixos).
🔥 Exception or Error
When using Fedora as a host system, the build fails like this:
The OS provides
/usr/lib64/libcrypt.so.2
, but notlibcrypt.so.1
.🌍 Your Environment
Operating System(s):
Output of
bazel version
:Rules_python version:
Anything else relevant?
This issue exists: #716, but the bug was not actually fixed here.
Forcing downstream users to install old glibc versions system wide seems like it will become harder over time.
The text was updated successfully, but these errors were encountered: