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
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