Skip to content
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

Support alpine linux #76

Open
honi opened this issue Jan 4, 2021 · 2 comments
Open

Support alpine linux #76

honi opened this issue Jan 4, 2021 · 2 comments

Comments

@honi
Copy link

honi commented Jan 4, 2021

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.

@chris48s
Copy link
Owner

chris48s commented Jan 6, 2021

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:

try:
dm = Draughtsman()
except OSError:
dm = Draughtsman(_path)

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 🤞 ) 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.

@chris48s
Copy link
Owner

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 💡

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants