diff options
author | James Smillie <83249606+jamessmillie@users.noreply.github.com> | 2024-04-03 23:03:56 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-03 23:03:56 -0600 |
commit | cb315e18f04b1e087500f1fcea8cde13b3a6e783 (patch) | |
tree | f9d115ac38453f778fcc1dfa6b8b9fb781fd1278 /var | |
parent | 10c637aca0880e33b792c96c5ba58ed22a8bbb7e (diff) | |
download | spack-cb315e18f04b1e087500f1fcea8cde13b3a6e783.tar.gz spack-cb315e18f04b1e087500f1fcea8cde13b3a6e783.tar.bz2 spack-cb315e18f04b1e087500f1fcea8cde13b3a6e783.tar.xz spack-cb315e18f04b1e087500f1fcea8cde13b3a6e783.zip |
py-pip package: enable install on Windows (#43203)
The installation mechanism used on Linux to install py-pip (using pip
from the downloaded wheel to install the wheel) does not work on Windows.
This updates the installation of py-pip on Windows to download and
use a zipapp of a specific pip version in order to install the wheel
pip version that is requested.
Diffstat (limited to 'var')
-rw-r--r-- | var/spack/repos/builtin/packages/py-pip/package.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/var/spack/repos/builtin/packages/py-pip/package.py b/var/spack/repos/builtin/packages/py-pip/package.py index e8a415b4ce..023eab21ec 100644 --- a/var/spack/repos/builtin/packages/py-pip/package.py +++ b/var/spack/repos/builtin/packages/py-pip/package.py @@ -2,8 +2,8 @@ # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) - import os +import sys from spack.package import * @@ -44,6 +44,15 @@ class PyPip(Package, PythonExtension): # Uses collections.MutableMapping depends_on("python@:3.9", when="@:19.1", type=("build", "run")) + resource( + name="pip-bootstrap", + url="https://bootstrap.pypa.io/pip/zipapp/pip-22.3.1.pyz", + checksum="c9363c70ad91d463f9492a8a2c89f60068f86b0239bd2a6aa77367aab5fefb3e", + when="platform=windows", + placement={"pip-22.3.1.pyz": "pip.pyz"}, + expand=False, + ) + 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"): @@ -58,7 +67,14 @@ class PyPip(Package, PythonExtension): # 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] + args = std_pip_args + ["--prefix=" + prefix, whl] + if sys.platform == "win32": + # On Windows for newer versions of pip, you must bootstrap pip first. + # In order to achieve this, use the pip.pyz zipapp version of pip to + # bootstrap the pip wheel install. + args.insert(0, os.path.join(self.stage.source_path, "pip.pyz")) + else: + args.insert(0, os.path.join(whl, "pip")) python(*args) def setup_dependent_package(self, module, dependent_spec): |