From 806f630c8f83d499e97eb201d63ad8c8f4659670 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Sat, 22 Apr 2023 11:01:15 -0500 Subject: [PATCH] (py-)codecov: not on pypi anymore, replace by static binary (#36809) * py-codecov: deprecate since not on pypi anymore * codecov: new package * [@spackbot] updating style on behalf of wdconinc * codecov: use github URL instead, multi-platform * fix: install to prefix.bin.codecov Co-authored-by: Adam J. Stewart * codecov: use versions lookup dict * codecov: versions -> _versions, fix style --------- Co-authored-by: wdconinc Co-authored-by: Adam J. Stewart --- .../repos/builtin/packages/codecov/package.py | 46 +++++++++++++++++++ .../builtin/packages/py-codecov/package.py | 8 +++- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 var/spack/repos/builtin/packages/codecov/package.py diff --git a/var/spack/repos/builtin/packages/codecov/package.py b/var/spack/repos/builtin/packages/codecov/package.py new file mode 100644 index 0000000000..f8594ed04b --- /dev/null +++ b/var/spack/repos/builtin/packages/codecov/package.py @@ -0,0 +1,46 @@ +# 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 platform + +from spack.package import * + + +class Codecov(Package): + """Codecov uploads coverage reports to Codecov for processing.""" + + homepage = "https://codecov.io" + + _versions = { + "0.4.1": { + "linux": { + "x86_64": "32cb14b5f3aaacd67f4c1ff55d82f037d3cd10c8e7b69c051f27391d2e66e15c" + }, + "darwin": { + "x86_64": "4ab0f06f06e9c4d25464f155b0aff36bfc1e8dbcdb19bfffd586beed1269f3af" + }, + "windows": { + "x86_64": "e0cda212aeaebe695509ce8fa2d608760ff70bc932003f544f1ad368ac5450a8" + }, + } + } + + system = platform.system().lower() + machine = platform.machine().lower() + + for ver in _versions: + if system in _versions[ver] and machine in _versions[ver][system]: + version(ver, sha256=_versions[ver][system][machine], expand=False) + + def url_for_version(self, version): + _url_base = f"https://github.com/codecov/uploader/releases/download/v{version}/codecov" + return _url_base + ".exe" if self.system == "windows" else _url_base + f"-{self.system}" + + def install(self, spec, prefix): + codecov = self.stage.archive_file + chmod = which("chmod") + chmod("+x", codecov) + mkdirp(prefix.bin) + install(codecov, prefix.bin.codecov) diff --git a/var/spack/repos/builtin/packages/py-codecov/package.py b/var/spack/repos/builtin/packages/py-codecov/package.py index f6e28b73cd..1823586f07 100644 --- a/var/spack/repos/builtin/packages/py-codecov/package.py +++ b/var/spack/repos/builtin/packages/py-codecov/package.py @@ -12,7 +12,13 @@ class PyCodecov(PythonPackage): homepage = "https://github.com/codecov/codecov-python" pypi = "codecov/codecov-2.0.15.tar.gz" - version("2.0.15", sha256="8ed8b7c6791010d359baed66f84f061bba5bd41174bf324c31311e8737602788") + # Since codecov has been removed from PyPI, py-codecov is deprecated. + # The new codecov uploader can be installed with the package codecov. + version( + "2.0.15", + sha256="8ed8b7c6791010d359baed66f84f061bba5bd41174bf324c31311e8737602788", + deprecated=True, + ) depends_on("py-setuptools", type=("build", "run")) depends_on("py-requests@2.7.9:", type=("build", "run"))