From 24048b35456633516f0d82b90efe9ea717b108a8 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Mon, 26 Jul 2021 02:55:51 -0500 Subject: [PATCH] py-pyprecice: simplify package (#25077) --- .../deactivate-version-check-via-pip.patch | 32 ------------------- .../builtin/packages/py-pyprecice/package.py | 31 ++++++------------ 2 files changed, 10 insertions(+), 53 deletions(-) delete mode 100644 var/spack/repos/builtin/packages/py-pyprecice/deactivate-version-check-via-pip.patch diff --git a/var/spack/repos/builtin/packages/py-pyprecice/deactivate-version-check-via-pip.patch b/var/spack/repos/builtin/packages/py-pyprecice/deactivate-version-check-via-pip.patch deleted file mode 100644 index e7b13aa666..0000000000 --- a/var/spack/repos/builtin/packages/py-pyprecice/deactivate-version-check-via-pip.patch +++ /dev/null @@ -1,32 +0,0 @@ -diff --git a/setup.py b/setup.py -index 9282639..d69c285 100644 ---- a/setup.py -+++ b/setup.py -@@ -1,15 +1,20 @@ - import os - import subprocess - import warnings --from packaging import version --import pip -+from setuptools._vendor.packaging import version -+ -+# If installed with pip we need to check its version -+try: -+ import pip -+ if version.parse(pip.__version__) < version.parse("19.0"): -+ # version 19.0 is required, since we are using pyproject.toml for definition of build-time depdendencies. See https://pip.pypa.io/en/stable/news/#id209 -+ warnings.warn("You are using pip version {}. However, pip version > 19.0 is recommended. You can continue with the installation, but installation problems can occour. Please refer to https://github.com/precice/python-bindings#build-time-dependencies-cython-numpy-defined-in-pyprojecttoml-are-not-installed-automatically for help.".format(pip.__version__)) - --if version.parse(pip.__version__) < version.parse("19.0"): -- # version 19.0 is required, since we are using pyproject.toml for definition of build-time depdendencies. See https://pip.pypa.io/en/stable/news/#id209 -- warnings.warn("You are using pip version {}. However, pip version > 19.0 is recommended. You can continue with the installation, but installation problems can occour. Please refer to https://github.com/precice/python-bindings#build-time-dependencies-cython-numpy-defined-in-pyprojecttoml-are-not-installed-automatically for help.".format(pip.__version__)) -+ if version.parse(pip.__version__) < version.parse("10.0.1"): -+ warnings.warn("You are using pip version {}. However, pip version > 10.0.1 is required. If you continue with installation it is likely that you will face an error. See https://github.com/precice/python-bindings#version-of-pip3-is-too-old".format(pip.__version__)) -+except: -+ warnings.warn("Assuming that you are not using pip!") - --if version.parse(pip.__version__) < version.parse("10.0.1"): -- warnings.warn("You are using pip version {}. However, pip version > 10.0.1 is required. If you continue with installation it is likely that you will face an error. See https://github.com/precice/python-bindings#version-of-pip3-is-too-old".format(pip.__version__)) - - from enum import Enum - from setuptools import setup diff --git a/var/spack/repos/builtin/packages/py-pyprecice/package.py b/var/spack/repos/builtin/packages/py-pyprecice/package.py index 422873d350..792802fe31 100644 --- a/var/spack/repos/builtin/packages/py-pyprecice/package.py +++ b/var/spack/repos/builtin/packages/py-pyprecice/package.py @@ -30,11 +30,6 @@ class PyPyprecice(PythonPackage): version("2.0.0.2", sha256="5f055d809d65ec2e81f4d001812a250f50418de59990b47d6bcb12b88da5f5d7") version("2.0.0.1", sha256="96eafdf421ec61ad6fcf0ab1d3cf210831a815272984c470b2aea57d4d0c9e0e") - # Older versions of the bindings checked versions via pip. This patch - # removes the pip dependency. - # See also https://github.com/spack/spack/pull/19558 - patch("deactivate-version-check-via-pip.patch", when="@:2.1.1.1") - depends_on("precice@develop", when="@develop") depends_on("precice@2.2.1", when="@2.2.1.1:2.2.1.99") depends_on("precice@2.2.0", when="@2.2.0.1:2.2.0.99") @@ -44,22 +39,16 @@ class PyPyprecice(PythonPackage): depends_on("precice@2.0.1", when="@2.0.1.1:2.0.1.99") depends_on("precice@2.0.0", when="@2.0.0.1:2.0.0.99") - depends_on("python@3:", type=("build", "run")) + depends_on("python@3:", type=("build", "link", "run")) depends_on("py-setuptools", type="build") - depends_on("py-numpy", type=("build", "run")) + depends_on("py-numpy", type=("build", "link", "run")) depends_on("py-mpi4py", type=("build", "run")) - depends_on("py-cython@0.29:", type=("build")) + depends_on("py-cython@0.29:", type="build") + depends_on("py-packaging", when="@:2.1", type="build") + depends_on("py-pip", when="@:2.1", type="build") - phases = ['install_lib', 'build_ext', 'install'] - - def build_ext_args(self, spec, prefix): - return [ - "--include-dirs=" + spec["precice"].headers.directories[0], - "--library-dirs=" + spec["precice"].libs.directories[0] - ] - - def install(self, spec, prefix): - # Older versions of the bindings had a non-standard installation routine - # See also https://github.com/spack/spack/pull/19558#discussion_r513123239 - if self.version <= Version("2.1.1.1"): - self.setup_py("install", "--prefix={0}".format(prefix)) + @when("@:2.1") + def patch(self): + filter_file( + "distutils.command.install", "setuptools.command.install", "setup.py" + )