forked from spack/spack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Long overdue update for WarpX: in 2024, we updated our Python bindings to rely on the new pyAMReX package. This deprecates the old `py-warpx` package and adds a new dependency and variant to WarpX. Also deprecates old versions that we will not continue to support.
- Loading branch information
Showing
5 changed files
with
464 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,27 +3,36 @@ | |
# | ||
# SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
|
||
from spack.build_systems.python import PythonPipBuilder | ||
from spack.package import * | ||
|
||
|
||
class PyAmrex(PythonPackage, CudaPackage, ROCmPackage): | ||
class PyAmrex(CMakePackage, PythonExtension, CudaPackage, ROCmPackage): | ||
"""AMReX Python Bindings with pybind11""" | ||
|
||
homepage = "https://amrex-codes.github.io/amrex/" | ||
url = "https://github.com/AMReX-Codes/pyamrex/archive/refs/tags/24.04.tar.gz" | ||
url = "https://github.com/AMReX-Codes/pyamrex/archive/refs/tags/24.08.tar.gz" | ||
git = "https://github.com/AMReX-Codes/pyamrex.git" | ||
|
||
maintainers("ax3l", "RTSandberg", "sayerhs", "WeiqunZhang") | ||
|
||
license("BSD-3-Clause-LBNL") | ||
|
||
version("develop", branch="development") | ||
version("24.04", sha256="ab85695bb9644b702d0fc84e77205d264d27ba94999cab912c8a3212a7eb77fc") | ||
version("24.03", sha256="bf85b4ad35b623278cbaae2c07e22138545dec0732d15c4ab7c53be76a7f2315") | ||
version("24.08", sha256="e7179d88261f64744f392a2194ff2744fe323fe0e21d0742ba60458709a1b47e") | ||
version( | ||
"24.04", | ||
sha256="ab85695bb9644b702d0fc84e77205d264d27ba94999cab912c8a3212a7eb77fc", | ||
deprecated=True, | ||
) | ||
|
||
depends_on("cxx", type="build") # generated | ||
version( | ||
"24.03", | ||
sha256="bf85b4ad35b623278cbaae2c07e22138545dec0732d15c4ab7c53be76a7f2315", | ||
deprecated=True, | ||
) | ||
|
||
for v in ["24.04", "24.03"]: | ||
for v in ["24.08", "24.04", "24.03"]: | ||
depends_on("amrex@{0}".format(v), when="@{0}".format(v), type=("build", "link")) | ||
|
||
variant( | ||
|
@@ -33,6 +42,9 @@ class PyAmrex(PythonPackage, CudaPackage, ROCmPackage): | |
multi=True, | ||
description="Dimensionality", | ||
) | ||
# Spack defaults to False but pybind11 defaults to True (and IPO is highly | ||
# encouraged to be used with pybind11 projects) | ||
variant("ipo", default=True, description="CMake interprocedural optimization") | ||
variant("mpi", default=True, description="Build with MPI support") | ||
variant("openmp", default=False, description="Build with OpenMP support") | ||
variant( | ||
|
@@ -42,14 +54,21 @@ class PyAmrex(PythonPackage, CudaPackage, ROCmPackage): | |
values=("single", "double"), | ||
) | ||
variant("tiny_profile", default=False, description="Enable tiny profiling") | ||
variant("sycl", default=False, description="Enable SYCL backend") | ||
|
||
extends("python") | ||
|
||
depends_on("cxx", type="build") | ||
|
||
depends_on("[email protected]:", type="build") | ||
depends_on("[email protected]:", type=("build", "run")) | ||
depends_on("[email protected]:1", type=("build", "run")) | ||
depends_on("[email protected]:", type=("build", "run"), when="+mpi") | ||
depends_on("[email protected]:1", type=("build", "run")) | ||
depends_on("py-packaging@23:", type="build") | ||
depends_on("py-pip@23:", type="build") | ||
depends_on("py-setuptools@42:", type="build") | ||
depends_on("[email protected]:3", type="build") | ||
depends_on("py-[email protected]:", type="link") | ||
depends_on("[email protected]:", type=("build", "link")) | ||
depends_on("py-[email protected]:", type="build") | ||
|
||
# AMReX options | ||
# required variants | ||
|
@@ -63,53 +82,65 @@ class PyAmrex(PythonPackage, CudaPackage, ROCmPackage): | |
depends_on("amrex dimensions=3") | ||
with when("+mpi"): | ||
depends_on("amrex +mpi") | ||
with when("~mpi"): | ||
depends_on("amrex ~mpi") | ||
with when("+openmp"): | ||
depends_on("amrex +openmp") | ||
with when("~openmp"): | ||
depends_on("amrex ~openmp") | ||
with when("+tiny_profile"): | ||
depends_on("amrex +tiny_profile") | ||
with when("+cuda"): | ||
depends_on("amrex +cuda") | ||
# todo: how to forward cuda_arch? | ||
with when("~cuda"): | ||
depends_on("amrex ~cuda") | ||
with when("+rocm"): | ||
depends_on("amrex +rocm") | ||
# todo: how to forward amdgpu_target? | ||
with when("~rocm"): | ||
depends_on("amrex ~rocm") | ||
with when("+sycl"): | ||
depends_on("amrex +sycl") | ||
with when("~sycl"): | ||
depends_on("amrex ~sycl") | ||
|
||
depends_on("py-pytest", type="test") | ||
depends_on("py-pandas", type="test") | ||
depends_on("py-cupy", type="test", when="+cuda") | ||
|
||
phases = ("cmake", "build", "install", "pip_install_nodeps") | ||
build_targets = ["all", "pip_wheel"] | ||
|
||
tests_src_dir = "tests/" | ||
|
||
def setup_build_environment(self, env): | ||
spec = self.spec | ||
|
||
# disable superbuilds: use external dependencies | ||
env.set("AMREX_INTERNAL", "OFF") | ||
env.set("PYAMREX_CCACHE", "OFF") | ||
env.set("PYAMREX_IPO", "ON") | ||
env.set("PYBIND11_INTERNAL", "OFF") | ||
|
||
# configure to require the exact AMReX configs provided by Spack | ||
env.set("AMREX_SPACEDIM", ";".join(spec.variants["dimensions"].value)) | ||
env.set("AMREX_MPI", "ON" if spec.satisfies("+mpi") else "OFF") | ||
env.set("AMREX_OMP", "ON" if spec.satisfies("+omp") else "OFF") | ||
env.set("AMREX_PRECISION", spec.variants["precision"].value.upper()) | ||
with when("+cuda"): | ||
env.set("AMREX_GPU_BACKEND", "CUDA") | ||
with when("+rocm"): | ||
env.set("AMREX_GPU_BACKEND", "HIP") | ||
# with when("+sycl"): | ||
# env.set("AMREX_GPU_BACKEND", "SYCL") | ||
|
||
# control build parallelism | ||
env.set("CMAKE_BUILD_PARALLEL_LEVEL", make_jobs) | ||
def cmake_args(self): | ||
args = ["-DpyAMReX_amrex_internal=OFF", "-DpyAMReX_pybind11_internal=OFF"] | ||
return args | ||
|
||
def pip_install_nodeps(self, spec, prefix): | ||
"""Install everything from build directory.""" | ||
pip = spec["python"].command | ||
pip.add_default_arg("-m", "pip") | ||
|
||
args = PythonPipBuilder.std_args(self) + [ | ||
f"--prefix={prefix}", | ||
"--find-links=amrex-whl", | ||
"amrex", | ||
] | ||
|
||
with working_dir(self.build_directory): | ||
pip(*args) | ||
|
||
# todo: from PythonPipBuilder | ||
# ....execute_install_time_tests() | ||
|
||
def check(self): | ||
"""Checks after the build phase""" | ||
pytest = which("pytest") | ||
pytest(join_path(self.stage.source_path, self.tests_src_dir)) | ||
|
||
@run_after("install") | ||
@run_after("pip_install_nodeps") | ||
def copy_test_sources(self): | ||
"""Copy the example test files after the package is installed to an | ||
install test subdirectory for use during `spack test run`.""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,25 +11,47 @@ class PyPicmistandard(PythonPackage): | |
|
||
homepage = "https://picmi-standard.github.io" | ||
git = "https://github.com/picmi-standard/picmi.git" | ||
pypi = "picmistandard/picmistandard-0.26.0.tar.gz" | ||
pypi = "picmistandard/picmistandard-0.29.0.tar.gz" | ||
|
||
maintainers("ax3l", "dpgrote", "RemiLehe") | ||
|
||
version("master", branch="master") | ||
version("0.29.0", sha256="dc0bf3ddd3635df9935ac569b3085de387150c4f8e9851897078bb12d123dde8") | ||
version("0.28.0", sha256="aa980b0fb49fc3ff9c7e32b5927b3700c4660aefbf96567bac1f8c9c93bb7831") | ||
version("0.26.0", sha256="b22689f576d064bf0cd8f435621e912359fc2ee9347350eab845d2d36ebb62eb") | ||
version("0.25.0", sha256="3fe6a524822d382e52bfc9d3378249546075d28620969954c5ffb43e7968fb02") | ||
version("0.24.0", sha256="55a82adcc14b41eb612caf0d9e47b0e2a56ffc196a58b41fa0cc395c6924be9a") | ||
version("0.23.2", sha256="2853fcfaf2f226a88bb6063ae564832b7e69965294fd652cd2ac04756fa4599a") | ||
version("0.23.1", sha256="c7375010b7a3431b519bc0accf097f2aafdb520e2a0126f42895cb96dcc7dcf1") | ||
version("0.0.22", sha256="e234a431274254b22cd70be64d6555b383d98426b2763ea0c174cf77bf4d0890") | ||
version("0.0.21", sha256="930056a23ed92dac7930198f115b6248606b57403bffebce3d84579657c8d10b") | ||
version("0.0.20", sha256="9c1822eaa2e4dd543b5afcfa97940516267dda3890695a6cf9c29565a41e2905") | ||
version("0.0.19", sha256="4b7ba1330964fbfd515e8ea2219966957c1386e0896b92d36bd9e134afb02f5a") | ||
version("0.0.18", sha256="68c208c0c54b4786e133bb13eef0dd4824998da4906285987ddee84e6d195e71") | ||
version( | ||
"0.0.22", | ||
sha256="e234a431274254b22cd70be64d6555b383d98426b2763ea0c174cf77bf4d0890", | ||
deprecated=True, | ||
) | ||
version( | ||
"0.0.21", | ||
sha256="930056a23ed92dac7930198f115b6248606b57403bffebce3d84579657c8d10b", | ||
deprecated=True, | ||
) | ||
version( | ||
"0.0.20", | ||
sha256="9c1822eaa2e4dd543b5afcfa97940516267dda3890695a6cf9c29565a41e2905", | ||
deprecated=True, | ||
) | ||
version( | ||
"0.0.19", | ||
sha256="4b7ba1330964fbfd515e8ea2219966957c1386e0896b92d36bd9e134afb02f5a", | ||
deprecated=True, | ||
) | ||
version( | ||
"0.0.18", | ||
sha256="68c208c0c54b4786e133bb13eef0dd4824998da4906285987ddee84e6d195e71", | ||
deprecated=True, | ||
) | ||
|
||
depends_on("[email protected]:", type=("build", "run")) | ||
depends_on("[email protected]:1", type=("build", "run")) | ||
depends_on("[email protected]:1", type=("build", "run")) | ||
depends_on("[email protected]:", type=("build", "run")) | ||
depends_on("[email protected]:", type=("build", "run")) | ||
depends_on("py-setuptools", type="build") | ||
|
||
@property | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,10 @@ class PyPybind11(CMakePackage, PythonExtension): | |
depends_on("py-wheel", type="build") | ||
extends("python") | ||
|
||
# Spack defaults to False but pybind11 defaults to True (and IPO is highly | ||
# encouraged to be used) | ||
variant("ipo", default=True, description="CMake interprocedural optimization") | ||
|
||
with when("build_system=cmake"): | ||
generator("ninja") | ||
depends_on("[email protected]:", type="build") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.