summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/py-pip/package.py
blob: 88272efdce7117935923950dfefdd56ca73a3859 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

import os

from spack.package import *


class PyPip(Package, PythonExtension):
    """The PyPA recommended tool for installing Python packages."""

    homepage = "https://pip.pypa.io/"
    url = "https://files.pythonhosted.org/packages/py3/p/pip/pip-20.2-py3-none-any.whl"
    list_url = "https://pypi.org/simple/pip/"

    # Requires railroad
    skip_modules = ["pip._vendor"]

    tags = ["build-tools"]

    maintainers("adamjstewart", "pradyunsg")

    license("MIT")

    version(
        "23.1.2",
        sha256="3ef6ac33239e4027d9a5598a381b9d30880a1477e50039db2eac6e8a8f6d1b18",
        expand=False,
    )
    version(
        "23.0",
        sha256="b5f88adff801f5ef052bcdef3daa31b55eb67b0fccd6d0106c206fa248e0463c",
        expand=False,
    )
    version(
        "22.2.2",
        sha256="b61a374b5bc40a6e982426aede40c9b5a08ff20e640f5b56977f4f91fed1e39a",
        expand=False,
    )
    version(
        "22.1.2",
        sha256="a3edacb89022ef5258bf61852728bf866632a394da837ca49eb4303635835f17",
        expand=False,
    )
    version(
        "21.3.1",
        sha256="deaf32dcd9ab821e359cd8330786bcd077604b5c5730c0b096eda46f95c24a2d",
        expand=False,
    )
    version(
        "21.1.2",
        sha256="f8ea1baa693b61c8ad1c1d8715e59ab2b93cd3c4769bacab84afcc4279e7a70e",
        expand=False,
    )
    version(
        "20.2",
        sha256="d75f1fc98262dabf74656245c509213a5d0f52137e40e8f8ed5cc256ddd02923",
        expand=False,
    )
    version(
        "19.3",
        sha256="e100a7eccf085f0720b4478d3bb838e1c179b1e128ec01c0403f84e86e0e2dfb",
        expand=False,
    )
    version(
        "19.1.1",
        sha256="993134f0475471b91452ca029d4390dc8f298ac63a712814f101cd1b6db46676",
        expand=False,
    )
    version(
        "19.0.3",
        sha256="bd812612bbd8ba84159d9ddc0266b7fbce712fc9bc98c82dee5750546ec8ec64",
        expand=False,
    )
    version(
        "18.1",
        sha256="7909d0a0932e88ea53a7014dfd14522ffef91a464daaaf5c573343852ef98550",
        expand=False,
    )
    version(
        "10.0.1",
        sha256="717cdffb2833be8409433a93746744b59505f42146e8d37de6c62b430e25d6d7",
        expand=False,
    )
    version(
        "9.0.1",
        sha256="690b762c0a8460c303c089d5d0be034fb15a5ea2b75bdf565f40421f542fefb0",
        expand=False,
    )

    extends("python")
    depends_on("python@3.7:", when="@22:", type=("build", "run"))

    # Uses collections.MutableMapping
    depends_on("python@:3.9", when="@:19.1", type=("build", "run"))

    def url_for_version(self, version):
        url = "https://files.pythonhosted.org/packages/{0}/p/pip/pip-{1}-{0}-none-any.whl"
        if version >= Version("21"):
            python_tag = "py3"
        else:
            python_tag = "py2.py3"
        return url.format(python_tag, version)

    def install(self, spec, prefix):
        # To build and install pip from source, you need setuptools, wheel, and pip
        # already installed. We get around this by using a pre-built wheel to install
        # itself, see:
        # https://discuss.python.org/t/bootstrapping-a-specific-version-of-pip/12306
        whl = self.stage.archive_file
        args = [os.path.join(whl, "pip")] + std_pip_args + ["--prefix=" + prefix, whl]
        python(*args)

    def setup_dependent_package(self, module, dependent_spec):
        pip = dependent_spec["python"].command
        pip.add_default_arg("-m", "pip")
        setattr(module, "pip", pip)