-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Gunicorn 20.0.0: find_library('c') doesn't work in Alpine Linux #2160
Comments
Right. We should probably test if python=< 3.7 to use gunicorn/gunicorn/socketfromfd.py Line 65 in 438371e
|
First, thanks for a great piece of software! |
Can confirm that the issue isn't related to a specific Python version, have it happening in 3.6,3.7,3.8 so long as it's in Alpine. |
It's a side effect of using an operating system without all the basic libs in a container unfortunately. Maybe you could use an image using a debian? or an alpine image coming with a libc? This api is there is pre-3.7 to replace a lack of API for it in Python. Detecting if the api is available (for python >= 3.7) would at least solve the issue for these versions. Before that we need to investigate what could be done. |
Alpine uses musl libc in place of glibc as part of it being based on busybox, of course using other base images would be a workaround but it will limit gunicorn uses as both alpine & other minimal OS that are growing in popularity (which are often based on it\busybox\etc) all have musl instead of glibc so the affect is likely not limited to alpine (just the most popular one affected). Sounds to me that something like detecting if musl is installed instead of glibc & if so use whatever solution was in place in 19.9.x is a potential fix that isn't python version specific as we know 19.9.x works well. |
found a related issue in docker-library/python#111 maybe this code can be reused in a way: python/cpython@e3f6778 |
There is one possible workaround for that, as twisted users encountered the same:
Just one of the possible solutions,but probably not the best one. |
I think that's this issue: https://bugs.python.org/issue21622 Let's find a workaround and make a patch release. |
@tilgovi the patch I linked above does the trick (and is linked in the bug ticket you added). I will work on a PR that use it. |
find_library('c') doesn't work in Alpine Linux. This happen because musl has a simpler implementation of libc. This patch fix it by extending ctypes.util.find_library to search the libs using LD_LIBRARY_PATH. Patch is based on python/cpython@e3f6778 See also https://bugs.python.org/issue21622 fix #2160
@aljinovic can you try fda61b5 . It should fix your issue. Let me know :) |
I tried it and it doesn't work. I found a bug in your implementation, here's a proposal of the fix: for suffix in ['so', '*.so.*']:
for f in glob('{0}.{1}'.format(prefix, suffix)): |
hrm odd, can you paste me the error you had? |
Your code: |
Also, I had to manually set paths = ['/lib', '/usr/local/lib', '/usr/lib']
if 'LD_LIBRARY_PATH' in os.environ:
paths = os.environ['LD_LIBRARY_PATH'].split(':') + paths |
ok fixing that, not sure about why the glob is nlot working the first way though. I need to test |
find_library('c') doesn't work in Alpine Linux. This happen because musl has a simpler implementation of libc. This patch fix it by extending ctypes.util.find_library to search the libs using LD_LIBRARY_PATH. Patch is based on python/cpython@e3f6778 See also https://bugs.python.org/issue21622 fix #2160
@aljinovic should be OK now, let me know |
Still doesn't work unless I change from: for suffix in ['so', 'so.*']: to: for suffix in ['so', '*.so.*']: The actual |
sorry I missed the additional star.
e150ca4
should fix it now.
…On Thu, Nov 21, 2019 at 11:47 AM Ante Aljinovic ***@***.***> wrote:
Still doesn't work unless I change from:
for suffix in ['so', 'so.*']:
to:
for suffix in ['so', '*.so.*']:
The actual libc name is: libc.musl-x86_64.so.1
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#2160?email_source=notifications&email_token=AAADRISHZX5Q265IJQ5OCKLQUZRMJA5CNFSM4JLJUUP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEZZJPY#issuecomment-557028543>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAADRIXWUCJLU6ZCD2R2Z6DQUZRMJANCNFSM4JLJUUPQ>
.
|
Great, that worked, thank you! |
Nice work everyone! |
find_library('c') doesn't work in Alpine Linux. This happen because musl has a simpler implementation of libc. This patch fix it by extending ctypes.util.find_library to search the libs using LD_LIBRARY_PATH. Patch is based on python/cpython@e3f6778 See also https://bugs.python.org/issue21622 fix #2160
can you all test #2208 as i changed the implementation to simply use the python standard library. Any feedback is welcome :) |
I was trying to run gunicorn 20.0.0 inside an Alpine Linux docker container (python:3.8-alpine).
Gunicorn 19.9.0 works just fine on the same docker image.
After installing
musl
, the errorlibc not found
is still present.Here's a block of code extracted from
gunicorn/socketfromfd.py
that doesn't work in Alpine:test.py
Dockerfile
The text was updated successfully, but these errors were encountered: