Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable building of spack issm installation with wrappers #186

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
84 changes: 84 additions & 0 deletions packages/access-triangle/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Copyright 2013-2024 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)
# ----------------------------------------------------------------------------
#
# spack install access-triangle-git
#
# You can edit this file again by typing:
#
# spack edit access-triangle-git
#
# ----------------------------------------------------------------------------

from spack.package import *
import glob
import os

Check failure on line 17 in packages/access-triangle/package.py

View workflow job for this annotation

GitHub Actions / Check syntax

packages/access-triangle/package.py:17:8: F401 `os` imported but unused


class AccessTriangle(MakefilePackage):
"""Spack package for the ISSM Triangle library."""

homepage = "https://github.com/ACCESS-NRI/issm-triangle"
git = 'https://github.com/ACCESS-NRI/issm-triangle.git'

version('main')

# # If on some systems 'gmake' is truly required, keep it. Otherwise, 'make'
# # is often sufficient because Spack sets MAKE appropriately.
depends_on('gmake', type='build')
depends_on('libx11', type='link')

def url_for_version(self, version):
return "https://github.com/ACCESS-NRI/issm-triangle/archive/refs/heads/{0}.tar.gz".format(version)

def edit(self, spec, prefix):
"""
Below, we just copy in the 'configs'
so that the build can find them in `self.build_directory`.
"""
src_dir = join_path(self.stage.source_path, "src")
mkdirp(src_dir)

# Copy necessary files to src directory
install('configs/makefile', src_dir)
install('configs/linux/configure.make', src_dir)
install('triangle.c', src_dir)
install('triangle.h', src_dir)

def build(self, spec, prefix):
"""
This is where we actually call `make shared`.
Using MakefilePackage, you *could* rely on build_targets,
but we'll be explicit here so you can see it clearly.
"""
with working_dir(join_path(self.stage.source_path, "src")):
make('shared')

#raise an exception

Check failure on line 59 in packages/access-triangle/package.py

View workflow job for this annotation

GitHub Actions / Check syntax

packages/access-triangle/package.py:59:9: E265 Block comment should start with `# `

def install(self, spec, prefix):
"""
Copy the resulting library and headers into the Spack prefix.
"""
src = join_path(self.stage.source_path, "src")

# Create prefix directories
mkdirp(prefix.include)
mkdirp(prefix.lib)

with working_dir(src):
# Make sure we see what's actually there, for debugging:
ls_output = Executable('ls')('-l', '.', output=str, error=str)
print("Files in build directory:\n", ls_output)

install('triangle.h', prefix.include)

for libfile in glob.glob("libtriangle.*"):
install(libfile, prefix.lib)





122 changes: 101 additions & 21 deletions packages/issm/package.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,137 @@
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
# Copyright 2013-2023 Lawrence Livermore National Security,
# LLC and other Spack Project Developers. See the top-level COPYRIGHT
# file for details.
#
# Copyright 2023 Angus Gibson
# Modified by Justin Kin Jun Hew, 2025
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack.package import *
import os

Check failure on line 11 in packages/issm/package.py

View workflow job for this annotation

GitHub Actions / Check syntax

packages/issm/package.py:11:8: F401 `os` imported but unused
import subprocess

Check failure on line 12 in packages/issm/package.py

View workflow job for this annotation

GitHub Actions / Check syntax

packages/issm/package.py:12:8: F401 `subprocess` imported but unused


class Issm(AutotoolsPackage):
"""Ice-sheet and Sea-Level System Model"""

homepage = "https://issm.jpl.nasa.gov/"
git = "https://github.com/ISSMteam/ISSM.git"
git = "https://github.com/ACCESS-NRI/ISSM.git"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stick to the style used in the rest of the SPRs.


version("develop")
version("4.24", sha256="0487bd025f37be4a39dfd48b047de6a6423e310dfe5281dbd9a52aa35b26151a")
#version("4.24", sha256="c71d870e63f0ce3ae938d6a669e80dc2cecef827084db31a4b2cfc3a26a44820")

Check failure on line 21 in packages/issm/package.py

View workflow job for this annotation

GitHub Actions / Check syntax

packages/issm/package.py:21:5: E265 Block comment should start with `# `

version("main", branch="main", git="https://github.com/ACCESS-NRI/ISSM.git")
version("access-development", branch="access-development", git="https://github.com/ACCESS-NRI/ISSM.git")

#
# Variants
#
variant("wrappers", default=False,
description="Enable building with MPI wrappers")

# If you want to make external Fortran linking optional or specialized,
# you can create a separate variant for it, but typically you might
# rely on Spack's compiler wrappers for Fortran libraries.

#
# Build dependencies
#
depends_on("autoconf", type="build")
depends_on("automake", type="build")
depends_on("libtool", type="build")
depends_on("m4", type="build")

depends_on("libtool", type="build")
depends_on("m4", type="build")

