From 84d053262623b039a0ff729dfb41a5870c53e6f4 Mon Sep 17 00:00:00 2001 From: Cole Kendrick Date: Thu, 30 May 2024 11:58:28 -0700 Subject: [PATCH 1/5] Add option to build without MFEM --- CMakeLists.txt | 112 +++++++++++++++++++-------------- bindings/pylibROM/__init__.py | 12 +++- bindings/pylibROM/pylibROM.cpp | 6 ++ setup.py | 14 ++++- 4 files changed, 94 insertions(+), 50 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b8a0a5a..9b825a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,8 @@ project(_pylibROM) set(CMAKE_BUILD_TYPE Debug) set(PYBIND11_FINDPYTHON ON) +option (USE_MFEM "Build pylibROM with MFEM" OFF) + #=================== ScaLAPACK (optional) ================== option(BUILD_SCALAPACK "Build static ScaLAPACK for libROM" OFF) @@ -50,14 +52,18 @@ if (BUILD_LIBROM) # ) # add_custom_target(RUN_LIBROM_BUILD ALL DEPENDS LIBROM_BUILD) + option (LIBROM_BUILD_CMD "Command used to build libROM and dependencies" CACHE STRING "${LIBROM_SCRIPTS_DIR}/compile.sh -t ${LIBROM_DIR}/cmake/toolchains/simple.cmake") + if (USE_MFEM) + set(LIBROM_BUILD_CMD "${LIBROM_BUILD_CMD} -m -g") + endif() ExternalProject_Add( libROM SOURCE_DIR ${LIBROM_SCRIPTS_DIR} CONFIGURE_COMMAND "" BINARY_DIR ${LIBROM_DIR} - BUILD_COMMAND ${LIBROM_SCRIPTS_DIR}/compile.sh -m -g -t ${LIBROM_DIR}/cmake/toolchains/simple.cmake - INSTALL_COMMAND "" - ) + BUILD_COMMAND ${LIBROM_BUILD_CMD} + INSTALL_COMMAND "" + ) message("Building libROM dependency...") endif(BUILD_LIBROM) @@ -72,32 +78,33 @@ execute_process(COMMAND python3 -c "import mpi4py; print(mpi4py.get_include())" # # TODO(kevin): We do not bind mfem-related functions until we figure out how to type-cast SWIG Object. # # Until then, mfem-related functions need to be re-implemented on python-end, using PyMFEM. -find_library(MFEM mfem - "$ENV{MFEM_DIR}/lib" - "$ENV{MFEM_DIR}" - "${LIBROM_DIR}/dependencies/mfem") -find_library(HYPRE HYPRE - "$ENV{HYPRE_DIR}/lib" - "${LIBROM_DIR}/dependencies/hypre/src/hypre/lib") -find_library(PARMETIS parmetis - "$ENV{PARMETIS_DIR}/lib" - "$ENV{PARMETIS_DIR}/build/lib/libparmetis" - "${LIBROM_DIR}/dependencies/parmetis-4.0.3/build/lib/libparmetis") -find_library(METIS metis - "$ENV{METIS_DIR}/lib" - "$ENV{PARMETIS_DIR}/build/lib/libmetis" - "${LIBROM_DIR}/dependencies/parmetis-4.0.3/build/lib/libmetis") -find_path(MFEM_INCLUDES mfem.hpp - "$ENV{MFEM_DIR}/include" - "$ENV{MFEM_DIR}" - "${LIBROM_DIR}/dependencies/mfem") -find_path(HYPRE_INCLUDES HYPRE.h - "$ENV{HYPRE_DIR}/include" - "${LIBROM_DIR}/dependencies/hypre/src/hypre/include") -find_path(PARMETIS_INCLUDES metis.h - "$ENV{PARMETIS_DIR}/metis/include" - "${LIBROM_DIR}/dependencies/parmetis-4.0.3/metis/include") - +if (USE_MFEM) + find_library(MFEM mfem + "$ENV{MFEM_DIR}/lib" + "$ENV{MFEM_DIR}" + "${LIBROM_DIR}/dependencies/mfem") + find_library(HYPRE HYPRE + "$ENV{HYPRE_DIR}/lib" + "${LIBROM_DIR}/dependencies/hypre/src/hypre/lib") + find_library(PARMETIS parmetis + "$ENV{PARMETIS_DIR}/lib" + "$ENV{PARMETIS_DIR}/build/lib/libparmetis" + "${LIBROM_DIR}/dependencies/parmetis-4.0.3/build/lib/libparmetis") + find_library(METIS metis + "$ENV{METIS_DIR}/lib" + "$ENV{PARMETIS_DIR}/build/lib/libmetis" + "${LIBROM_DIR}/dependencies/parmetis-4.0.3/build/lib/libmetis") + find_path(MFEM_INCLUDES mfem.hpp + "$ENV{MFEM_DIR}/include" + "$ENV{MFEM_DIR}" + "${LIBROM_DIR}/dependencies/mfem") + find_path(HYPRE_INCLUDES HYPRE.h + "$ENV{HYPRE_DIR}/include" + "${LIBROM_DIR}/dependencies/hypre/src/hypre/include") + find_path(PARMETIS_INCLUDES metis.h + "$ENV{PARMETIS_DIR}/metis/include" + "${LIBROM_DIR}/dependencies/parmetis-4.0.3/metis/include") +endif() #===================== pylibROM ============================= @@ -105,30 +112,36 @@ set(CMAKE_CXX_STANDARD 14) find_package(MPI REQUIRED) -set(SOURCE_DIR "bindings/pylibROM") +set(SOURCE_DIR "bindings/pylibROM") include_directories( ${SOURCE_DIR} ${LIBROM_INCLUDE_DIR} ${MPI_INCLUDE_PATH} ${MPI4PY} ${HDF5_C_INCLUDE_DIRS} - ${MFEM_INCLUDES} - ${HYPRE_INCLUDES} - ${PARMETIS_INCLUDES} - ${MFEM_C_INCLUDE_DIRS} -) -link_libraries( - ${HDF5_LIBRARIES} - ${MFEM} - ${HYPRE} - ${PARMETIS} - ${METIS} ) +link_libraries(${HDF5_LIBRARIES}) + +if (USE_MFEM) + target_include_directories( + _pylibROM + ${MFEM_INCLUDES} + ${HYPRE_INCLUDES} + ${PARMETIS_INCLUDES} + ${MFEM_C_INCLUDE_DIRS}) + + target_link_libraries( + _pylibROM + ${MFEM} + ${HYPRE} + ${PARMETIS} + ${METIS}) +endif() add_subdirectory("extern/pybind11") -pybind11_add_module(_pylibROM - bindings/pylibROM/pylibROM.cpp +set(PYLIBROM_SOURCES + bindings/pylibROM/pylibROM.cpp bindings/pylibROM/linalg/pyMatrix.cpp bindings/pylibROM/linalg/pyVector.cpp @@ -165,12 +178,17 @@ pybind11_add_module(_pylibROM bindings/pylibROM/utils/pyHDFDatabase.cpp bindings/pylibROM/utils/pyCSVDatabase.cpp - bindings/pylibROM/mfem/pyUtilities.cpp - bindings/pylibROM/mfem/pyPointwiseSnapshot.cpp - bindings/pylibROM/mfem/pySampleMesh.cpp - bindings/pylibROM/python_utils/cpp_utils.hpp ) + +if (USE_MFEM) + set(PYLIBROM_SOURCES ${PYLIBROM_SOURCES} + bindings/pylibROM/mfem/pyUtilities.cpp + bindings/pylibROM/mfem/pyPointwiseSnapshot.cpp + bindings/pylibROM/mfem/pySampleMesh.cpp) +endif() + +pybind11_add_module(_pylibROM ${PYLIBROM_SOURCES}) message("building pylibROM...") target_link_libraries(_pylibROM PRIVATE ROM) diff --git a/bindings/pylibROM/__init__.py b/bindings/pylibROM/__init__.py index 8353c0f..19641a6 100644 --- a/bindings/pylibROM/__init__.py +++ b/bindings/pylibROM/__init__.py @@ -6,4 +6,14 @@ # either define/import the python routine in this file. # This will combine both c++ bindings/pure python routines into this module. -from _pylibROM import * +from _pylibROM.algo import * +from _pylibROM.hyperreduction import * +from _pylibROM.linalg import * + +try: + import _pylibROM.mfem + from _pylibROM.mfem import * +except: + pass + +from _pylibROM.utils import * diff --git a/bindings/pylibROM/pylibROM.cpp b/bindings/pylibROM/pylibROM.cpp index 6aa90ab..92d654e 100644 --- a/bindings/pylibROM/pylibROM.cpp +++ b/bindings/pylibROM/pylibROM.cpp @@ -1,5 +1,7 @@ #include +#include "CAROM_config.h" + namespace py = pybind11; //linalg @@ -47,10 +49,12 @@ void init_Database(pybind11::module_ &m); void init_HDFDatabase(pybind11::module_ &m); void init_CSVDatabase(pybind11::module_ &m); +#ifdef CAROM_HAS_MFEM //mfem void init_mfem_Utilities(pybind11::module_ &m); void init_mfem_PointwiseSnapshot(pybind11::module_ &m); void init_mfem_SampleMesh(pybind11::module_ &m); +#endif PYBIND11_MODULE(_pylibROM, m) { py::module utils = m.def_submodule("utils"); @@ -97,10 +101,12 @@ PYBIND11_MODULE(_pylibROM, m) { init_STSampling(hyperreduction); init_Utilities(hyperreduction); +#ifdef CAROM_HAS_MFEM py::module mfem = m.def_submodule("mfem"); init_mfem_Utilities(mfem); init_mfem_PointwiseSnapshot(mfem); init_mfem_SampleMesh(mfem); +#endif // py::module python_utils = m.def_submodule("python_utils"); } diff --git a/setup.py b/setup.py index 5d3cac1..d796d4c 100644 --- a/setup.py +++ b/setup.py @@ -16,6 +16,7 @@ # Take the global option for pre-installed librom directory. librom_dir = None install_scalapack = False +use_mfem = True for arg in sys.argv: if (arg[:13] == "--librom_dir="): librom_dir = arg[13:] @@ -23,6 +24,12 @@ if "--install_scalapack" in sys.argv: install_scalapack = True sys.argv.remove("--install_scalapack") +if "--no-mfem" in sys.argv: + use_mfem = False + sys.argv.remove("--no-mfem") +if "--use-mfem" in sys.argv: + use_mfem = True + sys.argv.remove("--use-mfem") # Convert distutils Windows platform specifiers to CMake -A arguments PLAT_TO_CMAKE = { @@ -64,8 +71,9 @@ def build_extension(self, ext: CMakeExtension) -> None: librom_dir += "/extern/libROM" print("Installing libROM library: %s" % librom_dir) - librom_cmd = "cd %s && ./scripts/compile.sh -m -g -t ./cmake/toolchains/simple.cmake" % librom_dir + librom_cmd = "cd %s && ./scripts/compile.sh -t ./cmake/toolchains/simple.cmake" % librom_dir if (install_scalapack): librom_cmd += " -s" + if (use_mfem): librom_cmd += " -m -g" print("libROM installation command: %s" % librom_cmd) subprocess.run( librom_cmd, shell=True, check=True @@ -73,6 +81,8 @@ def build_extension(self, ext: CMakeExtension) -> None: else: print("Using pre-installed libROM library: %s" % librom_dir) cmake_args += [f"-DLIBROM_DIR=%s" % librom_dir] + if (not use_mfem): + cmake_args += ["-DUSE_MFEM=OFF"] # Set Python_EXECUTABLE instead if you use PYBIND11_FINDPYTHON # EXAMPLE_VERSION_INFO shows you how to pass a value into the C++ code @@ -165,7 +175,7 @@ def build_extension(self, ext: CMakeExtension) -> None: # author_email="dean0x7d@gmail.com", description="Python Interface for LLNL libROM", long_description="", - packages=find_packages(where='bindings'), + packages=find_packages(where='bindings', exclude=['pylibROM.mfem'] if use_mfem == False else ['']), package_dir={"":"bindings"}, # packages=['bindings/pylibROM'], ext_modules=[CMakeExtension("_pylibROM")], From 621298cf80339eaf170a483363e6742d0b904280 Mon Sep 17 00:00:00 2001 From: Cole Kendrick Date: Thu, 30 May 2024 13:48:33 -0700 Subject: [PATCH 2/5] CMake adjustments and add config header for pylibROM --- CMakeLists.txt | 38 +++++++++++++++----------- bindings/pylibROM/pylibROM.cpp | 12 ++++++-- bindings/pylibROM/pylibROM_config.h.in | 6 ++++ setup.py | 4 +-- 4 files changed, 40 insertions(+), 20 deletions(-) create mode 100644 bindings/pylibROM/pylibROM_config.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b825a4..7985b64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,6 +104,7 @@ if (USE_MFEM) find_path(PARMETIS_INCLUDES metis.h "$ENV{PARMETIS_DIR}/metis/include" "${LIBROM_DIR}/dependencies/parmetis-4.0.3/metis/include") + set(PYLIBROM_HAS_MFEM 1) endif() #===================== pylibROM ============================= @@ -112,6 +113,9 @@ set(CMAKE_CXX_STANDARD 14) find_package(MPI REQUIRED) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bindings/pylibROM/pylibROM_config.h.in + ${CMAKE_CURRENT_SOURCE_DIR}/bindings/pylibROM/pylibROM_config.h) + set(SOURCE_DIR "bindings/pylibROM") include_directories( ${SOURCE_DIR} @@ -122,22 +126,6 @@ include_directories( ) link_libraries(${HDF5_LIBRARIES}) -if (USE_MFEM) - target_include_directories( - _pylibROM - ${MFEM_INCLUDES} - ${HYPRE_INCLUDES} - ${PARMETIS_INCLUDES} - ${MFEM_C_INCLUDE_DIRS}) - - target_link_libraries( - _pylibROM - ${MFEM} - ${HYPRE} - ${PARMETIS} - ${METIS}) -endif() - add_subdirectory("extern/pybind11") set(PYLIBROM_SOURCES @@ -191,4 +179,22 @@ endif() pybind11_add_module(_pylibROM ${PYLIBROM_SOURCES}) message("building pylibROM...") +if (USE_MFEM) + target_include_directories( + _pylibROM + PUBLIC + ${MFEM_INCLUDES} + ${HYPRE_INCLUDES} + ${PARMETIS_INCLUDES} + ${MFEM_C_INCLUDE_DIRS}) + + target_link_libraries( + _pylibROM + PUBLIC + ${MFEM} + ${HYPRE} + ${PARMETIS} + ${METIS}) +endif() + target_link_libraries(_pylibROM PRIVATE ROM) diff --git a/bindings/pylibROM/pylibROM.cpp b/bindings/pylibROM/pylibROM.cpp index 92d654e..fac8a8e 100644 --- a/bindings/pylibROM/pylibROM.cpp +++ b/bindings/pylibROM/pylibROM.cpp @@ -1,6 +1,14 @@ #include #include "CAROM_config.h" +#include "pylibROM_config.h" + +// check that libROM has MFEM if pylibROM is using MFEM +#ifdef PYLIBROM_HAS_MFEM +#ifndef CAROM_HAS_MFEM +#error "libROM was not compiled with MFEM support" +#endif +#endif namespace py = pybind11; @@ -49,7 +57,7 @@ void init_Database(pybind11::module_ &m); void init_HDFDatabase(pybind11::module_ &m); void init_CSVDatabase(pybind11::module_ &m); -#ifdef CAROM_HAS_MFEM +#ifdef PYLIBROM_HAS_MFEM //mfem void init_mfem_Utilities(pybind11::module_ &m); void init_mfem_PointwiseSnapshot(pybind11::module_ &m); @@ -101,7 +109,7 @@ PYBIND11_MODULE(_pylibROM, m) { init_STSampling(hyperreduction); init_Utilities(hyperreduction); -#ifdef CAROM_HAS_MFEM +#ifdef PYLIBROM_HAS_MFEM py::module mfem = m.def_submodule("mfem"); init_mfem_Utilities(mfem); init_mfem_PointwiseSnapshot(mfem); diff --git a/bindings/pylibROM/pylibROM_config.h.in b/bindings/pylibROM/pylibROM_config.h.in new file mode 100644 index 0000000..cf1ad19 --- /dev/null +++ b/bindings/pylibROM/pylibROM_config.h.in @@ -0,0 +1,6 @@ +#ifndef PYLIBROM_CONFIG_H_ +#define PYLIBROM_CONFIG_H_ + +#cmakedefine PYLIBROM_HAS_MFEM + +#endif diff --git a/setup.py b/setup.py index d796d4c..e8d4b3c 100644 --- a/setup.py +++ b/setup.py @@ -81,8 +81,8 @@ def build_extension(self, ext: CMakeExtension) -> None: else: print("Using pre-installed libROM library: %s" % librom_dir) cmake_args += [f"-DLIBROM_DIR=%s" % librom_dir] - if (not use_mfem): - cmake_args += ["-DUSE_MFEM=OFF"] + + cmake_args += ["-DUSE_MFEM={:s}".format('ON' if use_mfem else 'OFF')] # Set Python_EXECUTABLE instead if you use PYBIND11_FINDPYTHON # EXAMPLE_VERSION_INFO shows you how to pass a value into the C++ code From 6a366d444be8befa222a6a2f996599e235d83cb6 Mon Sep 17 00:00:00 2001 From: Cole Kendrick Date: Fri, 31 May 2024 14:19:08 -0700 Subject: [PATCH 3/5] Disable libROM mfem check temporarily --- bindings/pylibROM/pylibROM.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bindings/pylibROM/pylibROM.cpp b/bindings/pylibROM/pylibROM.cpp index fac8a8e..bd5c523 100644 --- a/bindings/pylibROM/pylibROM.cpp +++ b/bindings/pylibROM/pylibROM.cpp @@ -5,9 +5,10 @@ // check that libROM has MFEM if pylibROM is using MFEM #ifdef PYLIBROM_HAS_MFEM -#ifndef CAROM_HAS_MFEM -#error "libROM was not compiled with MFEM support" -#endif +// temporarily disabled until libROM upstream adds this option +// #ifndef CAROM_HAS_MFEM +// #error "libROM was not compiled with MFEM support" +// #endif #endif namespace py = pybind11; From 953efca1686d33636ba0e880708b907686ad51d3 Mon Sep 17 00:00:00 2001 From: Cole Kendrick Date: Tue, 11 Jun 2024 14:05:32 -0700 Subject: [PATCH 4/5] Update setup.py install with options --- CMakeLists.txt | 18 +++++++------- setup.py | 66 +++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 63 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7985b64..62c0ed3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,18 +52,18 @@ if (BUILD_LIBROM) # ) # add_custom_target(RUN_LIBROM_BUILD ALL DEPENDS LIBROM_BUILD) - option (LIBROM_BUILD_CMD "Command used to build libROM and dependencies" CACHE STRING "${LIBROM_SCRIPTS_DIR}/compile.sh -t ${LIBROM_DIR}/cmake/toolchains/simple.cmake") + set(LIBROM_BUILD_CMD "${LIBROM_SCRIPTS_DIR}/compile.sh -t ${LIBROM_DIR}/cmake/toolchains/simple.cmake" CACHE STRING "Command used to build libROM and dependencies") if (USE_MFEM) set(LIBROM_BUILD_CMD "${LIBROM_BUILD_CMD} -m -g") endif() - ExternalProject_Add( - libROM - SOURCE_DIR ${LIBROM_SCRIPTS_DIR} - CONFIGURE_COMMAND "" - BINARY_DIR ${LIBROM_DIR} - BUILD_COMMAND ${LIBROM_BUILD_CMD} - INSTALL_COMMAND "" - ) + # ExternalProject_Add( + # libROM + # SOURCE_DIR ${LIBROM_SCRIPTS_DIR} + # CONFIGURE_COMMAND "" + # BINARY_DIR ${LIBROM_DIR} + # BUILD_COMMAND ${LIBROM_BUILD_CMD} + # INSTALL_COMMAND "" + # ) message("Building libROM dependency...") endif(BUILD_LIBROM) diff --git a/setup.py b/setup.py index e8d4b3c..4783f83 100644 --- a/setup.py +++ b/setup.py @@ -8,10 +8,11 @@ # It recommends using "--config-settings", though there is no clear documentation about this. # For now, we enforce to use the versions < 23.3.0. import pkg_resources -pkg_resources.require(['pip < 23.3.0']) +#pkg_resources.require(['pip < 23.3.0']) from setuptools import Extension, setup, find_packages from setuptools.command.build_ext import build_ext +from setuptools.command.install import install as _install # Take the global option for pre-installed librom directory. librom_dir = None @@ -21,15 +22,15 @@ if (arg[:13] == "--librom_dir="): librom_dir = arg[13:] sys.argv.remove(arg) -if "--install_scalapack" in sys.argv: - install_scalapack = True - sys.argv.remove("--install_scalapack") -if "--no-mfem" in sys.argv: - use_mfem = False - sys.argv.remove("--no-mfem") -if "--use-mfem" in sys.argv: - use_mfem = True - sys.argv.remove("--use-mfem") +# if "--install_scalapack" in sys.argv: +# install_scalapack = True +# sys.argv.remove("--install_scalapack") +# if "--no-mfem" in sys.argv: +# use_mfem = False +# sys.argv.remove("--no-mfem") +# if "--use-mfem" in sys.argv: +# use_mfem = True +# sys.argv.remove("--use-mfem") # Convert distutils Windows platform specifiers to CMake -A arguments PLAT_TO_CMAKE = { @@ -48,6 +49,38 @@ def __init__(self, name: str, sourcedir: str = "") -> None: self.sourcedir = os.fspath(Path(sourcedir).resolve()) +class InstallBuild(_install): + + user_options = _install.user_options + [ + ("librom-dir=", None, "Path to libROM root directory. If specified, pylibROM will use this instead of compiling its own libROM."), + ("install-scalapack", None, "Enables SCALAPACK when building libROM."), + ("use-mfem", None, "Compile pylibROM with MFEM enabled."), + ("no-mfem", None, "Compile pylibROM without MFEM.") + ] + + negative_opt = dict(_install.negative_opt) + negative_opt.update({"no-mfem" : "use-mfem"}) + + def run(self): + _install.run(self) + + + def initialize_options(self): + _install.initialize_options(self) + self.librom_dir = None + self.install_scalapack = False + self.use_mfem = True + + + def finalize_options(self): + global librom_dir, install_scalapack, use_mfem + librom_dir = self.librom_dir + install_scalapack = self.install_scalapack + use_mfem = self.use_mfem + + _install.finalize_options(self) + + class CMakeBuild(build_ext): def build_extension(self, ext: CMakeExtension) -> None: # Must be in this form due to bug in .resolve() only fixed in Python 3.10+ @@ -64,11 +97,11 @@ def build_extension(self, ext: CMakeExtension) -> None: # Can be set with Conda-Build, for example. cmake_generator = os.environ.get("CMAKE_GENERATOR", "") - global librom_dir, install_scalapack + global librom_dir, install_scalapack, use_mfem cmake_args = [] if (librom_dir is None): librom_dir = os.path.dirname(os.path.realpath(__file__)) - librom_dir += "/extern/libROM" + librom_dir += "/extern/libROM/" print("Installing libROM library: %s" % librom_dir) librom_cmd = "cd %s && ./scripts/compile.sh -t ./cmake/toolchains/simple.cmake" % librom_dir @@ -166,6 +199,14 @@ def build_extension(self, ext: CMakeExtension) -> None: ) + def initialize_options(self): + build_ext.initialize_options(self) + + + def finalize_options(self): + build_ext.finalize_options(self) + + # The information here can also be placed in setup.cfg - better separation of # logic and declaration, and simpler if you include description/version in a file. setup( @@ -181,6 +222,7 @@ def build_extension(self, ext: CMakeExtension) -> None: ext_modules=[CMakeExtension("_pylibROM")], cmdclass={ "build_ext": CMakeBuild, + "install": InstallBuild }, zip_safe=False, extras_require={"test": ["pytest>=6.0"]}, From f6ce75e07a25858fa795ea1a49820a533e801616 Mon Sep 17 00:00:00 2001 From: Cole Kendrick Date: Thu, 26 Sep 2024 07:59:21 -0700 Subject: [PATCH 5/5] Revert to manual parsing due to pip issues --- setup.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/setup.py b/setup.py index 4783f83..e3f06b7 100644 --- a/setup.py +++ b/setup.py @@ -18,19 +18,20 @@ librom_dir = None install_scalapack = False use_mfem = True +# TODO: fix this.. passing options through pip to setuptools with PEP517 is not working for arg in sys.argv: - if (arg[:13] == "--librom_dir="): + if (arg[:13] == "--librom_dir=" or arg[:13] == "--librom-dir="): librom_dir = arg[13:] sys.argv.remove(arg) -# if "--install_scalapack" in sys.argv: -# install_scalapack = True -# sys.argv.remove("--install_scalapack") -# if "--no-mfem" in sys.argv: -# use_mfem = False -# sys.argv.remove("--no-mfem") -# if "--use-mfem" in sys.argv: -# use_mfem = True -# sys.argv.remove("--use-mfem") + if (arg[:19] == "--install_scalapack"): + install_scalapack = True + sys.argv.remove(arg) + if (arg[:9] == "--no-mfem"): + use_mfem = False + sys.argv.remove(arg) + if (arg[:10] == "--use-mfem"): + use_mfem = True + sys.argv.remove(arg) # Convert distutils Windows platform specifiers to CMake -A arguments PLAT_TO_CMAKE = { @@ -195,7 +196,7 @@ def build_extension(self, ext: CMakeExtension) -> None: ["cmake", ext.sourcedir, *cmake_args], cwd=build_temp, check=True ) subprocess.run( - ["cmake", "--build", ".", *build_args], cwd=build_temp, check=True + ["cmake", "--build", ".", "-j 8", "-v", *build_args], cwd=build_temp, check=True )