esc
esc

Reputation: 455

How does pip decide which many linux wheel to use?

Binary many-linux wheels are now supported:

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. The wheels are listed here:

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. And yes, I did update pip to version 8.1.2 which supports binary many linux wheels.

Specifically, I am not interested in alternative solutions, just answer the question, if you can.

Upvotes: 24

Views: 18775

Answers (5)

gdlmx
gdlmx

Reputation: 6789

Since pip version 19.3, TargetPython.get_tags() returns the supported PEP 425 tags to check wheel candidates (source). The tags are returned in the 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.

Updated for version 24.0

Thanks to David B, who finds out that get_tags has been renamed to get_sorted_tags.

pep425tags = target_python.get_sorted_tags()

Upvotes: 12

GoingMyWay
GoingMyWay

Reputation: 17478

In my case, I want to install 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.. 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. 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.

PEP 600 has been designed to be "future-proof" and does not enforce specific symbols and a specific distro to build. It only states that a wheel tagged manylinux_x_y shall work on any distro based on glibc>=x.y. The manylinux project supports:

  • manylinux_2_24 images for x86_64, i686, aarch64, ppc64le and s390x.
  • manylinux_2_28 images for x86_64, aarch64 and ppc64le

See the instruction: https://github.com/pypa/manylinux

Upvotes: 1

ogrisel
ogrisel

Reputation: 40169

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

EDIT: the function pip._internal.utils.compatibility_tags.get_supported() should return the list of supported platform tags in order. Pip prefers wheel tags that appear earlier in this list over tags that appear later.

Also may I kindly suggest you to use python 3.5 instead of 2.7 ;)

Upvotes: 15

Bryce Guinta
Bryce Guinta

Reputation: 3742

For pip 10 you'll need to run:

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

Upvotes: 4

esc
esc

Reputation: 455

So, the correct answer is that pip has a list of supported tags and will try to match those. pip.pep425tags.get_supported() will list the tags for your platform and will also use that list to match manylinux binary wheels.

Upvotes: 3

Related Questions