# Required libraries
#
depends_on("mpi")
depends_on("petsc+metis+mumps+scalapack")
depends_on("m1qn3")

#
# Optional libraries
#
depends_on('access-triangle', when='+wrappers')
depends_on("parmetis", when="+wrappers")
# depends_on("python@3.9.0:3.9", when="+wrappers", type=("build", "run"))
# depends_on("py-numpy", when="+wrappers", type=("build", "run"))

def url_for_version(self, version):
return "https://github.com/ISSMteam/ISSM/tarball/v{0}".format(version)
# Example of how you might form a URL for a particular version:
#branch = "access-development"

Check failure on line 60 in packages/issm/package.py

View workflow job for this annotation

GitHub Actions / Check syntax

packages/issm/package.py:60:9: E265 Block comment should start with `# `
return "https://github.com/ACCESS-NRI/ISSM/archive/refs/heads/{0}.tar.gz".format(version)

def autoreconf(self, spec, prefix):
# If the repo has an Autotools build system, run autoreconf:
autoreconf("--install", "--verbose", "--force")

def setup_run_environment(self, env):
env.prepend_path("LD_LIBRARY_PATH", self.prefix.lib)

def configure_args(self):
"""Populate configure arguments, including optional flags to mimic
your manual `./configure` invocation on Gadi."""
args = [
"--with-wrappers=no",
"--enable-debugging",
"--enable-development",
"--enable-shared",
"--without-kriging",
"--enable-debugging",
"--enable-development",
"--enable-shared",
"--without-kriging",
]
args.append("--with-petsc-dir={0}".format(self.spec["petsc"].prefix))
args.append("--with-metis-dir={0}".format(self.spec["metis"].prefix))
args.append("--with-mumps-dir={0}".format(self.spec["mumps"].prefix))
args.append("--with-m1qn3-dir={0}".format(self.spec["m1qn3"].prefix.lib))

# Even though we set the MPI compilers manually, the build system
# wants us to explicitly request an MPI-enabled build by telling
# it the MPI include directory.
#
# Wrappers
#
if "+wrappers" in self.spec:
args.append("--with-wrappers=yes")
else:
args.append("--with-wrappers=no")

#
# MPI: Even if we use Spack's MPI wrappers, the build system may
# want explicit mention of MPI includes and compilers:
#
args.append("--with-mpi-include={0}".format(self.spec["mpi"].prefix.include))
args.append("CC=" + self.spec["mpi"].mpicc)
args.append("CXX=" + self.spec["mpi"].mpicxx)
args.append("FC=" + self.spec["mpi"].mpifc)
args.append("F77=" + self.spec["mpi"].mpif77)

#
# PETSc, MUMPS, METIS, SCALAPACK, etc.
# (Spack typically puts these in the compiler/link environment,
# but if the ISSM configure script looks for explicit --with-*
# flags, we pass them.)
#
args.append("--with-petsc-dir={0}".format(self.spec["petsc"].prefix))
args.append("--with-metis-dir={0}".format(self.spec["metis"].prefix))
args.append("--with-mumps-dir={0}".format(self.spec["mumps"].prefix))
# If you rely on sca/lapack from PETSc, these lines might
# not be strictly necessary. If ISSM's configure script
# checks them individually, add them:
args.append("--with-scalapack-dir={0}".format(self.spec["scalapack"].prefix))
args.append("--with-parmetis-dir={0}".format(self.spec["parmetis"].prefix))
args.append("--with-triangle-dir={0}".format(self.spec["access-triangle"].prefix))

#
# M1QN3
#
# Some codes want the actual library subdir for m1qn3,
# e.g. "prefix.lib" or "prefix" depending on the configure logic:
#
args.append("--with-m1qn3-dir={0}".format(self.spec["m1qn3"].prefix.lib))
args.append("--with-python-version=3.9")
args.append("--with-python-dir=/apps/python3/3.9.2")


numpy_site_packages = "/apps/python3/3.9.2/lib/python3.9/site-packages/numpy-1.20.0-py3.9-linux-x86_64.egg/numpy"

Check failure on line 125 in packages/issm/package.py

View workflow job for this annotation

GitHub Actions / Check syntax

packages/issm/package.py:125:9: F841 Local variable `numpy_site_packages` is assigned to but never used
numpy_core_dir = "/apps/python3/3.9.2/lib/python3.9/site-packages/numpy-1.20.0-py3.9-linux-x86_64.egg/numpy"
args.append("--with-python-numpy-dir={0}".format(numpy_core_dir))

return args

def install(self, spec, prefix):
# Run the normal Autotools install logic
super().install(spec, prefix)

# Copy the entire source tree into an additional directory
install_tree(self.stage.source_path, prefix.src)
Comment on lines +135 to +136
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that the ISSM Spack package should install all the source? That's very unusual.


Loading