Skip to content

Commit

Permalink
merge: Merge branch 'chore/update_spack_config' into 'main'
Browse files Browse the repository at this point in the history
Update spack config

See merge request numerics/solver/comma!57
  • Loading branch information
Riccardo Milani committed Aug 19, 2024
2 parents 9818dbb + f64fb7f commit 2cff454
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 15 deletions.
48 changes: 33 additions & 15 deletions config_files/spack/comma/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ class Comma(CMakePackage):
variant("python", when="@1.2:", description="Install python bindings", default=True)
variant("codaflags", when="@1.1:", description="Compile with usual CODA flags", default=False)
variant("doc", when="@1.3.1:", description="Build Doxygen documentation", default=False)
# In recent version is always on
variant(
"pkgconfig",
when="@1.3.1:1.3.2",
when="@1.3.1:1.3.2", # In recent versions is always on
description="Add pkg-config configuration file",
default=True
default=True,
)
variant(
"int64",
Expand All @@ -67,27 +66,46 @@ class Comma(CMakePackage):

extends("python", when="+python")
depends_on("python", type=("build", "link", "run"), when="+python")
depends_on("py-pybind11", type=("build", "link", "run"), when="@develop:+python")
depends_on(
"[email protected]:",
type=("build", "link", "run"),
when="@develop:+python^[email protected]:"
)
depends_on(
"[email protected]:",
type=("build", "link", "run"),
when="@develop:+python^[email protected]:"
)

# older versions always had a Python dependency
extends("python", when="@1.0:1.1")
depends_on("python", type=("build", "link", "run"), when="@1.0:1.1")

depends_on("py-pybind11", type=("build", "link", "run"), when="@develop:+python")
# MAJOR SHAMEFUL HACK
# The version of pybind11 included in <=1.3.2 does not support python>=3.11. In order to make
# this work for any version of spack, if needed, we get the right version of pybind11 as
# resource and apply a patch to make cmake use this latter instead of the
# default one
PYTHONVER_TO_PYBINDVER = {"3.11": "2.10.0", "3.12": "2.12.0"}
for pythonver, pybindver in PYTHONVER_TO_PYBINDVER.items():
depends_on(
"py-pybind11@{}:".format(pybindver),
type=("build", "link", "run"),
when="@develop:+python^python@{}".format(pythonver),
)
for commaver, ptch in [
("1.0", "python312_v10.patch"),
("1.1", "python312_v11.patch"),
("1.2", "python312_v13.patch"), # Same as 1.3
("1.3.0", "python312_v13.patch"),
("1.3.1", "python312_v131.patch"),
("1.3.2", "python312_v132.patch"),
]:
with when("@{}^python@{}".format(commaver, pythonver)):
patch(ptch)
resource(
name="pybind11",
git="https://github.com/pybind/pybind11.git",
tag="v{}".format(pybindver),
destination="pybind11new", # That's what we put in the patch
)

# However, see this bug report https://github.com/spack/spack/issues/29447
depends_on("catch2", type=("test",), when="@develop:")

# Require C++17 compilers
conflicts("%gcc@:8.1.9", msg="Compiler supporting C++17 required")
conflicts("%gcc@:8.9.9", msg="Compiler supporting C++17 required")
conflicts("%clang@:5.9.9", msg="Compiler supporting C++17 required")
conflicts("%intel@:19.9.9", msg="Compiler supporting C++17 required")

Expand Down
13 changes: 13 additions & 0 deletions config_files/spack/comma/python312_v10.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cc76cf5..6015a87 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -102,7 +102,7 @@ target_link_libraries(Comma_test gcov)
#target_link_libraries(Comma_test Boost)
#set_source_files_properties( Comma_test PROPERTIES COMPILE_FLAGS "--coverage" )
######################## Pybind11 bindings ####################################
-add_subdirectory(pybind11)
+add_subdirectory(pybind11new/pybind11)
pybind11_add_module(CoMMA ${IMPLEMENTATION} ${INTERFACCIA} ${SOURCE_FILES})


11 changes: 11 additions & 0 deletions config_files/spack/comma/python312_v11.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a2e301f..f922bfe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -103,5 +103,5 @@ target_link_libraries(Comma_test gcov)
#target_link_libraries(Comma_test Boost)
#set_source_files_properties( Comma_test PROPERTIES COMPILE_FLAGS "--coverage" )
######################## Pybind11 bindings ####################################
-add_subdirectory(pybind11)
+add_subdirectory(pybind11new/pybind11)
pybind11_add_module(CoMMA ${PYTHONBIND})
12 changes: 12 additions & 0 deletions config_files/spack/comma/python312_v13.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 72bc024..eebceab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -124,6 +124,6 @@ endif()
######################## Pybind11 bindings ####################################
if ( BUILD_PYTHON_BINDINGS )
message("Python bindings enabled")
- add_subdirectory(pybind11)
+ add_subdirectory(pybind11new/pybind11)
pybind11_add_module(${PROJECT_NAME} ${PYTHONBIND})
endif()
13 changes: 13 additions & 0 deletions config_files/spack/comma/python312_v131.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3afa4de..653b4eb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -140,7 +140,7 @@ if ( BUILD_PYTHON_BINDINGS )
message(STATUS "Python bindings enabled")
# find the Python interpreter (including pybind might lead to other find files being used)
find_package(Python COMPONENTS Interpreter Development)
- add_subdirectory(pybind11)
+ add_subdirectory(pybind11new/pybind11)
pybind11_add_module(${PROJECT_NAME} ${PYTHONBIND})
endif()

13 changes: 13 additions & 0 deletions config_files/spack/comma/python312_v132.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9cf2c7e..bcdfa0e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -168,7 +168,7 @@ if ( BUILD_PYTHON_BINDINGS )
message(STATUS "Python bindings enabled")
# find the Python interpreter (including pybind might lead to other find files being used)
find_package(Python COMPONENTS Interpreter Development)
- add_subdirectory(pybind11)
+ add_subdirectory(pybind11new/pybind11)
pybind11_add_module(${CoMMA_PYTHON} ${PYTHONBIND})
target_link_libraries(${CoMMA_PYTHON} PUBLIC ${CoMMA_LIB})
endif()

0 comments on commit 2cff454

Please sign in to comment.