From 8a1b69c1d3b93ba2f9b787f53bb93282448c3bdf Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sat, 4 May 2024 01:21:41 +0200 Subject: [PATCH] Modernize py-torch-geometric and dependencies (#43984) * Modernize py-torch-geometric and dependencies * Forgot one maintainer --- .../packages/py-torch-cluster/package.py | 49 +++++++---- .../packages/py-torch-geometric/package.py | 83 ++++++++----------- .../packages/py-torch-scatter/package.py | 48 +++++++---- .../packages/py-torch-sparse/package.py | 57 +++++++++---- .../packages/py-torch-spline-conv/package.py | 46 ++++++---- 5 files changed, 173 insertions(+), 110 deletions(-) diff --git a/var/spack/repos/builtin/packages/py-torch-cluster/package.py b/var/spack/repos/builtin/packages/py-torch-cluster/package.py index 685019395f..02eabb6f33 100644 --- a/var/spack/repos/builtin/packages/py-torch-cluster/package.py +++ b/var/spack/repos/builtin/packages/py-torch-cluster/package.py @@ -7,25 +7,33 @@ class PyTorchCluster(PythonPackage): - """This package consists of a small extension library of highly optimized graph cluster - algorithms for the use in PyTorch. - """ + """PyTorch Extension Library of Optimized Graph Cluster Algorithms.""" homepage = "https://github.com/rusty1s/pytorch_cluster" - url = "https://github.com/rusty1s/pytorch_cluster/archive/1.5.7.tar.gz" + pypi = "torch-cluster/torch_cluster-1.6.3.tar.gz" + git = "https://github.com/rusty1s/pytorch_cluster.git" license("MIT") + maintainers("adamjstewart") - version("1.6.3", sha256="0e2b08095e03cf87ce9b23b7a7352236a25d3ed92d92351dc020fd927ea8dbfe") - version("1.5.8", sha256="95c6e81e9c4a6235e1b2152ab917021d2060ad995199f6bd7fb39986d37310f0") - version("1.5.7", sha256="71701d2f7f3e458ebe5904c982951349fdb60e6f1654e19c7e102a226e2de72e") - - variant("cuda", default=False, description="Enables CUDA support") + version("1.6.3", sha256="78d5a930a5bbd0d8788df8c6d66addd68d6dd292fe3edb401e3dacba26308152") + version( + "1.5.8", + sha256="a0a32f63faac40a026ab1e9da31f6babdb4d937e53be40bd1c91d9b5a286eee6", + deprecated=True, + ) + version( + "1.5.7", + sha256="62a3ec1bebadda1a4a2c867203f4c957b9c0b9d11ffb03b40b8ea9f95a0a4d3b", + deprecated=True, + ) + depends_on("python", type=("build", "link", "run")) depends_on("py-setuptools", type="build") depends_on("py-scipy", type=("build", "run")) - depends_on("py-torch+cuda", when="+cuda", type=("build", "link", "run")) - depends_on("py-torch~cuda", when="~cuda", type=("build", "link", "run")) + + # Undocumented dependencies + depends_on("py-torch", type=("build", "link", "run")) # https://github.com/rusty1s/pytorch_cluster/issues/120 depends_on("py-torch~openmp", when="@:1.5 %apple-clang", type=("build", "link", "run")) @@ -34,8 +42,19 @@ class PyTorchCluster(PythonPackage): depends_on("py-pytest-runner", when="@:1.5", type="build") def setup_build_environment(self, env): - if "+cuda" in self.spec: - env.set("FORCE_CUDA", "1") - env.set("CUDA_HOME", self.spec["cuda"].prefix) + if self.spec.satisfies("@1.5.9:"): + if "+cuda" in self.spec["py-torch"]: + env.set("FORCE_CUDA", 1) + env.set("FORCE_ONLY_CUDA", 0) + env.set("FORCE_ONLY_CPU", 0) + else: + env.set("FORCE_CUDA", 0) + env.set("FORCE_ONLY_CUDA", 0) + env.set("FORCE_ONLY_CPU", 1) else: - env.set("FORCE_CUDA", "0") + if "+cuda" in self.spec["py-torch"]: + env.set("FORCE_CUDA", 1) + env.set("FORCE_CPU", 0) + else: + env.set("FORCE_CUDA", 0) + env.set("FORCE_CPU", 1) diff --git a/var/spack/repos/builtin/packages/py-torch-geometric/package.py b/var/spack/repos/builtin/packages/py-torch-geometric/package.py index e9820c2bdc..be0cc9a790 100644 --- a/var/spack/repos/builtin/packages/py-torch-geometric/package.py +++ b/var/spack/repos/builtin/packages/py-torch-geometric/package.py @@ -8,57 +8,51 @@ class PyTorchGeometric(PythonPackage): - """PyTorch Geometric (PyG) is a geometric deep learning extension - library for PyTorch. It consists of various methods for deep - learning on graphs and other irregular structures, also known as - geometric deep learning, from a variety of published papers. In - addition, it consists of an easy-to-use mini-batch loader for many - small and single giant graphs, multi gpu-support, a large number - of common benchmark datasets (based on simple interfaces to create - your own), and helpful transforms, both for learning on arbitrary - graphs as well as on 3D meshes or point clouds.""" + """Graph Neural Network Library for PyTorch.""" - homepage = "https://github.com/pyg-team/pytorch_geometric" - pypi = "torch-geometric/torch_geometric-2.1.0.post1.tar.gz" + homepage = "https://pyg.org/" + pypi = "torch-geometric/torch_geometric-2.5.3.tar.gz" + git = "https://github.com/pyg-team/pytorch_geometric.git" license("MIT") + maintainers("adamjstewart") + version("2.5.3", sha256="ad0761650c8fa56cdc46ee61c564fd4995f07f079965fe732b3a76d109fd3edc") version( - "2.1.0.post1", sha256="32347402076ccf60fa50312825178f1e3e5ce5e7b3b3a8b2729ac699da24525d" + "2.1.0.post1", + sha256="32347402076ccf60fa50312825178f1e3e5ce5e7b3b3a8b2729ac699da24525d", + deprecated=True, + ) + version( + "1.6.3", + sha256="347f693bebcc8a621eda4867dafab91c04db5f596d7ed7ecb89b242f8ab5c6a1", + deprecated=True, + ) + version( + "1.6.0", + sha256="fbf43fe15421c9affc4fb361ba4db55cb9d3c64d0c29576bb58d332bf6d27fef", + deprecated=True, ) - version("1.6.3", sha256="347f693bebcc8a621eda4867dafab91c04db5f596d7ed7ecb89b242f8ab5c6a1") - version("1.6.0", sha256="fbf43fe15421c9affc4fb361ba4db55cb9d3c64d0c29576bb58d332bf6d27fef") - variant("cuda", default=False, description="Enable CUDA support") + depends_on("py-flit-core@3.2:3", when="@2.4:", type="build") - # setup.py - depends_on("python@3.7:", when="@2:", type=("build", "run")) - depends_on("python@3.6:", type=("build", "run")) - depends_on("py-setuptools", type="build") - depends_on("py-tqdm", type=("build", "run")) - depends_on("py-numpy", type=("build", "run")) - depends_on("py-scipy", type=("build", "run")) - depends_on("py-jinja2", type=("build", "run")) - depends_on("py-requests", type=("build", "run")) - depends_on("py-pyparsing", when="@2:", type=("build", "run")) - depends_on("py-scikit-learn", type=("build", "run")) + with default_args(type=("build", "run")): + depends_on("py-tqdm") + depends_on("py-numpy") + depends_on("py-scipy") + depends_on("py-fsspec", when="@2.5:") + depends_on("py-jinja2") + depends_on("py-aiohttp", when="@2.5:") + depends_on("py-requests") + depends_on("py-pyparsing", when="@1.7.2:") + depends_on("py-scikit-learn") + depends_on("py-psutil@5.8:", when="@2.2:") - # README.md - depends_on("py-torch-scatter+cuda", when="+cuda", type=("build", "run")) - depends_on("py-torch-scatter~cuda", when="~cuda", type=("build", "run")) - depends_on("py-torch-sparse+cuda", when="+cuda", type=("build", "run")) - depends_on("py-torch-sparse~cuda", when="~cuda", type=("build", "run")) + # Undocumented dependencies + depends_on("py-torch") - # Optional dependencies - depends_on("py-torch-cluster+cuda", when="+cuda", type=("build", "run")) - depends_on("py-torch-cluster~cuda", when="~cuda", type=("build", "run")) - depends_on("py-torch-spline-conv+cuda", when="+cuda", type=("build", "run")) - depends_on("py-torch-spline-conv~cuda", when="~cuda", type=("build", "run")) - - # Undocumented dependencies - depends_on("py-torch", type=("build", "run")) - - # Historic or optional dependencies + # Historical dependencies + depends_on("py-setuptools", type="build", when="@:2.3") with when("@:1"): depends_on("py-pytest-runner", type="build") depends_on("py-networkx", type=("build", "run")) @@ -69,10 +63,3 @@ class PyTorchGeometric(PythonPackage): depends_on("py-googledrivedownloader", type=("build", "run")) depends_on("py-h5py~mpi", type=("build", "run")) depends_on("py-ase", type=("build", "run")) - - def setup_build_environment(self, env): - if "+cuda" in self.spec: - env.set("FORCE_CUDA", "1") - env.set("CUDA_HOME", self.spec["cuda"].prefix) - else: - env.set("FORCE_CUDA", "0") diff --git a/var/spack/repos/builtin/packages/py-torch-scatter/package.py b/var/spack/repos/builtin/packages/py-torch-scatter/package.py index e1aea29192..cd9c395d68 100644 --- a/var/spack/repos/builtin/packages/py-torch-scatter/package.py +++ b/var/spack/repos/builtin/packages/py-torch-scatter/package.py @@ -7,29 +7,45 @@ class PyTorchScatter(PythonPackage): - """This package consists of a small extension library of - highly optimized sparse update (scatter and segment) - operations for the use in PyTorch, which are missing in the - main package.""" + """PyTorch Extension Library of Optimized Scatter Operations.""" homepage = "https://github.com/rusty1s/pytorch_scatter" - url = "https://github.com/rusty1s/pytorch_scatter/archive/2.0.5.tar.gz" + pypi = "torch-scatter/torch_scatter-2.1.2.tar.gz" + git = "https://github.com/rusty1s/pytorch_scatter.git" license("MIT") + maintainers("adamjstewart") - version("2.0.5", sha256="e29b364beaa9c84a99e0e236be89ed19d4452d89010ff736184ddcce488b47f6") + version("2.1.2", sha256="69b3aa435f2424ac6a1bfb6ff702da6eb73b33ca0db38fb26989c74159258e47") + version( + "2.0.5", + sha256="148fbe634fb9e9465dbde2ab337138f63650ed8abbac42bb3f565e3fe92e9b2f", + deprecated=True, + ) - variant("cuda", default=False, description="Enable CUDA support") - - depends_on("python@3.6:", type=("build", "run")) + depends_on("python", type=("build", "link", "run")) depends_on("py-setuptools", type="build") - depends_on("py-pytest-runner", type="build") - depends_on("py-torch+cuda", when="+cuda") - depends_on("py-torch~cuda", when="~cuda") + + # Undocumented dependencies + depends_on("py-torch", type=("build", "link", "run")) + + # Historical dependencies + depends_on("py-pytest-runner", type="build", when="@:2.0.7") def setup_build_environment(self, env): - if "+cuda" in self.spec: - env.set("FORCE_CUDA", "1") - env.set("CUDA_HOME", self.spec["cuda"].prefix) + if self.spec.satisfies("@2.0.6:"): + if "+cuda" in self.spec["py-torch"]: + env.set("FORCE_CUDA", 1) + env.set("FORCE_ONLY_CUDA", 0) + env.set("FORCE_ONLY_CPU", 0) + else: + env.set("FORCE_CUDA", 0) + env.set("FORCE_ONLY_CUDA", 0) + env.set("FORCE_ONLY_CPU", 1) else: - env.set("FORCE_CUDA", "0") + if "+cuda" in self.spec["py-torch"]: + env.set("FORCE_CUDA", 1) + env.set("FORCE_CPU", 0) + else: + env.set("FORCE_CUDA", 0) + env.set("FORCE_CPU", 1) diff --git a/var/spack/repos/builtin/packages/py-torch-sparse/package.py b/var/spack/repos/builtin/packages/py-torch-sparse/package.py index 8df9e1bd62..cac8ffff3b 100644 --- a/var/spack/repos/builtin/packages/py-torch-sparse/package.py +++ b/var/spack/repos/builtin/packages/py-torch-sparse/package.py @@ -7,31 +7,54 @@ class PyTorchSparse(PythonPackage): - """This package consists of a small extension library of - optimized sparse matrix operations with autograd support.""" + """PyTorch Extension Library of Optimized Autograd Sparse Matrix Operations.""" - homepage = "https://github.com/rusty1s/pytorch_sparse/" - url = "https://github.com/rusty1s/pytorch_sparse/archive/0.6.7.tar.gz" + homepage = "https://github.com/rusty1s/pytorch_sparse" + pypi = "torch-sparse/torch_sparse-0.6.18.tar.gz" + git = "https://github.com/rusty1s/pytorch_sparse.git" license("MIT") + maintainers("adamjstewart") - version("0.6.17", sha256="c964a70ed978bff65009250eb12fae96317c60c9a04d7d1b07f0beee8b4b9c22") - version("0.6.8", sha256="98f7ff1f0f9cd5031bc81c70c11970c3864545ae33677025a6efd2466a97e6f9") - version("0.6.7", sha256="0d038a1502548692972a085cd0496460b5d2050bb7328427add990f081d6c44d") - - variant("cuda", default=False, description="Enable CUDA support") + version("0.6.18", sha256="2f14c510a6e93f404c6ea357210615b3c15a71731f9dbd86f25434e34fb5a741") + version("0.6.17", sha256="06e268dd77f73eb641da8f9383306d7afac6423383c9197b9df120955e2a96bd") + version("0.6.8", sha256="312fb5ae6e4e575fca4bbc0bd092af85e7679d5b8e53459f24492fc2a073c7b6") + version("0.6.7", sha256="f69b2ed35baf2a9853234756a2b19e6f7ce88d2c1f029d1c7ca166d91e1adbd0") depends_on("py-setuptools", type="build") - depends_on("py-pytest-runner", when="@:0.6.8", type="build") depends_on("py-scipy", type=("build", "run")) - depends_on("py-torch", type=("build", "run")) - depends_on("py-torch-scatter+cuda", when="+cuda") - depends_on("py-torch-scatter~cuda", when="~cuda") + + # Undocumented dependencies + depends_on("py-torch", type=("build", "link", "run")) + depends_on("py-torch-scatter", type=("build", "run")) depends_on("parallel-hashmap", when="@0.6.17:") + # Historical dependencies + depends_on("py-pytest-runner", when="@:0.6.8", type="build") + + def patch(self): + # Force build against externally-installed hashmap + filter_file( + "include_dirs=[extensions_dir, phmap_dir]", + "include_dirs=[extensions_dir]", + "setup.py", + string=True, + ) + def setup_build_environment(self, env): - if "+cuda" in self.spec: - env.set("FORCE_CUDA", "1") - env.set("CUDA_HOME", self.spec["cuda"].prefix) + if self.spec.satisfies("@0.6.9:"): + if "+cuda" in self.spec["py-torch"]: + env.set("FORCE_CUDA", 1) + env.set("FORCE_ONLY_CUDA", 0) + env.set("FORCE_ONLY_CPU", 0) + else: + env.set("FORCE_CUDA", 0) + env.set("FORCE_ONLY_CUDA", 0) + env.set("FORCE_ONLY_CPU", 1) else: - env.set("FORCE_CUDA", "0") + if "+cuda" in self.spec["py-torch"]: + env.set("FORCE_CUDA", 1) + env.set("FORCE_CPU", 0) + else: + env.set("FORCE_CUDA", 0) + env.set("FORCE_CPU", 1) diff --git a/var/spack/repos/builtin/packages/py-torch-spline-conv/package.py b/var/spack/repos/builtin/packages/py-torch-spline-conv/package.py index b861734b49..537a31739a 100644 --- a/var/spack/repos/builtin/packages/py-torch-spline-conv/package.py +++ b/var/spack/repos/builtin/packages/py-torch-spline-conv/package.py @@ -7,27 +7,45 @@ class PyTorchSplineConv(PythonPackage): - """This is a PyTorch implementation of the spline-based - convolution operator of SplineCNN.""" + """Implementation of the Spline-Based Convolution Operator of SplineCNN in PyTorch.""" homepage = "https://github.com/rusty1s/pytorch_spline_conv" - url = "https://github.com/rusty1s/pytorch_spline_conv/archive/1.2.0.tar.gz" + pypi = "torch-spline-conv/torch_spline_conv-1.2.2.tar.gz" + git = "https://github.com/rusty1s/pytorch_spline_conv.git" license("MIT") + maintainers("adamjstewart") - version("1.2.0", sha256="ab8da41357c8a4785662366655bb6dc5e84fd0e938008194955409aefe535009") + version("1.2.2", sha256="ed45a81da29f774665dbdd4709d7e534cdf16d2e7006dbd06957f35bd09661b2") + version( + "1.2.0", + sha256="b7a1788004f6c6143d47040f2dd7d8a579a0c69a0cb0b5d7537416bf37c082a5", + deprecated=True, + ) - variant("cuda", default=False, description="Enable CUDA support") - - depends_on("python@3.6:", type=("build", "run")) + depends_on("python", type=("build", "link", "run")) depends_on("py-setuptools", type="build") - depends_on("py-pytest-runner", type="build") - depends_on("py-torch+cuda", when="+cuda") - depends_on("py-torch~cuda", when="~cuda") + + # Undocumented dependencies + depends_on("py-torch", type=("build", "link", "run")) + + # Historical dependencies + depends_on("py-pytest-runner", type="build", when="@:1.2.1") def setup_build_environment(self, env): - if "+cuda" in self.spec: - env.set("FORCE_CUDA", "1") - env.set("CUDA_HOME", self.spec["cuda"].prefix) + if self.spec.satisfies("@1.2.1:"): + if "+cuda" in self.spec["py-torch"]: + env.set("FORCE_CUDA", 1) + env.set("FORCE_ONLY_CUDA", 0) + env.set("FORCE_ONLY_CPU", 0) + else: + env.set("FORCE_CUDA", 0) + env.set("FORCE_ONLY_CUDA", 0) + env.set("FORCE_ONLY_CPU", 1) else: - env.set("FORCE_CUDA", "0") + if "+cuda" in self.spec["py-torch"]: + env.set("FORCE_CUDA", 1) + env.set("FORCE_CPU", 0) + else: + env.set("FORCE_CUDA", 0) + env.set("FORCE_CPU", 1)