Nik*_* R. 2 python alpine-linux
我正在试验 alpine-linux,但它没有按预期工作。
我尝试使用,pip install cryptography
但它需要永远并停止在这个难以理解的输出
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
我该怎么办?
对于大多数附带 C/C++ 扩展(用 C/C++ 编写的代码编译为共享对象并通过外部函数库加载到 Python 中)的 Python 包来说,Alpine 是一个令人头疼的发行版。原因是PEP 513,Linux 发行版之间的可移植性定义manylinux1
基于 glibc/glibcxx。由于 Alpine 使用 musl libc,因此无法manylinux1
在 Alpine 上安装兼容的轮子。因此,当您发出 时pip install cryptography
,带有已编译扩展的轮子会被过滤,并pip
尝试从源代码构建具有所有 C 扩展的包。
这是首选方式,@GracefulRestart 在评论中提到了这一点;如果您不需要软件包的最新版本,请使用它。Alpine 提供预构建cryptography
包,目前它是cryptography<=2.1.4
. 安装它apk
:
$ apk add py-cryptography
Run Code Online (Sandbox Code Playgroud)
如果您需要最新版本,您可以尝试通过安装pip
.
您将需要带有头文件的编译器和库:musl、OpenSSL、libffi 和 Python 本身:
$ apk add gcc musl-dev libffi-dev openssl-dev python3-dev
Run Code Online (Sandbox Code Playgroud)
pip install pkgname
默认隐藏构建日志。要查看完整的构建日志,请添加-vvv
以增加详细程度。(可选)此外,您可以manylinux1
通过添加明确禁止安装轮子,--no-binary=pkgname
以便从源代码构建将被强制执行。
$ pip install cryptography -vvv --no-binary=cryptography
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2274 次 |
最近记录: |