简体   繁体   English

pip 如何决定使用多少个 linux 轮子?

[英]How does pip decide which many linux wheel to use?

Binary many-linux wheels are now supported:现在支持二进制 many-linux 轮子:

https://github.com/pypa/manylinux https://github.com/pypa/manylinux

Specifically I would like to install the many linux wheel for scipy on Travis, using the trusty beta operating system.具体来说,我想使用可信赖的 beta 操作系统在 Travis 上安装许多用于 scipy 的 linux 轮子。 The wheels are listed here:车轮在这里列出:

https://pypi.python.org/pypi/scipy/0.17.1 https://pypi.python.org/pypi/scipy/0.17.1

I get:我得到:

Collecting scipy
  Downloading scipy-0.17.1.tar.gz (12.4MB)
    100% |████████████████████████████████| 12.4MB 100kB/s 

Instead of:代替:

Collecting scipy
  Downloading scipy-0.17.1-cp27-cp27mu-manylinux1_x86_64.whl (39.5MB)
    100% |████████████████████████████████| 39.5MB 37kB/s 

So, in order to fix this, I would like to know, how pip determines which wheel to download and install.所以,为了解决这个问题,我想知道 pip 如何确定下载和安装哪个轮子。 And yes, I did update pip to version 8.1.2 which supports binary many linux wheels.是的,我确实将 pip 更新到了版本 8.1.2,它支持二进制许多 linux 轮子。

Specifically, I am not interested in alternative solutions, just answer the question, if you can.具体来说,我对替代解决方案感兴趣,如果可以的话,只要回答这个问题。

You need pip 8.1 or later and a linux distribution that is based on glibc (and not musl libc as alpine linux for instance).您需要 pip 8.1 或更高版本以及基于 glibc 的 linux 发行版(而不是像 alpine linux 那样的 musl libc)。

EDIT: the function pip._internal.utils.compatibility_tags.get_supported() should return the list of supported platform tags in order.编辑: 函数pip._internal.utils.compatibility_tags.get_supported()应该按顺序返回支持的平台标签列表。 Pip prefers wheel tags that appear earlier in this list over tags that appear later. Pip 更喜欢在此列表中较早出现的车轮标签,而不是较晚出现的标签。

Also may I kindly suggest you to use python 3.5 instead of 2.7 ;)我也可以建议您使用 python 3.5 而不是 2.7 ;)

For pip 10 you'll need to run:对于 pip 10,您需要运行:

from pprint import pprint
import pip._internal
pprint(pip._internal.pep425tags.get_supported())

So, the correct answer is that pip has a list of supported tags and will try to match those.所以,正确的答案是 pip 有一个受支持的标签列表,并会尝试匹配这些标签。 pip.pep425tags.get_supported() will list the tags for your platform and will also use that list to match manylinux binary wheels. pip.pep425tags.get_supported()将列出您平台的标签,并且还将使用该列表来匹配 manylinux 二进制轮子。

Since pip version 19.3, TargetPython.get_tags() returns the supported PEP 425 tags to check wheel candidates against ( source ).从 pip 版本 19.3 开始, TargetPython.get_tags()返回受支持的PEP 425 标签以检查轮候选项( )。 The tags are returned in order of preference (most preferred first).标签按优先顺序(最优先)返回。

from pip._internal.models.target_python import TargetPython
target_python = TargetPython()
pep425tags = target_python.get_tags()

The class TargetPython encapsulates the properties of a Python interpreter one is targeting for a package install, download, etc. TargetPython类封装了 Python 解释器的属性,该解释器针对的是包安装、下载等。

In my case, I want to install dmlab2d-1.0-cp39-cp39-manylinux_2_31_x86_64.whl就我而言,我想安装dmlab2d-1.0-cp39-cp39-manylinux_2_31_x86_64.whl

python -m pip install dmlab2d-1.0-cp39-cp39-manylinux_2_31_x86_64.whl

However, it shows ERROR: dmlab2d-1.0-cp39-cp39-manylinux_2_31_x86_64.whl is not a supported wheel on this platform.但是,它显示ERROR: dmlab2d-1.0-cp39-cp39-manylinux_2_31_x86_64.whl is not a supported wheel on this platform. . . I think maybe it relates to the version of the OS.我认为这可能与操作系统的版本有关。 Mine is Ubuntu 18. Then I tried to change the number of 31 to 24 in dmlab2d-1.0-cp39-cp39-manylinux_2_31_x86_64.whl .我的是 Ubuntu 18。然后我尝试在dmlab2d-1.0-cp39-cp39-manylinux_2_31_x86_64.whl 31 的数量更改为 24。 It works.有用。

cp dmlab2d-1.0-cp39-cp39-manylinux_2_31_x86_64.whl dmlab2d-1.0-cp39-cp39-manylinux_2_24_x86_64.whl

I think 31 is for Ubuntu 20, and 24 is for Ubuntu 18.我认为31适用于 Ubuntu 20,而24适用于 Ubuntu 18。

PEP 600 has been designed to be "future-proof" and does not enforce specific symbols and a specific distro to build. PEP 600 被设计为“面向未来”,不强制构建特定符号和特定发行版。 It only states that a wheel tagged manylinux_x_y shall work on any distro based on glibc>=xy The manylinux project supports:它仅说明标记为 manylinux_x_y 的轮子可以在任何基于 glibc>=xy 的发行版上运行 manylinux 项目支持:

  • manylinux_2_24 images for x86_64, i686, aarch64, ppc64le and s390x.用于 x86_64、i686、aarch64、ppc64le 和 s390x 的 manylinux_2_24 映像。
  • manylinux_2_28 images for x86_64, aarch64 and ppc64le用于 x86_64、aarch64 和 ppc64le 的 manylinux_2_28 映像

See the instruction: https://github.com/pypa/manylinux见说明: https ://github.com/pypa/manylinux

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM