1

I am experimenting with alpine-linux and it is not working as expected.

I try and use pip install cryptography but it takes forever and stops at this incomprehensible output

Running command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-h925mzyj/cryptography/setup.py';f=getattr(tokenize, 'open', open)(__f le__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-gdaazboj --python-tag cp36

What can I do about it?

  • 1
    alpine-linux is not exacly your run-of-the-mill linux...the core libraries are not the same, you might run into some incompatibilities. For certain docker uses, you might be better off with stripped down versions of Ubuntu or Debian. – Rui F Ribeiro May 29 '18 at 7:35
  • 1
    instead of using pip to install the software, have you tried to install the package supplied by alpine? apk update && apk add py-cryptography – GracefulRestart May 30 '18 at 1:18
5

Alpine is a headache distro for most Python packages that ship C/C++ extensions (code written in C/C++ that is compiled to a shared object and loaded in Python via a foreign function library). The reason for that is that is PEP 513 which portability definition between Linux distros, manylinux1, is based on glibc/glibcxx. Since Alpine uses musl libc, no manylinux1 compatible wheel can be installed on Alpine. So when you issue pip install cryptography, the wheel with the compiled extensions is filtered and pip tries to build the package with all the C extensions from source.

installing with the system package manager

This is the preferred way and was mentioned by @GracefulRestart in the comments; use it if you don't need the bleeding edge version of the package. Alpine offers the prebuilt cryptography package, currently it's the cryptography<=2.1.4. Install it with apk:

$ apk add py-cryptography

installing with pip

Should you need the bleeding edge version, you can try building it from source by installing with pip.

Preparing the build environment

You will need the compiler and libraries with header files: musl, OpenSSL, libffi and Python itself:

$ apk add gcc musl-dev libffi-dev openssl-dev python3-dev

Building

pip install pkgname hides the build log by default. To see the complete build log, add -vvv to increase verbosity. (Optional) Also, you can explicitly prohibit installing manylinux1 wheels by adding --no-binary=pkgname so the build from source will be enforced.

$ pip install cryptography -vvv --no-binary=cryptography

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.