Skip to content

Instantly share code, notes, and snippets.

@Valian
Last active February 26, 2019 06:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Valian/013297c79edcc03f87fe351fe7a76f1a to your computer and use it in GitHub Desktop.
Save Valian/013297c79edcc03f87fe351fe7a76f1a to your computer and use it in GitHub Desktop.
Fast way to fix not working ctype.util.find_library() in python alpine. Rather quick workaround, but works :)
FROM python:2-alpine
ENV PYTHONUNBUFFERED=1 \
PROJECT_ROOT=/srv
COPY requirements.txt $PROJECT_ROOT/
RUN apk add --update --virtual build-dependencies build-base python-dev \
&& cd $PROJECT_ROOT && pip install -r requirements.txt \
# those two lines replaces "find_library(...)" call with result of "ls /lib | grep ..." in problematic packages
&& sed -i -e "s/ctypes\.util\.find_library('crypto')/'$(ls /lib | grep crypto)'/g" /usr/local/lib/python2.7/site-packages/pyelliptic/openssl.py \
&& sed -i -e "s/find_library('c')/'$(ls /lib | grep libc.musl)'/g" /usr/local/lib/python2.7/site-packages/fakeredis.py \
&& apk del build-dependencies \
&& rm -rf /var/cache/apk/*
COPY . $PROJECT_ROOT
WORKDIR $PROJECT_ROOT
#!/usr/bin/env bash
CODE_FRAGMENT="find_library('c')"
LIBRARY_NAME="libc.musl"
PACKAGE_NAME="fakeredis.py"
sed -i -e "s/$CODE_FRAGMENT/'$(ls /lib | grep $LIBRARY_NAME)'/g" /usr/local/lib/python2.7/site-packages/$PACKAGE_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment