From 407f68a67b2e5649de50406e00457f7eb6a4471c Mon Sep 17 00:00:00 2001 From: Andrew W Elble Date: Fri, 12 Nov 2021 11:45:07 -0500 Subject: new package: py-qiskit-aer and dependencies (#27198) * new package: py-qiskit-aer and dependencies +updates for dependencies * flake8 fix * forgot homepages * incorporate feedback * py-cmake and py-ninja to py-tweedledum, prevent py-cmake from completely rebuilding cmake * py-ninja: avoid rebuilding ninja * other feedback fixes * additional fixes --- .../repos/builtin/packages/muparserx/package.py | 14 ++++++ .../repos/builtin/packages/py-cmake/package.py | 7 +++ .../builtin/packages/py-fastjsonschema/package.py | 15 ++++++ .../repos/builtin/packages/py-ninja/package.py | 35 ++++++++++++++ .../packages/py-python-constraint/package.py | 15 ++++++ .../builtin/packages/py-qiskit-aer/package.py | 56 ++++++++++++++++++++++ .../builtin/packages/py-qiskit-terra/package.py | 34 +++++++++++++ .../repos/builtin/packages/py-retworkx/package.py | 18 +++++++ .../builtin/packages/py-scikit-build/package.py | 2 + .../repos/builtin/packages/py-symengine/package.py | 20 +++++--- .../builtin/packages/py-tweedledum/package.py | 25 ++++++++++ 11 files changed, 235 insertions(+), 6 deletions(-) create mode 100644 var/spack/repos/builtin/packages/muparserx/package.py create mode 100644 var/spack/repos/builtin/packages/py-fastjsonschema/package.py create mode 100644 var/spack/repos/builtin/packages/py-ninja/package.py create mode 100644 var/spack/repos/builtin/packages/py-python-constraint/package.py create mode 100644 var/spack/repos/builtin/packages/py-qiskit-aer/package.py create mode 100644 var/spack/repos/builtin/packages/py-qiskit-terra/package.py create mode 100644 var/spack/repos/builtin/packages/py-retworkx/package.py create mode 100644 var/spack/repos/builtin/packages/py-tweedledum/package.py diff --git a/var/spack/repos/builtin/packages/muparserx/package.py b/var/spack/repos/builtin/packages/muparserx/package.py new file mode 100644 index 0000000000..77997d7842 --- /dev/null +++ b/var/spack/repos/builtin/packages/muparserx/package.py @@ -0,0 +1,14 @@ +# Copyright 2013-2021 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) + + +class Muparserx(CMakePackage): + """A C++ Library for Parsing Expressions with Strings, Complex + Numbers, Vectors, Matrices and more. """ + + homepage = "https://beltoforion.de/en/muparserx/" + url = "https://github.com/beltoforion/muparserx/archive/refs/tags/v4.0.8.tar.gz" + + version('4.0.8', sha256='5913e0a4ca29a097baad1b78a4674963bc7a06e39ff63df3c73fbad6fadb34e1') diff --git a/var/spack/repos/builtin/packages/py-cmake/package.py b/var/spack/repos/builtin/packages/py-cmake/package.py index fab0dda083..7425eb116a 100644 --- a/var/spack/repos/builtin/packages/py-cmake/package.py +++ b/var/spack/repos/builtin/packages/py-cmake/package.py @@ -14,7 +14,14 @@ class PyCmake(PythonPackage): homepage = "https://cmake.org/" pypi = "cmake/cmake-3.18.0.tar.gz" + version('3.21.4', sha256='30fa5ed8a5ad66dcd263adb87f3ce3dc2d0ec0ac3958f5becff577e4b62cd065') version('3.18.0', sha256='52b98c5ee70b5fa30a8623e96482227e065292f78794eb085fdf0fecb204b79b') + depends_on('cmake@3.21.4', type=('build', 'link', 'run'), when='@3.21.4') depends_on('cmake@3.18.0', type=('build', 'link', 'run'), when='@3.18.0') depends_on('py-scikit-build', type='build') + + def build_args(self, spec, prefix): + args = [] + args.append('-DBUILD_CMAKE_FROM_SOURCE=OFF') + return args diff --git a/var/spack/repos/builtin/packages/py-fastjsonschema/package.py b/var/spack/repos/builtin/packages/py-fastjsonschema/package.py new file mode 100644 index 0000000000..61b0093298 --- /dev/null +++ b/var/spack/repos/builtin/packages/py-fastjsonschema/package.py @@ -0,0 +1,15 @@ +# Copyright 2013-2021 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) + + +class PyFastjsonschema(PythonPackage): + """Fast JSON schema validator for Python.""" + + homepage = "https://github.com/horejsek/python-fastjsonschema" + pypi = "fastjsonschema/fastjsonschema-2.15.1.tar.gz" + + version('2.15.1', sha256='671f36d225b3493629b5e789428660109528f373cf4b8a22bac6fa2f8191c2d2') + + depends_on('py-setuptools', type='build') diff --git a/var/spack/repos/builtin/packages/py-ninja/package.py b/var/spack/repos/builtin/packages/py-ninja/package.py new file mode 100644 index 0000000000..944163676f --- /dev/null +++ b/var/spack/repos/builtin/packages/py-ninja/package.py @@ -0,0 +1,35 @@ +# Copyright 2013-2021 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 os + + +class PyNinja(PythonPackage): + """Ninja is a small build system with a focus on speed.""" + + homepage = "https://ninja-build.org" + pypi = "ninja/ninja-1.10.2.tar.gz" + + version('1.10.2', sha256='bb5e54b9a7343b3a8fc6532ae2c169af387a45b0d4dd5b72c2803e21658c5791') + + depends_on('cmake@3.6:', type='build') + depends_on('py-scikit-build', type='build') + depends_on('ninja@1.10.2', type=('build', 'run'), when='@1.10.2') + + def patch(self): + os.unlink(join_path(self.stage.source_path, 'CMakeLists.txt')) + + @run_after('install') + def installit(self): + syntax_file = os.path.join(self.spec['ninja'].prefix.misc, + 'ninja_syntax.py') + bin_file = os.path.join(self.spec['ninja'].prefix.bin, + 'ninja') + dst = os.path.join(site_packages_dir, + 'ninja') + dstbin = os.path.join(dst, 'data', 'bin') + mkdirp(dstbin) + os.symlink(bin_file, os.path.join(dstbin, 'ninja')) + os.symlink(syntax_file, os.path.join(dst, 'ninja_syntax.py')) diff --git a/var/spack/repos/builtin/packages/py-python-constraint/package.py b/var/spack/repos/builtin/packages/py-python-constraint/package.py new file mode 100644 index 0000000000..1e79c487a0 --- /dev/null +++ b/var/spack/repos/builtin/packages/py-python-constraint/package.py @@ -0,0 +1,15 @@ +# Copyright 2013-2021 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) + + +class PyPythonConstraint(PythonPackage): + """Constraint Solving Problem resolver for Python""" + + homepage = "https://github.com/python-constraint/python-constraint" + pypi = "python-constraint/python-constraint-1.4.0.tar.bz2" + + version('1.4.0', sha256='501d6f17afe0032dfc6ea6c0f8acc12e44f992733f00e8538961031ef27ccb8e') + + depends_on('py-setuptools', type='build') diff --git a/var/spack/repos/builtin/packages/py-qiskit-aer/package.py b/var/spack/repos/builtin/packages/py-qiskit-aer/package.py new file mode 100644 index 0000000000..9f4b6af754 --- /dev/null +++ b/var/spack/repos/builtin/packages/py-qiskit-aer/package.py @@ -0,0 +1,56 @@ +# Copyright 2013-2021 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) + + +class PyQiskitAer(PythonPackage, CudaPackage): + """Aer is a high performance simulator for quantum circuits that + includes noise models""" + + homepage = "https://github.com/Qiskit/qiskit-aer" + pypi = "qiskit-aer/qiskit-aer-0.9.1.tar.gz" + + version('0.9.1', sha256='3bf5f615aaae7cc5f816c39a4e9108aabaed0cc894fb6f841e48ffd56574e7eb') + + depends_on('python@3.6:', type=('build', 'run')) + depends_on('py-setuptools@40.1.0:', type='build') + depends_on('py-numpy@1.16.3:', type=('build', 'run')) + depends_on('py-pybind11@2.6:', type='build') + depends_on('py-qiskit-terra@0.17.0:', type=('build', 'run')) + depends_on('py-scipy@1.0:', type=('build', 'run')) + depends_on('py-scikit-build@0.11.0:', type='build') + depends_on('py-cmake@:3.16,3.18:', type='build') + depends_on('mpi', when='+mpi') + depends_on('nlohmann-json@3.1.1:') + depends_on('spdlog@1.5.0:') + depends_on('muparserx@4.0.8:') + depends_on('blas') + depends_on('cuda@10.1:', when='+cuda') + + variant('mpi', default=True, description='Enable MPI support') + variant('gdr', default=True, description='Enable GDR support') + + def setup_build_environment(self, env): + env.set('DISABLE_CONAN', 'ON') + env.set('DISABLE_DEPENDENCY_INSTALL', '1') + env.set("CUDAHOSTCXX", spack_cxx) + + def build_args(self, spec, prefix): + args = [] + args.append('-DDISABLE_CONAN=ON') + if '~gdr' in self.spec: + args.append('-DAER_DISABLE_GDR=True') + else: + args.append('-DAER_DISABLE_GDR=False') + if '+mpi' in self.spec: + args.append('-DAER_MPI=True') + else: + args.append('-DAER_MPI=False') + if '+cuda' in self.spec: + args.append('-DAER_THRUST_BACKEND=CUDA') + cuda_archs = spec.variants['cuda_arch'].value + if 'none' not in cuda_archs: + args.append('-DCUDA_NVCC_FLAGS={0}'. + format(' '.join(self.cuda_flags(cuda_archs)))) + return args diff --git a/var/spack/repos/builtin/packages/py-qiskit-terra/package.py b/var/spack/repos/builtin/packages/py-qiskit-terra/package.py new file mode 100644 index 0000000000..fbbef84f37 --- /dev/null +++ b/var/spack/repos/builtin/packages/py-qiskit-terra/package.py @@ -0,0 +1,34 @@ +# Copyright 2013-2021 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) + + +class PyQiskitTerra(PythonPackage): + """Qiskit is an open-source SDK for working with quantum computers + at the level of extended quantum circuits, operators, and + algorithms.""" + + homepage = "https://github.com/Qiskit/qiskit-terra" + pypi = "qiskit-terra/qiskit-terra-0.18.3.tar.gz" + + version('0.18.3', sha256='8737c8f1f4c6f29ec2fb02d73023f4854a396c33f78f4629a861a3e48fc789cc') + + depends_on('python@3.6:', type=('build', 'run')) + depends_on('py-setuptools', type='build') + depends_on('py-cython@0.27.1:', type='build') + + depends_on('py-contextvars@2.4:', when='^python@:3.6', type=('build', 'run')) + depends_on('py-jsonschema@2.6:', type=('build', 'run')) + depends_on('py-retworkx@0.9.0:', type=('build', 'run')) + depends_on('py-numpy@1.17:', type=('build', 'run')) + depends_on('py-scipy@1.4:', type=('build', 'run')) + depends_on('py-ply@3.10:', type=('build', 'run')) + depends_on('py-psutil@5:', type=('build', 'run')) + depends_on('py-sympy@1.3:', type=('build', 'run')) + depends_on('py-dill@0.3:', type=('build', 'run')) + depends_on('py-fastjsonschema@2.10:', type=('build', 'run')) + depends_on('py-python-constraint@1.4:', type=('build', 'run')) + depends_on('py-python-dateutil@2.8.0:', type=('build', 'run')) + depends_on('py-symengine@0.7:', type=('build', 'run')) + depends_on('py-tweedledum@1.1:1', type=('build', 'run')) diff --git a/var/spack/repos/builtin/packages/py-retworkx/package.py b/var/spack/repos/builtin/packages/py-retworkx/package.py new file mode 100644 index 0000000000..512c67fbb4 --- /dev/null +++ b/var/spack/repos/builtin/packages/py-retworkx/package.py @@ -0,0 +1,18 @@ +# Copyright 2013-2021 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) + + +class PyRetworkx(PythonPackage): + """A high performance Python graph library implemented in Rust.""" + + homepage = "https://github.com/Qiskit/retworkx" + pypi = "retworkx/retworkx-0.5.0.tar.gz" + + version('0.10.2', sha256='ba81cb527de7ff338575905bb6fcbebdf2ab18ae800169a77ab863f855bf0951') + + depends_on('python@3.6:', type=('build', 'run')) + depends_on('py-setuptools', type='build') + depends_on('py-setuptools-rust', type='build') + depends_on('py-numpy@1.16.0:', type=('build', 'run')) diff --git a/var/spack/repos/builtin/packages/py-scikit-build/package.py b/var/spack/repos/builtin/packages/py-scikit-build/package.py index f6fab07c95..b8d49f7b95 100644 --- a/var/spack/repos/builtin/packages/py-scikit-build/package.py +++ b/var/spack/repos/builtin/packages/py-scikit-build/package.py @@ -20,8 +20,10 @@ class PyScikitBuild(PythonPackage): maintainers = ['coreyjadams'] + version('0.12.0', sha256='c32a415d2e7920a4a966b037403c93b02c8a958d8badf3c60abd4b4493f7d988') version('0.10.0', sha256='2beec252813b20327072c15e9d997f15972aedcc6a130d0154979ff0fdb1b010') depends_on('py-setuptools@28.0.0:', type=('build', 'run')) depends_on('py-packaging', type=('build', 'run')) depends_on('py-wheel@0.29.0:', type=('build', 'run')) + depends_on('py-distro', type=('build', 'run'), when='@0.11:') diff --git a/var/spack/repos/builtin/packages/py-symengine/package.py b/var/spack/repos/builtin/packages/py-symengine/package.py index 7b5b4d6eda..0411c455bf 100644 --- a/var/spack/repos/builtin/packages/py-symengine/package.py +++ b/var/spack/repos/builtin/packages/py-symengine/package.py @@ -12,16 +12,24 @@ class PySymengine(PythonPackage): homepage = "https://github.com/symengine/symengine.py" pypi = "symengine/symengine-0.2.0.tar.gz" git = "https://github.com/symengine/symengine.py.git" + phases = ['install'] - version('develop', branch='master') + version('master', branch='master') + # pypi source doesn't have necessary files in cmake directory + version('0.8.1', + url='https://github.com/symengine/symengine.py/archive/refs/tags/v0.8.1.tar.gz', + sha256='02fe79e6d5e9b39a1d4e6fee05a2c1d1b10fd032157c7738ed97e32406ffb087') version('0.2.0', sha256='78a14aea7aad5e7cbfb5cabe141581f9bba30e3c319690e5db8ad99fdf2d8885') # Build dependencies - depends_on('python@2.7:2.8,3.3:', type=('build', 'run')) + depends_on('python@2.7:2.8,3.3:', type=('build', 'run'), when='@0.2.0') + depends_on('python@3.6:3', type=('build', 'run'), when='@0.8.1:') depends_on('py-setuptools', type='build') - depends_on('py-cython@0.19.1:', type='build') - depends_on('cmake@2.8.7:', type='build') - depends_on('symengine@0.2.0:') + depends_on('py-cython@0.19.1:', type='build', when='@0.2.0') + depends_on('py-cython@0.29.24:', type='build', when='@0.8.1:') + depends_on('cmake@2.8.12:', type='build') + depends_on('symengine@0.2.0', when='@0.2.0') + depends_on('symengine@0.8.1', when='@0.8.1') - def build_args(self, spec, prefix): + def install_args(self, spec, prefix): return ['--symengine-dir={0}'.format(spec['symengine'].prefix)] diff --git a/var/spack/repos/builtin/packages/py-tweedledum/package.py b/var/spack/repos/builtin/packages/py-tweedledum/package.py new file mode 100644 index 0000000000..e6ed41ffbf --- /dev/null +++ b/var/spack/repos/builtin/packages/py-tweedledum/package.py @@ -0,0 +1,25 @@ +# Copyright 2013-2021 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) + + +class PyTweedledum(PythonPackage): + """tweedledum is a library for synthesis, compilation, and + optimization of quantum circuits. The library is written to be + scalable up to problem sizes in which quantum circuits outperform + classical ones. Also, it is meant to be used both independently + and alongside established tools.""" + + homepage = "https://github.com/boschmitt/tweedledum" + pypi = 'tweedledum/tweedledum-1.1.1.tar.gz' + + version('1.1.1', sha256='58d6f7a988b10c31be3faa1faf3e58288ef7e8159584bfa6ded45742f390309f') + depends_on('python@3.6:', type=('build', 'run')) + depends_on('py-setuptools@42:', type='build') + depends_on('py-scikit-build@0.12:', type='build') + depends_on('py-cmake@3.18:', type='build') + depends_on('py-ninja', type='build') + depends_on('py-wheel', type='build') + depends_on('eigen@3.3:') + depends_on('nlohmann-json@3.9.0:') -- cgit v1.2.3-70-g09d2