django-apiblueprint-view
django-apiblueprint-view copied to clipboard
Support alpine linux
Is it possible that this package doesn't work when running on alpine linux because of the special handling of drafter?
I'm getting a Fatal Python error: Segmentation fault when trying to render a blueprint.
Hello.
I've never tried running this on alpine. The shared object distributed in the package is compiled on a manylinux2010_x86_64 docker container so it should theoretically be compatible on a pretty wide range of 64 bit x86 linux distros.
That said, if you're on a mac, a 32 bit distro, ARM arch etc that shared object won't work, so there is an option to provide your own. When we load drafter, we attempt to load system installed library first before falling back to the shared object distributed in the package if one is not found: https://github.com/chris48s/django-apiblueprint-view/blob/011703a92ab535a9f43de4495d7fb0dc8b0f2fec/apiblueprint_view/init.py#L7-L10
To provide your own library you'll need to compile your own libdrafter on the target platform (alpine), and it needs to be specifically v3.2.7. You'll need python2 (definitely) and gcc/g++ 5 (I think :crossed_fingers: ) to build it. Here's the process:
wget https://github.com/apiaryio/drafter/releases/download/v3.2.7/drafter-v3.2.7.tar.gz
tar xvzf drafter-v3.2.7.tar.gz
cd drafter-v3.2.7
python2 configure --shared
make libdrafter
cd ..
sudo cp drafter-v3.2.7/build/out/Release/lib.target/libdrafter.so /usr/lib/libdrafter.so # <-- this might not be the right place for alpine? Basically put it where your OS expects to find shared libs
rm -rf drafter-v3.2.7/
rm drafter-v3.2.7.tar.gz
Give that a try and see how you get on.
I'm returning to quite an old issue here. This is not a fix, but I did recently find out why this doesn't work on Alpine :bulb:
Unlike most distros (which are glibc based), Alpine is musl based which means manylinux binaries won't run on it. Currently PyPI doesn't have a platform tag that allows you to disribute a musl binary so for the moment the only solution is to manually compile. That said, there is currently an open PEP https://www.python.org/dev/peps/pep-0656/ about creating one so in future it might be possible to cross-compile drafter and distribute both glibc and musl wheels.