diff options
4 files changed, 158 insertions, 20 deletions
diff --git a/var/spack/repos/builtin/packages/py-flaky/package.py b/var/spack/repos/builtin/packages/py-flaky/package.py new file mode 100644 index 0000000000..7f83219c32 --- /dev/null +++ b/var/spack/repos/builtin/packages/py-flaky/package.py @@ -0,0 +1,17 @@ +# 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) + +from spack.package import * + + +class PyFlaky(PythonPackage): + """Flaky is a plugin for nose or pytest that automatically reruns flaky tests.""" + + homepage = "https://github.com/box/flaky" + pypi = "flaky/flaky-3.7.0.tar.gz" + + version("3.7.0", sha256="3ad100780721a1911f57a165809b7ea265a7863305acb66708220820caf8aa0d") + + depends_on("py-setuptools", type=("build")) diff --git a/var/spack/repos/builtin/packages/py-pennylane-lightning/package.py b/var/spack/repos/builtin/packages/py-pennylane-lightning/package.py index c834c94beb..d58b682587 100644 --- a/var/spack/repos/builtin/packages/py-pennylane-lightning/package.py +++ b/var/spack/repos/builtin/packages/py-pennylane-lightning/package.py @@ -7,20 +7,114 @@ from spack.package import * -class PyPennylaneLightning(PythonPackage): - """PennyLane-Lightning plugin""" +class PyPennylaneLightning(CMakePackage, PythonExtension): + """The PennyLane-Lightning plugin provides a fast state-vector simulator written in C++.""" - homepage = "https://github.com/PennyLaneAI/pennylane-lightning" - url = "https://github.com/PennyLaneAI/pennylane-lightning/archive/refs/tags/v0.28.0.tar.gz" - # using github for now, because pypi tarball is missing the CMakeLists.txt file - # pypi = "PennyLane-Lightning/PennyLane-Lightning-0.28.0.tar.gz" + homepage = "https://docs.pennylane.ai/projects/lightning" + git = "https://github.com/PennyLaneAI/pennylane-lightning.git" + url = "https://github.com/PennyLaneAI/pennylane-lightning/archive/refs/tags/v0.28.2.tar.gz" - version("0.28.0", sha256="f5849c2affb5fb57aca20feb40ca829d171b07db2304fde0a37c2332c5b09e18") + maintainers("mlxd", "AmintorDusko") + + version("master", branch="master") + version("0.29.0", sha256="da9912f0286d1a54051cc19cf8bdbdcd732795636274c95f376db72a88e52d85") + version( + "0.28.0", + sha256="f5849c2affb5fb57aca20feb40ca829d171b07db2304fde0a37c2332c5b09e18", + deprecated=True, + ) # on Spack v0.19.0 + + variant("blas", default=True, description="Build with BLAS support") + variant( + "dispatcher", + default=True, + description="Build with AVX2/AVX512 gate automatic dispatching support", + ) + variant("kokkos", default=True, description="Build with Kokkos support") + variant("openmp", default=True, description="Build with OpenMP support") + + variant("native", default=False, description="Build natively for given hardware") + variant("verbose", default=False, description="Build with full verbosity") + + variant("cpptests", default=False, description="Build CPP tests") + variant("cppbenchmarks", default=False, description="Build CPP benchmark examples") + + variant( + "build_type", + default="Release", + description="CMake build type", + values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel"), + ) + + extends("python") + + # hard dependencies + depends_on("cmake@3.21:3.24,3.25.2:", type="build") + depends_on("ninja", type=("run", "build")) + + # variant defined dependencies + depends_on("blas", when="+blas") + depends_on("kokkos@3.7.00", when="+kokkos") + depends_on("kokkos-kernels@3.7.00", when="+kokkos") + depends_on("llvm-openmp", when="+openmp %apple-clang") depends_on("python@3.8:", type=("build", "run")) depends_on("py-setuptools", type="build") - depends_on("cmake@3.16:", type="build") - - depends_on("py-ninja", type=("build", "run")) depends_on("py-numpy", type=("build", "run")) - # depends_on("py-pennylane@0.19:", type=("build", "run")) # circular dependency + depends_on("py-pybind11", type=("build")) + depends_on("py-pip", type="build") + depends_on("py-wheel", type="build") + # depends_on("py-pennylane@0.28:", type=("build", "run")) # circular dependency + + +class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder): + build_directory = "build" + + def cmake_args(self): + """ + Here we specify all variant options that can be dynamicaly specified at build time + """ + args = [ + self.define_from_variant("ENABLE_OPENMP", "openmp"), + self.define_from_variant("ENABLE_NATIVE", "native"), + self.define_from_variant("ENABLE_BLAS", "blas"), + self.define_from_variant("CMAKE_VERBOSE_MAKEFILE:BOOL", "verbose"), + self.define_from_variant("BUILD_TESTS", "cpptests"), + self.define_from_variant("BUILD_BENCHMARKS", "cppbenchmarks"), + self.define_from_variant("ENABLE_GATE_DISPATCHER", "dispatcher"), + ] + + if "+kokkos" in self.spec: + args += [ + "-DENABLE_KOKKOS=ON", + f"-DKokkos_Core_DIR={self.spec['kokkos'].home}", + f"-DKokkos_Kernels_DIR={self.spec['kokkos-kernels'].home}", + ] + else: + args += ["-DENABLE_KOKKOS=OFF"] + + return args + + def build(self, pkg, spec, prefix): + super().build(pkg, spec, prefix) + cm_args = ";".join( + [ + s[2:] + for s in self.cmake_args() + if s[2:] not in ["BUILD_TESTS:BOOL=ON", "BUILD_BENCHMARKS:BOOL=ON"] + ] + ) + args = ["-i", f"--define={cm_args}"] + python("setup.py", "build_ext", *args) + + def install(self, pkg, spec, prefix): + pip_args = std_pip_args + ["--prefix=" + prefix, "."] + pip(*pip_args) + super().install(pkg, spec, prefix) + + @run_after("install") + @on_package_attributes(run_tests=True) + def test_lightning_build(self): + with working_dir(self.stage.source_path): + pl_runner = Executable(self.prefix.bin.pennylane_lightning_test_runner) + pl_runner() diff --git a/var/spack/repos/builtin/packages/py-pennylane/package.py b/var/spack/repos/builtin/packages/py-pennylane/package.py index 4b2332847e..93c1a790e8 100644 --- a/var/spack/repos/builtin/packages/py-pennylane/package.py +++ b/var/spack/repos/builtin/packages/py-pennylane/package.py @@ -10,12 +10,19 @@ from spack.package import * class PyPennylane(PythonPackage): """PennyLane is a Python quantum machine learning library by Xanadu Inc.""" - homepage = "https://github.com/XanaduAI/pennylane" + homepage = "https://docs.pennylane.ai/" + git = "https://github.com/PennyLaneAI/pennylane.git" pypi = "PennyLane/PennyLane-0.28.0.tar.gz" - maintainers("marcodelapierre") + maintainers("mlxd", "AmintorDusko", "marcodelapierre") - version("0.28.0", sha256="2a6100c00277c1eb59eab6856cdad7b1237e9d1fbda98b1e15020bd5a64b10a8") + version("master", branch="master") + version("0.29.1", sha256="c5d662994b741afa69e4fdadc79a1b75840275138a8b7e0cfc5fd64b66a12eef") + version( + "0.28.0", + sha256="2a6100c00277c1eb59eab6856cdad7b1237e9d1fbda98b1e15020bd5a64b10a8", + deprecated=True, + ) depends_on("python@3.8:", type=("build", "run")) depends_on("py-setuptools", type="build") @@ -30,5 +37,21 @@ class PyPennylane(PythonPackage): depends_on("py-semantic-version@2.7:", type=("build", "run")) depends_on("py-autoray@0.3.1:", type=("build", "run")) depends_on("py-cachetools", type=("build", "run")) - depends_on("py-pennylane-lightning@0.28:", type=("build", "run")) + depends_on("py-pennylane-lightning@0.28.0:", type=("build", "run")) depends_on("py-requests", type=("build", "run")) + + # Test deps + depends_on("py-pytest", type="test") + depends_on("py-pytest-xdist@3.2:", type="test") + depends_on("py-pytest-mock", type="test") + depends_on("py-flaky", type="test") + + @run_after("install") + @on_package_attributes(run_tests=True) + def install_test(self): + with working_dir("tests"): + pl_dev_test = Executable(join_path(self.prefix, "bin", "pl-device-test")) + pl_dev_test("--device", "default.qubit", "--shots", "None", "--skip-ops") + pl_dev_test("--device", "default.qubit", "--shots", "10000", "--skip-ops") + pl_dev_test("--device", "lightning.qubit", "--shots", "None", "--skip-ops") + pl_dev_test("--device", "lightning.qubit", "--shots", "10000", "--skip-ops") diff --git a/var/spack/repos/builtin/packages/py-pytest-xdist/package.py b/var/spack/repos/builtin/packages/py-pytest-xdist/package.py index 6363451386..3c65b2da41 100644 --- a/var/spack/repos/builtin/packages/py-pytest-xdist/package.py +++ b/var/spack/repos/builtin/packages/py-pytest-xdist/package.py @@ -10,8 +10,9 @@ class PyPytestXdist(PythonPackage): """py.test xdist plugin for distributed testing and loop-on-failing mode""" homepage = "https://github.com/pytest-dev/pytest-xdist" - pypi = "pytest-xdist/pytest-xdist-1.30.0.tar.gz" + pypi = "pytest-xdist/pytest-xdist-3.2.0.tar.gz" + version("3.2.0", sha256="fa10f95a2564cd91652f2d132725183c3b590d9fdcdec09d3677386ecf4c1ce9") version("1.30.0", sha256="5d1b1d4461518a6023d56dab62fb63670d6f7537f23e2708459a557329accf48") version("1.29.0", sha256="3489d91516d7847db5eaecff7a2e623dba68984835dbe6cedb05ae126c4fb17f") version("1.27.0", sha256="a96ed691705882560fa3fc95531fbd4c224896c827f4004817eb2dcac4ba41a2") @@ -20,11 +21,14 @@ class PyPytestXdist(PythonPackage): version("1.16.0", sha256="42e5a1e5da9d7cff3e74b07f8692598382f95624f234ff7e00a3b1237e0feba2") depends_on("python@2.7:2.8,3.4:", type=("build", "run")) - depends_on("py-setuptools", type="build") + depends_on("py-setuptools@45.0:", type="build", when="@3.2.0:") + depends_on("py-setuptools", type="build", when="@:1.30.0") + depends_on("py-setuptools-scm@6.2.3: +toml", type="build", when="@3.2.0:") depends_on("py-execnet@1.1:", type=("build", "run")) - depends_on("py-pytest@4.4.0:", type=("build", "run"), when="@1.28.0:") + depends_on("py-pytest@6.2.0:", type=("build", "run"), when="@3.2.0:") + depends_on("py-pytest@4.4.0:", type=("build", "run"), when="@1.28.0:1.30.0") depends_on("py-pytest@3.6.0:", type=("build", "run"), when="@1.25.0:1.27.0") depends_on("py-pytest@3.0.0:", type=("build", "run"), when="@1.18.0:1.24.0") depends_on("py-pytest@2.7.0:", type=("build", "run"), when="@1.16.0:1.17.0") - depends_on("py-pytest-forked", type=("build", "run"), when="@1.19.0:") - depends_on("py-six", type=("build", "run"), when="@1.23.0:") + depends_on("py-pytest-forked", type=("build", "run"), when="@1.19.0:1") + depends_on("py-six", type=("build", "run"), when="@1.23.0:1") |