From f27063de3248bc599b03579087d220625101f071 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Mon, 27 May 2024 23:09:58 -0400 Subject: [PATCH 01/29] add submodule for pybind11 --- .gitmodules | 4 ++++ extern/pybind11 | 1 + 2 files changed, 5 insertions(+) create mode 100644 .gitmodules create mode 160000 extern/pybind11 diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..062cc71e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "extern/pybind11"] + path = extern/pybind11 + url = ../../pybind/pybind11 + branch = stable diff --git a/extern/pybind11 b/extern/pybind11 new file mode 160000 index 00000000..01ab9356 --- /dev/null +++ b/extern/pybind11 @@ -0,0 +1 @@ +Subproject commit 01ab935612a6800c4ad42957808d6cbd30047902 From 78626732e0bd7a00feeaab78c3a1b352b1303f18 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Tue, 28 May 2024 00:13:23 -0400 Subject: [PATCH 02/29] rename CMake project to fvsolver --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 195b8ea6..21b00a29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,7 @@ elseif (LINUX) endif() cmake_minimum_required(VERSION 3.13) -project(numerics) +project(fvsolver) set(CMAKE_CXX_STANDARD 14) enable_language(CXX) enable_language(C) From 3c1431ce3793405dc2a615492beb8e125d53d50d Mon Sep 17 00:00:00 2001 From: jcschaff Date: Tue, 28 May 2024 00:15:48 -0400 Subject: [PATCH 03/29] start pyvcell-fvsolver with trivial pybind11 example, adds two numbers --- CMakeLists.txt | 5 ++++- pyvcell-fvsolver/CMakeLists.txt | 14 ++++++++++++++ pyvcell-fvsolver/include/add.h | 10 ++++++++++ pyvcell-fvsolver/src/add.cpp | 6 ++++++ pyvcell-fvsolver/src/example.cpp | 10 ++++++++++ 5 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 pyvcell-fvsolver/CMakeLists.txt create mode 100644 pyvcell-fvsolver/include/add.h create mode 100644 pyvcell-fvsolver/src/add.cpp create mode 100644 pyvcell-fvsolver/src/example.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 21b00a29..fbd8f630 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,7 +44,7 @@ elseif (LINUX) endif() endif() -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.13...3.27) project(fvsolver) set(CMAKE_CXX_STANDARD 14) enable_language(CXX) @@ -255,6 +255,9 @@ endif() add_subdirectory(qhull) endif () + add_subdirectory(extern/pybind11) + add_subdirectory(pyvcell-fvsolver) + include(FetchContent) FetchContent_Declare( googletest diff --git a/pyvcell-fvsolver/CMakeLists.txt b/pyvcell-fvsolver/CMakeLists.txt new file mode 100644 index 00000000..1bc03c0a --- /dev/null +++ b/pyvcell-fvsolver/CMakeLists.txt @@ -0,0 +1,14 @@ +project(example) + +set(HEADER_FILES + include/add.h +) + +set(SOURCE_FILES + src/add.cpp + src/example.cpp +) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) + +pybind11_add_module(example ${SOURCE_FILES} ${HEADER_FILES}) diff --git a/pyvcell-fvsolver/include/add.h b/pyvcell-fvsolver/include/add.h new file mode 100644 index 00000000..2057d227 --- /dev/null +++ b/pyvcell-fvsolver/include/add.h @@ -0,0 +1,10 @@ +// +// Created by Jim Schaff on 5/27/24. +// + +#ifndef ADD_H +#define ADD_H + +int add(int i, int j); + +#endif //ADD_H diff --git a/pyvcell-fvsolver/src/add.cpp b/pyvcell-fvsolver/src/add.cpp new file mode 100644 index 00000000..d70770b1 --- /dev/null +++ b/pyvcell-fvsolver/src/add.cpp @@ -0,0 +1,6 @@ +#include "add.h" + +int add(int i, int j) { + return i + j; +} + diff --git a/pyvcell-fvsolver/src/example.cpp b/pyvcell-fvsolver/src/example.cpp new file mode 100644 index 00000000..fe053be6 --- /dev/null +++ b/pyvcell-fvsolver/src/example.cpp @@ -0,0 +1,10 @@ +#include <../../extern/pybind11/include/pybind11/pybind11.h> +#include "add.h" + +namespace py = pybind11; + +PYBIND11_MODULE(example, m) { + m.doc() = "pybind11 example plugin"; // optional module docstring + + m.def("add", &add, "A function that adds two numbers", py::arg("i"), py::arg("j")); +} From 0dbfb49aada921dcd2c1a1f92d69be7d3a210288 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sat, 1 Jun 2024 21:12:53 -0400 Subject: [PATCH 04/29] const char* and nullptr for C++ FV solver --- VCell/include/VCELL/FVSolver.h | 4 ++-- VCell/src/FVSolver.cpp | 2 +- VCellMessaging/src/SimulationMessaging.cpp | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/VCell/include/VCELL/FVSolver.h b/VCell/include/VCELL/FVSolver.h index e517e363..18f4a301 100644 --- a/VCell/include/VCELL/FVSolver.h +++ b/VCell/include/VCELL/FVSolver.h @@ -22,7 +22,7 @@ class Membrane; class FVSolver { public: - FVSolver(istream& fvinput, int taskID=-1, char* outdir=0, bool bSimZip=true); + FVSolver(istream& fvinput, int taskID=-1, const char* outdir=0, bool bSimZip=true); virtual ~FVSolver(); void createSimTool(istream& ifsInput, int taskID); @@ -64,7 +64,7 @@ class FVSolver { void loadSerialScanParameters(istream& ifsInput, int numSerialScanParameters); void loadSerialScanParameterValues(istream& ifsInput, int numSerialScanParamValues); - char* outputPath; + const char* outputPath; SimTool* simTool; SimulationExpression *simulation; VCellModel *model; diff --git a/VCell/src/FVSolver.cpp b/VCell/src/FVSolver.cpp index cc6e19c6..0a5da490 100644 --- a/VCell/src/FVSolver.cpp +++ b/VCell/src/FVSolver.cpp @@ -1562,7 +1562,7 @@ void FVSolver::loadSmoldyn(istream& ifsInput) { } } -FVSolver::FVSolver(istream& fvinput, int taskID, char* outdir, bool bSimZip) { +FVSolver::FVSolver(istream& fvinput, int taskID, const char* outdir, bool bSimZip) { simTool = 0; simulation = 0; model = 0; diff --git a/VCellMessaging/src/SimulationMessaging.cpp b/VCellMessaging/src/SimulationMessaging.cpp index 4747cb85..247cf3c9 100644 --- a/VCellMessaging/src/SimulationMessaging.cpp +++ b/VCellMessaging/src/SimulationMessaging.cpp @@ -41,7 +41,7 @@ static const double WORKEREVENT_MESSAGE_MIN_TIME_SECONDS = 15.0; #endif -SimulationMessaging *SimulationMessaging::m_inst = NULL; +SimulationMessaging *SimulationMessaging::m_inst = nullptr; SimulationMessaging::SimulationMessaging(){ this->bStopRequested = false; @@ -142,7 +142,7 @@ SimulationMessaging* SimulationMessaging::getInstVar() { SimulationMessaging* SimulationMessaging::create() { - if (m_inst == 0){ + if (m_inst == nullptr){ m_inst = new SimulationMessaging(); } return(m_inst); @@ -333,7 +333,7 @@ void SimulationMessaging::sendStatus() { } void SimulationMessaging::setWorkerEvent(WorkerEvent* arg_workerEvent) { - if (m_inst == 0) { + if (m_inst == nullptr) { throw "SimulationMessaging is not initialized"; } if (workerEventOutputMode == WORKEREVENT_OUTPUT_MODE_STDOUT) { @@ -449,7 +449,7 @@ bool SimulationMessaging::lockWorkerEvent(bool bTry) return true; #else // UNIX if (bTry) { - return (pthread_mutex_trylock(&mutex_workerEvent) == 0); + return (pthread_mutex_trylock(&mutex_workerEvent) == nullptr); } if (pthread_mutex_lock(&mutex_workerEvent) != 0) { return false; From 66f5bd67d46a87d0d830fe4fa7e6e8f91daddf23 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sat, 1 Jun 2024 21:14:48 -0400 Subject: [PATCH 05/29] create pyvcell_fvsolver Python module using pybind11 and vcell library --- CMakeLists.txt | 67 ++++++--------- pyvcell-fvsolver/CMakeLists.txt | 14 +-- pyvcell-fvsolver/include/SolverMain.h | 13 +++ pyvcell-fvsolver/include/add.h | 10 --- pyvcell-fvsolver/src/SolverMain.cpp | 100 ++++++++++++++++++++++ pyvcell-fvsolver/src/add.cpp | 6 -- pyvcell-fvsolver/src/example.cpp | 10 --- pyvcell-fvsolver/src/pyvcell_fvsolver.cpp | 13 +++ 8 files changed, 163 insertions(+), 70 deletions(-) create mode 100644 pyvcell-fvsolver/include/SolverMain.h delete mode 100644 pyvcell-fvsolver/include/add.h create mode 100644 pyvcell-fvsolver/src/SolverMain.cpp delete mode 100644 pyvcell-fvsolver/src/add.cpp delete mode 100644 pyvcell-fvsolver/src/example.cpp create mode 100644 pyvcell-fvsolver/src/pyvcell_fvsolver.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index fbd8f630..fd9670c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,8 @@ endif() cmake_minimum_required(VERSION 3.13...3.27) project(fvsolver) -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) enable_language(CXX) enable_language(C) enable_language(Fortran) @@ -95,6 +96,8 @@ include (FindZLIB) option(OPTION_TARGET_MESSAGING "Messaging (requires libcurl)" off) option(OPTION_TARGET_DOCS "Generate Doxygen documentation" on) option(OPTION_TARGET_FV_SOLVER on) +option(OPTION_TARGET_MESSAGING "Messaging (requires libcurl)" off) + if (${OPTION_TARGET_DOCS}) # if (DOXYGEN_FOUND AND ${CMAKE_VERSION} GREATER_EQUAL 3.9) @@ -213,47 +216,33 @@ endif() add_subdirectory(VCellMessaging) - if (${OPTION_TARGET_FV_SOLVER}) - add_subdirectory(VCellZipUtils) - add_subdirectory(libzip-1.2.0) - endif() - - if (${OPTION_TARGET_FV_SOLVER}) - message(STATUS "adding ExpressionParser") - add_subdirectory(ExpressionParser) - endif() + add_subdirectory(VCellZipUtils) - if (${OPTION_TARGET_FV_SOLVER} - ) - message(STATUS "adding sundials") - add_subdirectory(sundials) - endif () - - if (${OPTION_TARGET_FV_SOLVER}) - if (NOT APPLE) - add_subdirectory(blas) - endif() + add_subdirectory(libzip-1.2.0) + + add_subdirectory(ExpressionParser) + + add_subdirectory(sundials) + + if (NOT APPLE) + add_subdirectory(blas) endif() - if (OPTION_TARGET_FV_SOLVER) - option(OPTION_VCELL "Compile Smoldyn for VCell" ON) - option(OPTION_NSV "Compile Smoldyn with NextSubvolume functionality" OFF) - option(OPTION_USE_OPENGL "Build with OpenGL support" OFF) - option(OPTION_USE_ZLIB "Build with Zlib support" ON) - option(OPTION_USE_LIBTIFF "Build with LibTiff support" OFF) - option(OPTION_USE_ICONV "Build with Libiconv support" OFF) - SET(HAVE_ZLIB TRUE) - set(OPTION_TARGET_LIBSMOLDYN ON) - set(OPTION_VCELL ON) - add_subdirectory(bridgeVCellSmoldyn) - add_subdirectory(smoldyn-2.38) - endif () - - if (${OPTION_TARGET_FV_SOLVER}) - add_subdirectory(VCell) - add_subdirectory(PCGPack) - add_subdirectory(qhull) - endif () + option(OPTION_VCELL "Compile Smoldyn for VCell" ON) + option(OPTION_NSV "Compile Smoldyn with NextSubvolume functionality" OFF) + option(OPTION_USE_OPENGL "Build with OpenGL support" OFF) + option(OPTION_USE_ZLIB "Build with Zlib support" ON) + option(OPTION_USE_LIBTIFF "Build with LibTiff support" OFF) + option(OPTION_USE_ICONV "Build with Libiconv support" OFF) + SET(HAVE_ZLIB TRUE) + set(OPTION_TARGET_LIBSMOLDYN ON) + set(OPTION_VCELL ON) + add_subdirectory(bridgeVCellSmoldyn) + add_subdirectory(smoldyn-2.38) + + add_subdirectory(VCell) + add_subdirectory(PCGPack) + add_subdirectory(qhull) add_subdirectory(extern/pybind11) add_subdirectory(pyvcell-fvsolver) diff --git a/pyvcell-fvsolver/CMakeLists.txt b/pyvcell-fvsolver/CMakeLists.txt index 1bc03c0a..b610f649 100644 --- a/pyvcell-fvsolver/CMakeLists.txt +++ b/pyvcell-fvsolver/CMakeLists.txt @@ -1,14 +1,18 @@ -project(example) +project(pyvcell_fvsolver) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) set(HEADER_FILES - include/add.h + include/SolverMain.h ) set(SOURCE_FILES - src/add.cpp - src/example.cpp + src/pyvcell_fvsolver.cpp + src/SolverMain.cpp ) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) -pybind11_add_module(example ${SOURCE_FILES} ${HEADER_FILES}) +pybind11_add_module(pyvcell_fvsolver ${SOURCE_FILES} ${HEADER_FILES}) + +target_link_libraries(pyvcell_fvsolver PRIVATE vcell) diff --git a/pyvcell-fvsolver/include/SolverMain.h b/pyvcell-fvsolver/include/SolverMain.h new file mode 100644 index 00000000..5b69637f --- /dev/null +++ b/pyvcell-fvsolver/include/SolverMain.h @@ -0,0 +1,13 @@ +// +// Created by Jim Schaff on 6/1/24. +// + +#ifndef SOLVERMAIN_H +#define SOLVERMAIN_H + +#include + +std::string version(); +int solve(const std::string& inputFilename, const std::string& outputDir); + +#endif //SOLVERMAIN_H diff --git a/pyvcell-fvsolver/include/add.h b/pyvcell-fvsolver/include/add.h deleted file mode 100644 index 2057d227..00000000 --- a/pyvcell-fvsolver/include/add.h +++ /dev/null @@ -1,10 +0,0 @@ -// -// Created by Jim Schaff on 5/27/24. -// - -#ifndef ADD_H -#define ADD_H - -int add(int i, int j); - -#endif //ADD_H diff --git a/pyvcell-fvsolver/src/SolverMain.cpp b/pyvcell-fvsolver/src/SolverMain.cpp new file mode 100644 index 00000000..5e5b1527 --- /dev/null +++ b/pyvcell-fvsolver/src/SolverMain.cpp @@ -0,0 +1,100 @@ +// +// Created by Jim Schaff on 6/1/24. +// +#include "SolverMain.h" + +#include +#include +#include +#include +using namespace std; + +#undef USE_MESSAGING + +#include +#include +#include +#include +#include +#include +#include + + + +void vcellExit(int returnCode, string& errorMsg) { + if (SimulationMessaging::getInstVar() == 0) { + if (returnCode != 0) { + cerr << errorMsg << endl; + } + } else if (!SimulationMessaging::getInstVar()->isStopRequested()) { + if (returnCode != 0) { + SimulationMessaging::getInstVar()->setWorkerEvent(new WorkerEvent(JOB_FAILURE, errorMsg.c_str())); + } + } +} + +std::string version() +{ + return "Finite Volume version " + std::string(g_GIT_DESCRIBE) + " with smoldyn version " + std::string(VERSION); +} + +int solve(const std::string& inputFilename, const std::string& outputDir) { + // Check if output directory exists, if not create it + std::filesystem::path dirPath(outputDir); + if (!std::filesystem::exists(dirPath)) { + std::filesystem::create_directories(dirPath); + } + + // Open the input file + std::ifstream inputFile(inputFilename); + if (!inputFile.is_open()) { + throw std::runtime_error("Could not open input file: " + inputFilename); + } + + vcellhybrid::setHybrid(); //get smoldyn library in correct state + int returnCode = 0; + string errorMsg = "Exception : "; + + bool bSimZip = true; + int taskID = 0; + + SimulationMessaging::create(); + + FVSolver* fvSolver = nullptr; + + try { + fvSolver = new FVSolver(inputFile, taskID, outputDir.c_str(), bSimZip); + + inputFile.close(); + + if(fvSolver->getNumVariables() == 0){ + //sims with no reactions and no diffusing species cause exit logic to 'wait' forever + //never sending a job failed or job finished message and never cleaning up threads + throw invalid_argument("FiniteVolume error: Must have at least 1 variable or reaction to solve"); + } + fvSolver->solve(); + + } catch (const char *exStr){ + errorMsg += exStr; + returnCode = 1; + } catch (string& exStr){ + errorMsg += exStr; + returnCode = 1; + } catch (VCell::Exception& ex){ + errorMsg += ex.getMessage(); + returnCode = 1; + } catch (std::exception & e) { + errorMsg += e.what(); + returnCode = 1; + } catch (...){ + errorMsg += "unknown error"; + returnCode = 1; + } + + if (inputFile.is_open()) { + inputFile.close(); + } + vcellExit(returnCode, errorMsg); + delete fvSolver; + return returnCode; +} diff --git a/pyvcell-fvsolver/src/add.cpp b/pyvcell-fvsolver/src/add.cpp deleted file mode 100644 index d70770b1..00000000 --- a/pyvcell-fvsolver/src/add.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "add.h" - -int add(int i, int j) { - return i + j; -} - diff --git a/pyvcell-fvsolver/src/example.cpp b/pyvcell-fvsolver/src/example.cpp deleted file mode 100644 index fe053be6..00000000 --- a/pyvcell-fvsolver/src/example.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include <../../extern/pybind11/include/pybind11/pybind11.h> -#include "add.h" - -namespace py = pybind11; - -PYBIND11_MODULE(example, m) { - m.doc() = "pybind11 example plugin"; // optional module docstring - - m.def("add", &add, "A function that adds two numbers", py::arg("i"), py::arg("j")); -} diff --git a/pyvcell-fvsolver/src/pyvcell_fvsolver.cpp b/pyvcell-fvsolver/src/pyvcell_fvsolver.cpp new file mode 100644 index 00000000..8cd13223 --- /dev/null +++ b/pyvcell-fvsolver/src/pyvcell_fvsolver.cpp @@ -0,0 +1,13 @@ +#include <../../extern/pybind11/include/pybind11/pybind11.h> + +#include "SolverMain.h" + +namespace py = pybind11; + +PYBIND11_MODULE(pyvcell_fvsolver, m) { + m.doc() = "VCell FiniteVolume plugin"; // optional module docstring + + m.def("version", &version, "A function that returns the version of the FiniteVolume solver"); + + m.def("solve", &solve, "A function that invokes the FiniteVolume solver", py::arg("inputFilename"), py::arg("outputDir")); +} From ce3ed83a086e4f3ae67e96a7499448c6295eb5d8 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sun, 2 Jun 2024 09:27:04 -0400 Subject: [PATCH 06/29] static libzip build, FiniteVolume_x64 and Python don't need libzip.dylib --- libzip-1.2.0/CMakeLists.txt | 8 +++----- libzip-1.2.0/lib/CMakeLists.txt | 31 +++++------------------------ libzip-1.2.0/regress/CMakeLists.txt | 6 +++--- libzip-1.2.0/src/CMakeLists.txt | 5 +++-- 4 files changed, 14 insertions(+), 36 deletions(-) diff --git a/libzip-1.2.0/CMakeLists.txt b/libzip-1.2.0/CMakeLists.txt index a80d3837..4bb40500 100644 --- a/libzip-1.2.0/CMakeLists.txt +++ b/libzip-1.2.0/CMakeLists.txt @@ -106,12 +106,10 @@ ADD_DEFINITIONS("-DHAVE_CONFIG_H") # Targets ADD_SUBDIRECTORY(lib) -target_include_directories(zip PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) -#target_include_directories(zipstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) -#ADD_SUBDIRECTORY(man) + +target_include_directories(zipstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) + ADD_SUBDIRECTORY(src) -#ADD_SUBDIRECTORY(regress) -#ADD_SUBDIRECTORY(examples) # TODO: pkgconfig file diff --git a/libzip-1.2.0/lib/CMakeLists.txt b/libzip-1.2.0/lib/CMakeLists.txt index cb8d5f43..38870d1a 100644 --- a/libzip-1.2.0/lib/CMakeLists.txt +++ b/libzip-1.2.0/lib/CMakeLists.txt @@ -178,40 +178,19 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/gladman-fcrypt ${CMAKE_CURRENT_BINARY_DIR}/..) -# TODO: distribute instead? -#ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zip_err_str.c -# COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/make_zip_err_str.sh -# ${CMAKE_CURRENT_SOURCE_DIR}/zip.h -# ${CMAKE_CURRENT_BINARY_DIR}/zip_err_str.c -# DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/zip.h -# ${CMAKE_CURRENT_SOURCE_DIR}/make_zip_err_str.sh -#) CHECK_FUNCTION_EXISTS(mkstemp HAVE_MKSTEMP) IF(NOT HAVE_MKSTEMP) SET(LIBZIP_EXTRA_FILES mkstemp.c) ENDIF(NOT HAVE_MKSTEMP) -ADD_LIBRARY(zip SHARED ${LIBZIP_SOURCES} ${LIBZIP_EXTRA_FILES} ${LIBZIP_OPSYS_FILES}) -SET_TARGET_PROPERTIES(zip PROPERTIES VERSION 3.0 SOVERSION 3 ) -TARGET_LINK_LIBRARIES(zip ${ZLIB_LIBRARY}) -target_include_directories(zip PUBLIC +ADD_LIBRARY(zipstatic STATIC ${LIBZIP_SOURCES} ${LIBZIP_EXTRA_FILES} ${LIBZIP_OPSYS_FILES}) +SET_TARGET_PROPERTIES(zipstatic PROPERTIES VERSION 3.0 SOVERSION 3 ) +TARGET_LINK_LIBRARIES(zipstatic ${ZLIB_LIBRARY}) +target_include_directories(zipstatic PUBLIC $ $ # ) -INSTALL(TARGETS zip +INSTALL(TARGETS zipstatic RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) -#CREATE_LIBTOOL_FILE(zip lib) - -#ADD_LIBRARY(zipstatic STATIC ${LIBZIP_SOURCES} ${LIBZIP_EXTRA_FILES} ${LIBZIP_OPSYS_FILES}) -#SET_TARGET_PROPERTIES(zipstatic PROPERTIES VERSION 3.0 SOVERSION 3 ) -#TARGET_LINK_LIBRARIES(zipstatic ${ZLIB_LIBRARY}) -#target_include_directories(zipstatic PUBLIC -# $ -# $ # -#) -#INSTALL(TARGETS zipstatic -# RUNTIME DESTINATION bin -# ARCHIVE DESTINATION lib -# LIBRARY DESTINATION lib) diff --git a/libzip-1.2.0/regress/CMakeLists.txt b/libzip-1.2.0/regress/CMakeLists.txt index 0a36cfd0..61dc7333 100644 --- a/libzip-1.2.0/regress/CMakeLists.txt +++ b/libzip-1.2.0/regress/CMakeLists.txt @@ -131,18 +131,18 @@ SET(EXTRA_TESTS SET(ENV{srcdir} ${CMAKE_CURRENT_SOURCE_DIR}) FOREACH(PROGRAM ${STANDALONE_TEST_PROGRAMS}) ADD_EXECUTABLE(${PROGRAM} ${PROGRAM}.c) - TARGET_LINK_LIBRARIES(${PROGRAM} zip) + TARGET_LINK_LIBRARIES(${PROGRAM} zipstatic) ADD_TEST(${PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/runtest ${CMAKE_CURRENT_SOURCE_DIR}/${PROGRAM}) ENDFOREACH(PROGRAM ${STANDALONE_TEST_PROGRAMS}) FOREACH(PROGRAM ${HELPER_TEST_PROGRAMS}) ADD_EXECUTABLE(${PROGRAM} ${PROGRAM}.c) - TARGET_LINK_LIBRARIES(${PROGRAM} zip) + TARGET_LINK_LIBRARIES(${PROGRAM} zipstatic) ENDFOREACH(PROGRAM ${HELPER_TEST_PROGRAMS}) FOREACH(PROGRAM ${GETOPT_USERS}) ADD_EXECUTABLE(${PROGRAM} ${PROGRAM}.c ${SRC_EXTRA_FILES}) - TARGET_LINK_LIBRARIES(${PROGRAM} zip) + TARGET_LINK_LIBRARIES(${PROGRAM} zipstatic) ENDFOREACH(PROGRAM ${GETOPT_USERS}) ADD_TEST(fread ${CMAKE_CURRENT_SOURCE_DIR}/runtest ${CMAKE_CURRENT_SOURCE_DIR}/fread) diff --git a/libzip-1.2.0/src/CMakeLists.txt b/libzip-1.2.0/src/CMakeLists.txt index 2b7c6dce..36e67c92 100644 --- a/libzip-1.2.0/src/CMakeLists.txt +++ b/libzip-1.2.0/src/CMakeLists.txt @@ -17,8 +17,9 @@ ENDIF(NOT HAVE_GETOPT) #INSTALL(TARGETS zipmerge RUNTIME DESTINATION bin) add_library(ziptool_lib STATIC ziptool_lib.c ${SRC_EXTRA_FILES} source_hole.c) -#target_link_libraries(ziptool_lib zipstatic) -target_link_libraries(ziptool_lib zip) + +target_link_libraries(ziptool_lib zipstatic) + target_include_directories(ziptool_lib PUBLIC $ $ # From 5d191f623064ccf8fd2cca66bc50df633a77c6f6 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sun, 2 Jun 2024 10:38:32 -0400 Subject: [PATCH 07/29] separate scikit-build-core build using 'pip install ./pyvcell_fvsolver' --- CMakeLists.txt | 24 +- LICENSE | 21 ++ noxfile.py | 41 +++ pyvcell-fvsolver/CMakeLists.txt | 169 ++++++++++- pyvcell-fvsolver/README.md | 1 + .../modules/GetGitRevisionDescription.cmake | 284 ++++++++++++++++++ .../GetGitRevisionDescription.cmake.in | 45 +++ pyvcell-fvsolver/pyproject.toml | 87 ++++++ .../{include => src}/SolverMain.h | 0 pyvcell-fvsolver/src/main.cpp | 42 +++ pyvcell-fvsolver/src/pyvcell_fvsolver.cpp | 13 - .../src/pyvcell_fvsolver/__init__.py | 5 + pyvcell-fvsolver/test/test.py | 15 + .../SimID_11538992_0_.functions | 0 .../SimID_11538992_0_.fvinput | 0 .../{FiniteVolume => }/SimID_11538992_0_.vcg | 0 .../SimID_11538992_0__0.simtask.xml | 0 17 files changed, 708 insertions(+), 39 deletions(-) create mode 100644 LICENSE create mode 100644 noxfile.py create mode 100644 pyvcell-fvsolver/README.md create mode 100644 pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake create mode 100644 pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake.in create mode 100644 pyvcell-fvsolver/pyproject.toml rename pyvcell-fvsolver/{include => src}/SolverMain.h (100%) create mode 100644 pyvcell-fvsolver/src/main.cpp delete mode 100644 pyvcell-fvsolver/src/pyvcell_fvsolver.cpp create mode 100644 pyvcell-fvsolver/src/pyvcell_fvsolver/__init__.py create mode 100644 pyvcell-fvsolver/test/test.py rename testFiles/input/{FiniteVolume => }/SimID_11538992_0_.functions (100%) rename testFiles/input/{FiniteVolume => }/SimID_11538992_0_.fvinput (100%) rename testFiles/input/{FiniteVolume => }/SimID_11538992_0_.vcg (100%) rename testFiles/input/{FiniteVolume => }/SimID_11538992_0__0.simtask.xml (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd9670c4..a82f75c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,7 +44,7 @@ elseif (LINUX) endif() endif() -cmake_minimum_required(VERSION 3.13...3.27) +cmake_minimum_required(VERSION 3.17...3.27) project(fvsolver) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -202,17 +202,14 @@ endif() # ####################################### -if (${OPTION_TARGET_FV_SOLVER}) - - set(HDF5_USE_STATIC_LIBRARIES ON) - if(WINDOWS OR WIN32 OR WIN64) - set(HDF5_USE_STATIC_LIBRARIES OFF) - endif () - #CMakeList.txt that comes with hdf5 switches library name if compiled with debug - find_package(HDF5 COMPONENTS HL CXX C) - set(HDF_VERSION ${HDF5_VERSION}) - ###### ${HDF5_HL_LIBRARIES} ${HDF5_CXX_LIBRARIES} -endif() + set(HDF5_USE_STATIC_LIBRARIES ON) + if(WINDOWS OR WIN32 OR WIN64) + set(HDF5_USE_STATIC_LIBRARIES OFF) + endif () + #CMakeList.txt that comes with hdf5 switches library name if compiled with debug + find_package(HDF5 COMPONENTS HL CXX C) + set(HDF_VERSION ${HDF5_VERSION}) + ###### ${HDF5_HL_LIBRARIES} ${HDF5_CXX_LIBRARIES} add_subdirectory(VCellMessaging) @@ -244,9 +241,6 @@ endif() add_subdirectory(PCGPack) add_subdirectory(qhull) - add_subdirectory(extern/pybind11) - add_subdirectory(pyvcell-fvsolver) - include(FetchContent) FetchContent_Declare( googletest diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..ab867c11 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 1999-2024 University of Connecticut Health Center + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/noxfile.py b/noxfile.py new file mode 100644 index 00000000..23f05269 --- /dev/null +++ b/noxfile.py @@ -0,0 +1,41 @@ +from __future__ import annotations + +import sys + +import nox + +nox.options.sessions = ["lint", "tests"] + + +@nox.session +def lint(session: nox.Session) -> None: + """ + Run the linter. + """ + session.install("pre-commit") + session.run("pre-commit", "run", "--all-files", *session.posargs) + + +@nox.session +def tests(session: nox.Session) -> None: + """ + Run the unit and regular tests. + """ + session.install(".[test]") + session.run("pytest", *session.posargs) + + +@nox.session(venv_backend="none") +def dev(session: nox.Session) -> None: + """ + Prepare a .venv folder. + """ + + session.run(sys.executable, "-m", "venv", ".venv") + session.run( + ".venv/bin/pip", + "install", + "-e.", + "-Ccmake.define.CMAKE_EXPORT_COMPILE_COMMANDS=1", + "-Cbuild-dir=build", + ) diff --git a/pyvcell-fvsolver/CMakeLists.txt b/pyvcell-fvsolver/CMakeLists.txt index b610f649..095dfd4a 100644 --- a/pyvcell-fvsolver/CMakeLists.txt +++ b/pyvcell-fvsolver/CMakeLists.txt @@ -1,18 +1,165 @@ -project(pyvcell_fvsolver) +cmake_minimum_required(VERSION 3.29) + +project( + ${SKBUILD_PROJECT_NAME} + VERSION ${SKBUILD_PROJECT_VERSION} + LANGUAGES CXX C Fortran) + set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(HEADER_FILES - include/SolverMain.h -) +if(POLICY CMP0057) + cmake_policy(SET CMP0057 NEW) +endif() + +############################################# +# +# Build 64bit binaries on Mac and target Macos 10.7 or later +# +############################################## +if (APPLE) + execute_process(COMMAND uname -m OUTPUT_VARIABLE PROCESSOR_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE) + message("Processor Architecture: ${PROCESSOR_ARCHITECTURE}") + if (PROCESSOR_ARCHITECTURE STREQUAL "arm64") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__arm64__") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__arm64__") + set(CMAKE_OSX_ARCHITECTURES "arm64") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__x86_64__") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__x86_64__") + set(CMAKE_OSX_ARCHITECTURES "x86_64") + endif() + # set(CMAKE_Fortran_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=10.7" CACHE PATH "") + # set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE PATH "") + ############################################# + # + # Choose 32bit or 64bit target arch on Linux + # + ############################################## +elseif (LINUX) + option(LINUX_32bit_BINARIES "Build 32bit Linux BINARIES" OFF) + option(LINUX_64bit_BINARIES "Build 64bit Linux BINARIES" ON) + + if (LINUX_32bit_BINARIES AND LINUX_64bit_BINARIES) + message(FATAL_ERROR "It is required to select either 32bit or 64bit Linux Binaries, not both") + endif() + + if (LINUX_32bit_BINARIES) + set (ARCH_64bit FALSE) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") + set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -m32") + endif() + + if (LINUX_64bit_BINARIES) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64") + set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -m64") + endif() +endif() + +if(POLICY CMP0057) + cmake_policy(SET CMP0057 NEW) +endif() + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") + +include(GetGitRevisionDescription) +git_describe(GIT_DESCRIBE ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR) + +include (FindZLIB) + +option(OPTION_TARGET_MESSAGING "Messaging (requires libcurl)" off) +option(OPTION_TARGET_DOCS "Generate Doxygen documentation" off) +option(OPTION_TARGET_FV_SOLVER on) +option(OPTION_TARGET_MESSAGING "Messaging (requires libcurl)" off) + + +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE STRING "Choose minimum deploy target for Macos machines") +endif() + +set(LINUX FALSE) +if (${CMAKE_SYSTEM_NAME} MATCHES Linux) + set(LINUX TRUE) +endif() + +set(WINDOWS FALSE) +if (${CMAKE_SYSTEM_NAME} MATCHES Windows) + set(WINDOWS TRUE) + set(WIN32 TRUE) + set(MINGW TRUE) +endif() + +set (ARCH_64bit FALSE) +if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set (ARCH_64bit TRUE) +endif() + +if (NOT APPLE AND NOT LINUX AND NOT MINGW) + message(FATAL_ERROR "Unsupported Operating System or C/C++ Compiler.") +endif() + +add_definitions(-DFORTRAN_UNDERSCORE) + +set(OPTION_EXE_DIRECTORY "bin" CACHE PATH "installation directory") +set(OPTION_LIB_DIRECTORY "lib" CACHE PATH "library directory") +set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}") +add_definitions(-DUNIX) + +set(HDF5_USE_STATIC_LIBRARIES ON) +if(WINDOWS OR WIN32 OR WIN64) + set(HDF5_USE_STATIC_LIBRARIES OFF) +endif () +#CMakeList.txt that comes with hdf5 switches library name if compiled with debug +find_package(HDF5 COMPONENTS HL CXX C) +set(HDF_VERSION ${HDF5_VERSION}) +###### ${HDF5_HL_LIBRARIES} ${HDF5_CXX_LIBRARIES} + +add_subdirectory(../VCellMessaging bin/VCellMessaging) + +add_subdirectory(../VCellZipUtils bin/VCellZipUtils) + +add_subdirectory(../libzip-1.2.0 bin/libzip-1.2.0) + +add_subdirectory(../ExpressionParser bin/ExpressionParser) + +add_subdirectory(../sundials bin/sundials) + +if (NOT APPLE) + add_subdirectory(../blas bin/blas) +endif() + +option(OPTION_VCELL "Compile Smoldyn for VCell" ON) +option(OPTION_NSV "Compile Smoldyn with NextSubvolume functionality" OFF) +option(OPTION_USE_OPENGL "Build with OpenGL support" OFF) +option(OPTION_USE_ZLIB "Build with Zlib support" ON) +option(OPTION_USE_LIBTIFF "Build with LibTiff support" OFF) +option(OPTION_USE_ICONV "Build with Libiconv support" OFF) +SET(HAVE_ZLIB TRUE) +set(OPTION_TARGET_LIBSMOLDYN ON) +set(OPTION_VCELL ON) +add_subdirectory(../bridgeVCellSmoldyn bin/bridgeVCellSmoldyn) +add_subdirectory(../smoldyn-2.38 bin/smoldyn-2.38) + +add_subdirectory(../VCell bin/VCell) +add_subdirectory(../PCGPack bin/PCGPack) +add_subdirectory(../qhull bin/qhull) + + -set(SOURCE_FILES - src/pyvcell_fvsolver.cpp - src/SolverMain.cpp -) +# Find the module development requirements (requires FindPython from 3.17 or +# scikit-build-core's built-in backport) +find_package(Python REQUIRED COMPONENTS Interpreter Development.Module) +find_package(pybind11 CONFIG REQUIRED) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) +# Add a library using FindPython's tooling (pybind11 also provides a helper like this) +python_add_library(_core MODULE src/main.cpp src/SolverMain.cpp src/SolverMain.h WITH_SOABI) +target_link_libraries(_core PRIVATE vcell pybind11::headers) -pybind11_add_module(pyvcell_fvsolver ${SOURCE_FILES} ${HEADER_FILES}) +# This is passing in the version as a define just as an example +target_compile_definitions(_core PRIVATE VERSION_INFO=${PROJECT_VERSION}) -target_link_libraries(pyvcell_fvsolver PRIVATE vcell) +# The install directory is the output (wheel) directory +install(TARGETS _core DESTINATION pyvcell_fvsolver) \ No newline at end of file diff --git a/pyvcell-fvsolver/README.md b/pyvcell-fvsolver/README.md new file mode 100644 index 00000000..b17fbaa4 --- /dev/null +++ b/pyvcell-fvsolver/README.md @@ -0,0 +1 @@ +## pyvcell_fvsolver diff --git a/pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake b/pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake new file mode 100644 index 00000000..e48b2067 --- /dev/null +++ b/pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake @@ -0,0 +1,284 @@ +# - Returns a version string from Git +# +# These functions force a re-configure on each git commit so that you can +# trust the values of the variables in your build system. +# +# get_git_head_revision( [ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR]) +# +# Returns the refspec and sha hash of the current head revision +# +# git_describe( [ ...]) +# +# Returns the results of git describe on the source tree, and adjusting +# the output so that it tests false if an error occurs. +# +# git_describe_working_tree( [ ...]) +# +# Returns the results of git describe on the working tree (--dirty option), +# and adjusting the output so that it tests false if an error occurs. +# +# git_get_exact_tag( [ ...]) +# +# Returns the results of git describe --exact-match on the source tree, +# and adjusting the output so that it tests false if there was no exact +# matching tag. +# +# git_local_changes() +# +# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes. +# Uses the return code of "git diff-index --quiet HEAD --". +# Does not regard untracked files. +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2020 Ryan Pavlik +# http://academic.cleardefinition.com +# +# Copyright 2009-2013, Iowa State University. +# Copyright 2013-2020, Ryan Pavlik +# Copyright 2013-2020, Contributors +# SPDX-License-Identifier: BSL-1.0 +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +if(__get_git_revision_description) + return() +endif() +set(__get_git_revision_description YES) + +# We must run the following at "include" time, not at function call time, +# to find the path to this module rather than the path to a calling list file +get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) + +# Function _git_find_closest_git_dir finds the next closest .git directory +# that is part of any directory in the path defined by _start_dir. +# The result is returned in the parent scope variable whose name is passed +# as variable _git_dir_var. If no .git directory can be found, the +# function returns an empty string via _git_dir_var. +# +# Example: Given a path C:/bla/foo/bar and assuming C:/bla/.git exists and +# neither foo nor bar contain a file/directory .git. This wil return +# C:/bla/.git +# +function(_git_find_closest_git_dir _start_dir _git_dir_var) + set(cur_dir "${_start_dir}") + set(git_dir "${_start_dir}/.git") + while(NOT EXISTS "${git_dir}") + # .git dir not found, search parent directories + set(git_previous_parent "${cur_dir}") + get_filename_component(cur_dir "${cur_dir}" DIRECTORY) + if(cur_dir STREQUAL git_previous_parent) + # We have reached the root directory, we are not in git + set(${_git_dir_var} + "" + PARENT_SCOPE) + return() + endif() + set(git_dir "${cur_dir}/.git") + endwhile() + set(${_git_dir_var} + "${git_dir}" + PARENT_SCOPE) +endfunction() + +function(get_git_head_revision _refspecvar _hashvar) + _git_find_closest_git_dir("${CMAKE_CURRENT_SOURCE_DIR}" GIT_DIR) + + if("${ARGN}" STREQUAL "ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR") + set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR TRUE) + else() + set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR FALSE) + endif() + if(NOT "${GIT_DIR}" STREQUAL "") + file(RELATIVE_PATH _relative_to_source_dir "${CMAKE_SOURCE_DIR}" + "${GIT_DIR}") + if("${_relative_to_source_dir}" MATCHES "[.][.]" AND NOT ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR) + # We've gone above the CMake root dir. + set(GIT_DIR "") + endif() + endif() + if("${GIT_DIR}" STREQUAL "") + set(${_refspecvar} + "GITDIR-NOTFOUND" + PARENT_SCOPE) + set(${_hashvar} + "GITDIR-NOTFOUND" + PARENT_SCOPE) + return() + endif() + + # Check if the current source dir is a git submodule or a worktree. + # In both cases .git is a file instead of a directory. + # + if(NOT IS_DIRECTORY ${GIT_DIR}) + # The following git command will return a non empty string that + # points to the super project working tree if the current + # source dir is inside a git submodule. + # Otherwise the command will return an empty string. + # + execute_process( + COMMAND "${GIT_EXECUTABLE}" rev-parse + --show-superproject-working-tree + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + OUTPUT_VARIABLE out + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT "${out}" STREQUAL "") + # If out is empty, GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a submodule + file(READ ${GIT_DIR} submodule) + string(REGEX REPLACE "gitdir: (.*)$" "\\1" GIT_DIR_RELATIVE + ${submodule}) + string(STRIP ${GIT_DIR_RELATIVE} GIT_DIR_RELATIVE) + get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) + get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} + ABSOLUTE) + set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD") + else() + # GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a worktree + file(READ ${GIT_DIR} worktree_ref) + # The .git directory contains a path to the worktree information directory + # inside the parent git repo of the worktree. + # + string(REGEX REPLACE "gitdir: (.*)$" "\\1" git_worktree_dir + ${worktree_ref}) + string(STRIP ${git_worktree_dir} git_worktree_dir) + _git_find_closest_git_dir("${git_worktree_dir}" GIT_DIR) + set(HEAD_SOURCE_FILE "${git_worktree_dir}/HEAD") + endif() + else() + set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD") + endif() + set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") + if(NOT EXISTS "${GIT_DATA}") + file(MAKE_DIRECTORY "${GIT_DATA}") + endif() + + if(NOT EXISTS "${HEAD_SOURCE_FILE}") + return() + endif() + set(HEAD_FILE "${GIT_DATA}/HEAD") + configure_file("${HEAD_SOURCE_FILE}" "${HEAD_FILE}" COPYONLY) + + configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" + "${GIT_DATA}/grabRef.cmake" @ONLY) + include("${GIT_DATA}/grabRef.cmake") + + set(${_refspecvar} + "${HEAD_REF}" + PARENT_SCOPE) + set(${_hashvar} + "${HEAD_HASH}" + PARENT_SCOPE) +endfunction() + +function(git_describe _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} + "GIT-NOTFOUND" + PARENT_SCOPE) + return() + endif() + if(NOT hash) + set(${_var} + "HEAD-HASH-NOTFOUND" + PARENT_SCOPE) + return() + endif() + + # TODO sanitize + #if((${ARGN}" MATCHES "&&") OR + # (ARGN MATCHES "||") OR + # (ARGN MATCHES "\\;")) + # message("Please report the following error to the project!") + # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") + #endif() + + #message(STATUS "Arguments to execute_process: ${ARGN}") + + execute_process( + COMMAND "${GIT_EXECUTABLE}" describe --tags --always ${hash} ${ARGN} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE res + OUTPUT_VARIABLE out + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(out "${out}-${res}-NOTFOUND") + endif() + + set(${_var} + "${out}" + PARENT_SCOPE) +endfunction() + +function(git_describe_working_tree _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + if(NOT GIT_FOUND) + set(${_var} + "GIT-NOTFOUND" + PARENT_SCOPE) + return() + endif() + + execute_process( + COMMAND "${GIT_EXECUTABLE}" describe --dirty ${ARGN} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE res + OUTPUT_VARIABLE out + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(out "${out}-${res}-NOTFOUND") + endif() + + set(${_var} + "${out}" + PARENT_SCOPE) +endfunction() + +function(git_get_exact_tag _var) + git_describe(out --exact-match ${ARGN}) + set(${_var} + "${out}" + PARENT_SCOPE) +endfunction() + +function(git_local_changes _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} + "GIT-NOTFOUND" + PARENT_SCOPE) + return() + endif() + if(NOT hash) + set(${_var} + "HEAD-HASH-NOTFOUND" + PARENT_SCOPE) + return() + endif() + + execute_process( + COMMAND "${GIT_EXECUTABLE}" diff-index --quiet HEAD -- + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE res + OUTPUT_VARIABLE out + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + if(res EQUAL 0) + set(${_var} + "CLEAN" + PARENT_SCOPE) + else() + set(${_var} + "DIRTY" + PARENT_SCOPE) + endif() +endfunction() diff --git a/pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake.in b/pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake.in new file mode 100644 index 00000000..27982af5 --- /dev/null +++ b/pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake.in @@ -0,0 +1,45 @@ +# +# Internal file for GetGitRevisionDescription.cmake +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright 2009-2012, Iowa State University +# Copyright 2011-2015, Contributors +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +# SPDX-License-Identifier: BSL-1.0 + +set(HEAD_HASH) + +file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) + +string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) +if(HEAD_CONTENTS MATCHES "ref") + # named branch + string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") + if(EXISTS "@GIT_DIR@/${HEAD_REF}") + configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + else() + if(EXISTS "@GIT_DIR@/packed-refs") + configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) + file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) + if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") + set(HEAD_HASH "${CMAKE_MATCH_1}") + endif() + endif() + endif() +else() + # detached HEAD + configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) +endif() + +if(NOT HEAD_HASH) + file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) + string(STRIP "${HEAD_HASH}" HEAD_HASH) +endif() diff --git a/pyvcell-fvsolver/pyproject.toml b/pyvcell-fvsolver/pyproject.toml new file mode 100644 index 00000000..97930b33 --- /dev/null +++ b/pyvcell-fvsolver/pyproject.toml @@ -0,0 +1,87 @@ +[build-system] +requires = ["scikit-build-core>=0.3.3", "pybind11"] +build-backend = "scikit_build_core.build" + + +[project] +name = "pyvcell_fvsolver" +version = "0.0.1" +description="Virtual Cell Finite Volume PDE solver" +readme = "README.md" +authors = [ + { name = "Jim Schaff", email = "schaff@uchc.edu" }, +] +requires-python = ">=3.7" +classifiers = [ + "Development Status :: 4 - Beta", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] + +[project.optional-dependencies] +test = ["pytest"] + + +[tool.scikit-build] +wheel.expand-macos-universal-tags = true + + +[tool.pytest.ini_options] +minversion = "6.0" +addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"] +xfail_strict = true +log_cli_level = "INFO" +filterwarnings = [ + "error", +] +testpaths = ["tests"] + + +[tool.cibuildwheel] +test-command = "pytest {project}/tests" +test-extras = ["test"] +test-skip = ["*universal2:arm64"] +build-verbosity = 1 + + +[tool.ruff] +src = ["src"] + +[tool.ruff.lint] +extend-select = [ + "B", # flake8-bugbear + "I", # isort + "ARG", # flake8-unused-arguments + "C4", # flake8-comprehensions + "EM", # flake8-errmsg + "ICN", # flake8-import-conventions + "G", # flake8-logging-format + "PGH", # pygrep-hooks + "PIE", # flake8-pie + "PL", # pylint + "PT", # flake8-pytest-style + "PTH", # flake8-use-pathlib + "RET", # flake8-return + "RUF", # Ruff-specific + "SIM", # flake8-simplify + "T20", # flake8-print + "UP", # pyupgrade + "YTT", # flake8-2020 + "EXE", # flake8-executable + "NPY", # NumPy specific rules + "PD", # pandas-vet +] +ignore = [ + "PLR09", # Too many X + "PLR2004", # Magic comparison +] +isort.required-imports = ["from __future__ import annotations"] + +[tool.ruff.lint.per-file-ignores] +"tests/**" = ["T20"] diff --git a/pyvcell-fvsolver/include/SolverMain.h b/pyvcell-fvsolver/src/SolverMain.h similarity index 100% rename from pyvcell-fvsolver/include/SolverMain.h rename to pyvcell-fvsolver/src/SolverMain.h diff --git a/pyvcell-fvsolver/src/main.cpp b/pyvcell-fvsolver/src/main.cpp new file mode 100644 index 00000000..9aa735d3 --- /dev/null +++ b/pyvcell-fvsolver/src/main.cpp @@ -0,0 +1,42 @@ +#include <../../extern/pybind11/include/pybind11/pybind11.h> + +#include "SolverMain.h" + +#define STRINGIFY(x) #x +#define MACRO_STRINGIFY(x) STRINGIFY(x) + +namespace py = pybind11; + +PYBIND11_MODULE(_core, m) { + m.doc() = R"pbdoc( + VCell FiniteVolume solver + ------------------------- + + .. currentmodule:: pyvcell_fvsolver + + .. autosummary:: + :toctree: _generate + + version + solve + )pbdoc"; + + m.def("version", &version, R"pbdoc( + version of build + + version string of build using git hash + )pbdoc"); + + m.def("solve", &solve, R"pbdoc( + solve the PDE + + The inputFilename expects a .fvinput file, the outputDir will be created as needed. + )pbdoc", + py::arg("inputFilename"), py::arg("outputDir")); + +#ifdef VERSION_INFO + m.attr("__version__") = MACRO_STRINGIFY(VERSION_INFO); +#else + m.attr("__version__") = "dev"; +#endif +} diff --git a/pyvcell-fvsolver/src/pyvcell_fvsolver.cpp b/pyvcell-fvsolver/src/pyvcell_fvsolver.cpp deleted file mode 100644 index 8cd13223..00000000 --- a/pyvcell-fvsolver/src/pyvcell_fvsolver.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include <../../extern/pybind11/include/pybind11/pybind11.h> - -#include "SolverMain.h" - -namespace py = pybind11; - -PYBIND11_MODULE(pyvcell_fvsolver, m) { - m.doc() = "VCell FiniteVolume plugin"; // optional module docstring - - m.def("version", &version, "A function that returns the version of the FiniteVolume solver"); - - m.def("solve", &solve, "A function that invokes the FiniteVolume solver", py::arg("inputFilename"), py::arg("outputDir")); -} diff --git a/pyvcell-fvsolver/src/pyvcell_fvsolver/__init__.py b/pyvcell-fvsolver/src/pyvcell_fvsolver/__init__.py new file mode 100644 index 00000000..04ae3636 --- /dev/null +++ b/pyvcell-fvsolver/src/pyvcell_fvsolver/__init__.py @@ -0,0 +1,5 @@ +from __future__ import annotations + +from ._core import __doc__, __version__, version, solve + +__all__ = ["__doc__", "__version__", "version", "solve"] diff --git a/pyvcell-fvsolver/test/test.py b/pyvcell-fvsolver/test/test.py new file mode 100644 index 00000000..b5c7c977 --- /dev/null +++ b/pyvcell-fvsolver/test/test.py @@ -0,0 +1,15 @@ +from __future__ import annotations + +import pyvcell_fvsolver as fv + + +def test_version(): + assert fv.__version__ == "0.0.1" + + +def test_add(): + assert fv.add(1, 2) == 3 + + +def test_sub(): + assert fv.subtract(1, 2) == -1 diff --git a/testFiles/input/FiniteVolume/SimID_11538992_0_.functions b/testFiles/input/SimID_11538992_0_.functions similarity index 100% rename from testFiles/input/FiniteVolume/SimID_11538992_0_.functions rename to testFiles/input/SimID_11538992_0_.functions diff --git a/testFiles/input/FiniteVolume/SimID_11538992_0_.fvinput b/testFiles/input/SimID_11538992_0_.fvinput similarity index 100% rename from testFiles/input/FiniteVolume/SimID_11538992_0_.fvinput rename to testFiles/input/SimID_11538992_0_.fvinput diff --git a/testFiles/input/FiniteVolume/SimID_11538992_0_.vcg b/testFiles/input/SimID_11538992_0_.vcg similarity index 100% rename from testFiles/input/FiniteVolume/SimID_11538992_0_.vcg rename to testFiles/input/SimID_11538992_0_.vcg diff --git a/testFiles/input/FiniteVolume/SimID_11538992_0__0.simtask.xml b/testFiles/input/SimID_11538992_0__0.simtask.xml similarity index 100% rename from testFiles/input/FiniteVolume/SimID_11538992_0__0.simtask.xml rename to testFiles/input/SimID_11538992_0__0.simtask.xml From 56d97b52cdb93f0d7a1439229cd338d307691bb7 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sun, 2 Jun 2024 10:49:47 -0400 Subject: [PATCH 08/29] fix prior nullptr upgrade for messaging --- VCellMessaging/src/SimulationMessaging.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VCellMessaging/src/SimulationMessaging.cpp b/VCellMessaging/src/SimulationMessaging.cpp index 247cf3c9..55f24158 100644 --- a/VCellMessaging/src/SimulationMessaging.cpp +++ b/VCellMessaging/src/SimulationMessaging.cpp @@ -449,7 +449,7 @@ bool SimulationMessaging::lockWorkerEvent(bool bTry) return true; #else // UNIX if (bTry) { - return (pthread_mutex_trylock(&mutex_workerEvent) == nullptr); + return (pthread_mutex_trylock(&mutex_workerEvent) == 0); } if (pthread_mutex_lock(&mutex_workerEvent) != 0) { return false; From 41b9feb06be93e348ef7ae61ac9dc71ff4081992 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sun, 2 Jun 2024 11:10:47 -0400 Subject: [PATCH 09/29] update Dockerfile for HPC builds --- Dockerfile | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index b588f892..f4a40fe1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,32 +1,20 @@ -FROM ubuntu:20.04 as build +FROM ubuntu:22.04 as build RUN apt-get -y update && apt-get install -y apt-utils && \ apt-get install -y -qq -o=Dpkg::Use-Pty=0 build-essential gfortran zlib1g-dev \ - libhdf5-dev libcurl4-openssl-dev libboost-dev cmake wget python + libhdf5-dev ninja-build libcurl4-openssl-dev libboost-all-dev cmake wget python3 COPY . /vcellroot RUN mkdir -p /vcellroot/build/bin WORKDIR /vcellroot/build -RUN /usr/bin/cmake \ +RUN cmake \ + -G Ninja \ -DOPTION_TARGET_MESSAGING=ON \ -DOPTION_TARGET_SMOLDYN_SOLVER=OFF \ -DOPTION_TARGET_FV_SOLVER=ON \ -DOPTION_TARGET_DOCS=OFF \ .. && \ - make && \ + ninja && \ ctest - - -#RUN apt-get update && \ -# apt-get install -y apt-utils && \ -# apt-get install -q -y --no-install-recommends curl dnsutils -# -#RUN apt-get install -qq -y -o=Dpkg::Use-Pty=0 gcc gfortran zlib1g \ -# libhdf5-103 libhdf5-cpp-103 libcurl4-openssl-dev zip -# -#COPY --from=build /vcellroot/build/bin /vcellbin -#WORKDIR /vcellbin -#ENV PATH=/vcellbin:$PATH -# From 9463a3186b3688de0c2c4bfb26a6fd645cf380b3 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sun, 2 Jun 2024 11:24:14 -0400 Subject: [PATCH 10/29] try to fix windows build problem, include windows.h earlier --- VCell/src/DomainPDEScheduler.cpp | 1 + VCell/src/EllipticVolumeEqnBuilder.cpp | 1 + VCell/src/FiniteVolume.cpp | 5 +++++ VCell/src/TIFFImage.cpp | 1 + .../include/VCELL/SimulationMessaging.h | 19 +++++++++++-------- libzip-1.2.0/lib/zipwin32.h | 1 + smoldyn-2.38/source/lib/opengl2.h | 1 + 7 files changed, 21 insertions(+), 8 deletions(-) diff --git a/VCell/src/DomainPDEScheduler.cpp b/VCell/src/DomainPDEScheduler.cpp index e0de0df6..6e23ab68 100644 --- a/VCell/src/DomainPDEScheduler.cpp +++ b/VCell/src/DomainPDEScheduler.cpp @@ -3,6 +3,7 @@ * All rights reserved. */ #ifdef WIN32 +#define _HAS_STD_BYTE 0 #include #else #include diff --git a/VCell/src/EllipticVolumeEqnBuilder.cpp b/VCell/src/EllipticVolumeEqnBuilder.cpp index 2927cd6e..00435aa4 100644 --- a/VCell/src/EllipticVolumeEqnBuilder.cpp +++ b/VCell/src/EllipticVolumeEqnBuilder.cpp @@ -3,6 +3,7 @@ * All rights reserved. */ #ifdef WIN32 +#define _HAS_STD_BYTE 0 #include #endif diff --git a/VCell/src/FiniteVolume.cpp b/VCell/src/FiniteVolume.cpp index cdbb63e1..830a58d9 100644 --- a/VCell/src/FiniteVolume.cpp +++ b/VCell/src/FiniteVolume.cpp @@ -1,3 +1,8 @@ +#if (defined(WIN32) || defined(WIN64) ) +#define _HAS_STD_BYTE 0 +#include +#endif + #include #include #include diff --git a/VCell/src/TIFFImage.cpp b/VCell/src/TIFFImage.cpp index 4ec9c1ab..8dd9a2d6 100644 --- a/VCell/src/TIFFImage.cpp +++ b/VCell/src/TIFFImage.cpp @@ -3,6 +3,7 @@ * All rights reserved. */ #ifdef WIN32 +#define _HAS_STD_BYTE 0 #include #else #include diff --git a/VCellMessaging/include/VCELL/SimulationMessaging.h b/VCellMessaging/include/VCELL/SimulationMessaging.h index 20979cce..64b287fa 100644 --- a/VCellMessaging/include/VCELL/SimulationMessaging.h +++ b/VCellMessaging/include/VCELL/SimulationMessaging.h @@ -1,6 +1,17 @@ #ifndef _SIMULATIONMESSAGING_H_ #define _SIMULATIONMESSAGING_H_ +#if (defined(WIN32) || defined(WIN64) ) +#define _HAS_STD_BYTE 0 +#include +#else +#include +#include +#include +#include +#endif + + #include #ifdef USE_MESSAGING #include @@ -11,14 +22,6 @@ #include using namespace std; -#if (defined(WIN32) || defined(WIN64) ) -#include -#else -#include -#include -#include -#include -#endif #ifdef USE_MESSAGING #if (!defined(WIN32) && !defined(WIN64) ) diff --git a/libzip-1.2.0/lib/zipwin32.h b/libzip-1.2.0/lib/zipwin32.h index 60f8d0cf..407e0891 100644 --- a/libzip-1.2.0/lib/zipwin32.h +++ b/libzip-1.2.0/lib/zipwin32.h @@ -36,6 +36,7 @@ /* 0x0501 => Windows XP; needs to be at least this value because of GetFileSizeEx */ #define _WIN32_WINNT 0x0501 +#define _HAS_STD_BYTE 0 #include /* context for Win32 source */ diff --git a/smoldyn-2.38/source/lib/opengl2.h b/smoldyn-2.38/source/lib/opengl2.h index 1a919929..406df400 100644 --- a/smoldyn-2.38/source/lib/opengl2.h +++ b/smoldyn-2.38/source/lib/opengl2.h @@ -14,6 +14,7 @@ of the Gnu Lesser General Public License (LGPL). */ #if defined(HAVE_OPENGL) // Do NOT change the sequence of these if..elses without contacting Steve #ifdef WIN32 + #define _HAS_STD_BYTE 0 #include #endif From aa023e12f2bc17ac273b19daf6a1cf7d8e992983 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sun, 2 Jun 2024 12:49:17 -0400 Subject: [PATCH 11/29] define ZIP_STATIC for windows --- CMakeLists.txt | 1 + cmake/modules/CorrectWindowsPaths.cmake | 13 --- cmake/modules/FindPackageMultipass.cmake | 106 ----------------------- cmake/modules/ResolveCompilerPaths.cmake | 105 ---------------------- pyvcell-fvsolver/CMakeLists.txt | 1 + 5 files changed, 2 insertions(+), 224 deletions(-) delete mode 100644 cmake/modules/CorrectWindowsPaths.cmake delete mode 100644 cmake/modules/FindPackageMultipass.cmake delete mode 100644 cmake/modules/ResolveCompilerPaths.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index a82f75c1..bf8f6530 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -205,6 +205,7 @@ endif() set(HDF5_USE_STATIC_LIBRARIES ON) if(WINDOWS OR WIN32 OR WIN64) set(HDF5_USE_STATIC_LIBRARIES OFF) + add_definitions(-DZIP_STATIC) endif () #CMakeList.txt that comes with hdf5 switches library name if compiled with debug find_package(HDF5 COMPONENTS HL CXX C) diff --git a/cmake/modules/CorrectWindowsPaths.cmake b/cmake/modules/CorrectWindowsPaths.cmake deleted file mode 100644 index 8c3fcd85..00000000 --- a/cmake/modules/CorrectWindowsPaths.cmake +++ /dev/null @@ -1,13 +0,0 @@ -# CorrectWindowsPaths - this module defines one macro -# -# CONVERT_CYGWIN_PATH( PATH ) -# This uses the command cygpath (provided by cygwin) to convert -# unix-style paths into paths useable by cmake on windows - -macro (CONVERT_CYGWIN_PATH _path) - if (WIN32) - EXECUTE_PROCESS(COMMAND cygpath.exe -m ${${_path}} - OUTPUT_VARIABLE ${_path}) - string (STRIP ${${_path}} ${_path}) - endif (WIN32) -endmacro (CONVERT_CYGWIN_PATH) \ No newline at end of file diff --git a/cmake/modules/FindPackageMultipass.cmake b/cmake/modules/FindPackageMultipass.cmake deleted file mode 100644 index 6fa4e6a3..00000000 --- a/cmake/modules/FindPackageMultipass.cmake +++ /dev/null @@ -1,106 +0,0 @@ -# PackageMultipass - this module defines two macros -# -# FIND_PACKAGE_MULTIPASS (Name CURRENT -# STATES VAR0 VAR1 ... -# DEPENDENTS DEP0 DEP1 ...) -# -# This function creates a cache entry _CURRENT which -# the user can set to "NO" to trigger a reconfiguration of the package. -# The first time this function is called, the values of -# _VAR0, ... are saved. If _CURRENT -# is false or if any STATE has changed since the last time -# FIND_PACKAGE_MULTIPASS() was called, then CURRENT will be set to "NO", -# otherwise CURRENT will be "YES". IF not CURRENT, then -# _DEP0, ... will be FORCED to NOTFOUND. -# Example: -# find_path (FOO_DIR include/foo.h) -# FIND_PACKAGE_MULTIPASS (Foo foo_current -# STATES DIR -# DEPENDENTS INCLUDES LIBRARIES) -# if (NOT foo_current) -# # Make temporary files, run programs, etc, to determine FOO_INCLUDES and FOO_LIBRARIES -# endif (NOT foo_current) -# -# MULTIPASS_SOURCE_RUNS (Name INCLUDES LIBRARIES SOURCE RUNS LANGUAGE) -# Always runs the given test, use this when you need to re-run tests -# because parent variables have made old cache entries stale. The LANGUAGE -# variable is either C or CXX indicating which compiler the test should -# use. -# MULTIPASS_C_SOURCE_RUNS (Name INCLUDES LIBRARIES SOURCE RUNS) -# DEPRECATED! This is only included for backwards compatability. Use -# the more general MULTIPASS_SOURCE_RUNS instead. -# Always runs the given test, use this when you need to re-run tests -# because parent variables have made old cache entries stale. - -macro (FIND_PACKAGE_MULTIPASS _name _current) - string (TOUPPER ${_name} _NAME) - set (_args ${ARGV}) - list (REMOVE_AT _args 0 1) - - set (_states_current "YES") - list (GET _args 0 _cmd) - if (_cmd STREQUAL "STATES") - list (REMOVE_AT _args 0) - list (GET _args 0 _state) - while (_state AND NOT _state STREQUAL "DEPENDENTS") - # The name of the stored value for the given state - set (_stored_var PACKAGE_MULTIPASS_${_NAME}_${_state}) - if (NOT "${${_stored_var}}" STREQUAL "${${_NAME}_${_state}}") - set (_states_current "NO") - endif (NOT "${${_stored_var}}" STREQUAL "${${_NAME}_${_state}}") - set (${_stored_var} "${${_NAME}_${_state}}" CACHE INTERNAL "Stored state for ${_name}." FORCE) - list (REMOVE_AT _args 0) - list (GET _args 0 _state) - endwhile (_state AND NOT _state STREQUAL "DEPENDENTS") - endif (_cmd STREQUAL "STATES") - - set (_stored ${_NAME}_CURRENT) - if (NOT ${_stored}) - set (${_stored} "YES" CACHE BOOL "Is the configuration for ${_name} current? Set to \"NO\" to reconfigure." FORCE) - set (_states_current "NO") - endif (NOT ${_stored}) - - set (${_current} ${_states_current}) - if (NOT ${_current} AND PACKAGE_MULTIPASS_${_name}_CALLED) - message (STATUS "Clearing ${_name} dependent variables") - # Clear all the dependent variables so that the module can reset them - list (GET _args 0 _cmd) - if (_cmd STREQUAL "DEPENDENTS") - list (REMOVE_AT _args 0) - foreach (dep ${_args}) - set (${_NAME}_${dep} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) - endforeach (dep) - endif (_cmd STREQUAL "DEPENDENTS") - set (${_NAME}_FOUND "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) - endif () - set (PACKAGE_MULTIPASS_${name}_CALLED YES CACHE INTERNAL "Private" FORCE) -endmacro (FIND_PACKAGE_MULTIPASS) - - -macro (MULTIPASS_SOURCE_RUNS includes libraries source runs language) - include (Check${language}SourceRuns) - # This is a ridiculous hack. CHECK_${language}_SOURCE_* thinks that if the - # *name* of the return variable doesn't change, then the test does - # not need to be re-run. We keep an internal count which we - # increment to guarantee that every test name is unique. If we've - # gotten here, then the configuration has changed enough that the - # test *needs* to be rerun. - if (NOT MULTIPASS_TEST_COUNT) - set (MULTIPASS_TEST_COUNT 00) - endif (NOT MULTIPASS_TEST_COUNT) - math (EXPR _tmp "${MULTIPASS_TEST_COUNT} + 1") # Why can't I add to a cache variable? - set (MULTIPASS_TEST_COUNT ${_tmp} CACHE INTERNAL "Unique test ID") - set (testname MULTIPASS_TEST_${MULTIPASS_TEST_COUNT}_${runs}) - set (CMAKE_REQUIRED_INCLUDES ${includes}) - set (CMAKE_REQUIRED_LIBRARIES ${libraries}) - if(${language} STREQUAL "C") - check_c_source_runs ("${source}" ${testname}) - elseif(${language} STREQUAL "CXX") - check_cxx_source_runs ("${source}" ${testname}) - endif() - set (${runs} "${${testname}}") -endmacro (MULTIPASS_SOURCE_RUNS) - -macro (MULTIPASS_C_SOURCE_RUNS includes libraries source runs) - multipass_source_runs("${includes}" "${libraries}" "${source}" ${runs} "C") -endmacro (MULTIPASS_C_SOURCE_RUNS) \ No newline at end of file diff --git a/cmake/modules/ResolveCompilerPaths.cmake b/cmake/modules/ResolveCompilerPaths.cmake deleted file mode 100644 index 8f865e2f..00000000 --- a/cmake/modules/ResolveCompilerPaths.cmake +++ /dev/null @@ -1,105 +0,0 @@ -# ResolveCompilerPaths - this module defines two macros -# -# RESOLVE_LIBRARIES (XXX_LIBRARIES LINK_LINE) -# This macro is intended to be used by FindXXX.cmake modules. -# It parses a compiler link line and resolves all libraries -# (-lfoo) using the library path contexts (-L/path) in scope. -# The result in XXX_LIBRARIES is the list of fully resolved libs. -# Example: -# -# RESOLVE_LIBRARIES (FOO_LIBRARIES "-L/A -la -L/B -lb -lc -ld") -# -# will be resolved to -# -# FOO_LIBRARIES:STRING="/A/liba.so;/B/libb.so;/A/libc.so;/usr/lib/libd.so" -# -# if the filesystem looks like -# -# /A: liba.so libc.so -# /B: liba.so libb.so -# /usr/lib: liba.so libb.so libc.so libd.so -# -# and /usr/lib is a system directory. -# -# Note: If RESOLVE_LIBRARIES() resolves a link line differently from -# the native linker, there is a bug in this macro (please report it). -# -# RESOLVE_INCLUDES (XXX_INCLUDES INCLUDE_LINE) -# This macro is intended to be used by FindXXX.cmake modules. -# It parses a compile line and resolves all includes -# (-I/path/to/include) to a list of directories. Other flags are ignored. -# Example: -# -# RESOLVE_INCLUDES (FOO_INCLUDES "-I/A -DBAR='\"irrelevant -I/string here\"' -I/B") -# -# will be resolved to -# -# FOO_INCLUDES:STRING="/A;/B" -# -# assuming both directories exist. -# Note: as currently implemented, the -I/string will be picked up mistakenly (cry, cry) -include (CorrectWindowsPaths) - -macro (RESOLVE_LIBRARIES LIBS LINK_LINE) - string (REGEX MATCHALL "((-L|-l|-Wl)([^\" ]+|\"[^\"]+\")|[^\" ]+\\.(a|so|dll|lib))" _all_tokens "${LINK_LINE}") - set (_libs_found "") - set (_directory_list "") - foreach (token ${_all_tokens}) - if (token MATCHES "-L([^\" ]+|\"[^\"]+\")") - # If it's a library path, add it to the list - string (REGEX REPLACE "^-L" "" token ${token}) - string (REGEX REPLACE "//" "/" token ${token}) - convert_cygwin_path(token) - list (APPEND _directory_list ${token}) - elseif (token MATCHES "^(-l([^\" ]+|\"[^\"]+\")|[^\" ]+\\.(a|so|dll|lib))") - # It's a library, resolve the path by looking in the list and then (by default) in system directories - if (WIN32) #windows expects "libfoo", linux expects "foo" - string (REGEX REPLACE "^-l" "lib" token ${token}) - else (WIN32) - string (REGEX REPLACE "^-l" "" token ${token}) - endif (WIN32) - set (_root "") - if (token MATCHES "^/") # We have an absolute path - #separate into a path and a library name: - string (REGEX MATCH "[^/]*\\.(a|so|dll|lib)$" libname ${token}) - string (REGEX MATCH ".*[^${libname}$]" libpath ${token}) - convert_cygwin_path(libpath) - set (_directory_list ${_directory_list} ${libpath}) - set (token ${libname}) - endif (token MATCHES "^/") - set (_lib "NOTFOUND" CACHE FILEPATH "Cleared" FORCE) - find_library (_lib ${token} HINTS ${_directory_list} ${_root}) - if (_lib) - string (REPLACE "//" "/" _lib ${_lib}) - list (APPEND _libs_found ${_lib}) - else (_lib) - message (STATUS "Unable to find library ${token}") - endif (_lib) - endif (token MATCHES "-L([^\" ]+|\"[^\"]+\")") - endforeach (token) - set (_lib "NOTFOUND" CACHE INTERNAL "Scratch variable" FORCE) - # only the LAST occurence of each library is required since there should be no circular dependencies - if (_libs_found) - list (REVERSE _libs_found) - list (REMOVE_DUPLICATES _libs_found) - list (REVERSE _libs_found) - endif (_libs_found) - set (${LIBS} "${_libs_found}") -endmacro (RESOLVE_LIBRARIES) - -macro (RESOLVE_INCLUDES INCS COMPILE_LINE) - string (REGEX MATCHALL "-I([^\" ]+|\"[^\"]+\")" _all_tokens "${COMPILE_LINE}") - set (_incs_found "") - foreach (token ${_all_tokens}) - string (REGEX REPLACE "^-I" "" token ${token}) - string (REGEX REPLACE "//" "/" token ${token}) - convert_cygwin_path(token) - if (EXISTS ${token}) - list (APPEND _incs_found ${token}) - else (EXISTS ${token}) - message (STATUS "Include directory ${token} does not exist") - endif (EXISTS ${token}) - endforeach (token) - list (REMOVE_DUPLICATES _incs_found) - set (${INCS} "${_incs_found}") -endmacro (RESOLVE_INCLUDES) \ No newline at end of file diff --git a/pyvcell-fvsolver/CMakeLists.txt b/pyvcell-fvsolver/CMakeLists.txt index 095dfd4a..05530d00 100644 --- a/pyvcell-fvsolver/CMakeLists.txt +++ b/pyvcell-fvsolver/CMakeLists.txt @@ -111,6 +111,7 @@ add_definitions(-DUNIX) set(HDF5_USE_STATIC_LIBRARIES ON) if(WINDOWS OR WIN32 OR WIN64) set(HDF5_USE_STATIC_LIBRARIES OFF) + add_definitions(-DZIP_STATIC) endif () #CMakeList.txt that comes with hdf5 switches library name if compiled with debug find_package(HDF5 COMPONENTS HL CXX C) From b2feff657a5ad514dea59d3ddd335361d30d9987 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sun, 2 Jun 2024 13:03:54 -0400 Subject: [PATCH 12/29] WIP: python build CI/CD actions --- .github/workflows/conda.yml | 44 ++++++++++++++ .github/workflows/enscripten.yaml | 60 +++++++++++++++++++ .github/workflows/pip.yml | 31 ++++++++++ .github/workflows/wheels.yml | 99 +++++++++++++++++++++++++++++++ 4 files changed, 234 insertions(+) create mode 100644 .github/workflows/conda.yml create mode 100644 .github/workflows/enscripten.yaml create mode 100644 .github/workflows/pip.yml create mode 100644 .github/workflows/wheels.yml diff --git a/.github/workflows/conda.yml b/.github/workflows/conda.yml new file mode 100644 index 00000000..fc267d8e --- /dev/null +++ b/.github/workflows/conda.yml @@ -0,0 +1,44 @@ +name: Conda + +on: + workflow_dispatch: + push: + branches: + - master + pull_request: + +jobs: + build: + strategy: + fail-fast: false + matrix: + platform: [ubuntu-latest, macos-13, macos-14, windows-latest] + python-version: ["3.8", "3.11"] + + runs-on: ${{ matrix.platform }} + + # The setup-miniconda action needs this to activate miniconda + defaults: + run: + shell: "bash -l {0}" + + steps: + - uses: actions/checkout@v4 + + - name: Get conda + uses: conda-incubator/setup-miniconda@v3.0.4 + with: + python-version: ${{ matrix.python-version }} + channels: conda-forge + + - name: Prepare + run: conda install conda-build conda-verify pytest + + - name: Build + run: conda build conda.recipe + + - name: Install + run: conda install -c ${CONDA_PREFIX}/conda-bld/ pyvcell_fvsolver + + - name: Test + run: pytest tests diff --git a/.github/workflows/enscripten.yaml b/.github/workflows/enscripten.yaml new file mode 100644 index 00000000..7a5de098 --- /dev/null +++ b/.github/workflows/enscripten.yaml @@ -0,0 +1,60 @@ +name: WASM + +on: + workflow_dispatch: + pull_request: + branches: + - master + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + build-wasm-emscripten: + name: Pyodide + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + + - uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install pyodide-build + run: pip install pyodide-build==0.23.4 + + - name: Compute emsdk version + id: compute-emsdk-version + run: | + pyodide xbuildenv install --download + EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version) + echo "emsdk-version=$EMSCRIPTEN_VERSION" >> $GITHUB_OUTPUT + + - uses: mymindstorm/setup-emsdk@v14 + with: + version: ${{ steps.compute-emsdk-version.outputs.emsdk-version }} + actions-cache-folder: emsdk-cache + + # A future version of pyodide may switch to -fwasm-exceptions + - name: Build + run: CFLAGS=-fexceptions LDFLAGS=-fexceptions pyodide build + + - uses: actions/upload-artifact@v4 + with: + path: dist/*.whl + + - uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Set up Pyodide virtual environment + run: | + pyodide venv .venv-pyodide + .venv-pyodide/bin/pip install $(echo -n dist/*.whl)[test] + + - name: Test + run: .venv-pyodide/bin/pytest diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml new file mode 100644 index 00000000..a1f2173a --- /dev/null +++ b/.github/workflows/pip.yml @@ -0,0 +1,31 @@ +name: "Pip" + +on: + workflow_dispatch: + pull_request: + push: + branches: + - master + +jobs: + build: + name: Build with Pip + runs-on: ${{ matrix.platform }} + strategy: + fail-fast: false + matrix: + platform: [windows-latest, macos-13, ubuntu-latest] + python-version: ["3.7", "3.12", "pypy-3.9"] + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Build and install + run: pip install --verbose ./pyvcell-fvsolver + + - name: Test + run: pytest diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml new file mode 100644 index 00000000..3fcfe235 --- /dev/null +++ b/.github/workflows/wheels.yml @@ -0,0 +1,99 @@ +name: Wheels + +on: + workflow_dispatch: + pull_request: + push: + branches: + - master + release: + types: + - published + +env: + FORCE_COLOR: 3 + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + build_sdist: + name: Build SDist + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - name: Build SDist + working-directory: pyvcell-fvsolver + run: pipx run build --sdist + + - name: Check metadata + working-directory: pyvcell-fvsolver + run: pipx run twine check dist/* + + - name: artifact upload + uses: actions/upload-artifact@v4 + with: + name: cibw-sdist + path: dist/*.tar.gz + working-directory: pyvcell-fvsolver + + + build_wheels: + name: Wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-13, macos-14, windows-latest] + + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - name: build wheel + uses: pypa/cibuildwheel@v2.17 + with: + working-directory: pyvcell-fvsolver + env: + CIBW_ARCHS_MACOS: universal2 + CIBW_ARCHS_WINDOWS: auto ARM64 + + - name: Verify clean directory + working-directory: pyvcell-fvsolver + run: git diff --exit-code + shell: bash + + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }} + working-directory: pyvcell-fvsolver + path: wheelhouse/*.whl + + + upload_all: + name: Upload if release + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + if: github.event_name == 'release' && github.event.action == 'published' + environment: pypi + permissions: + id-token: write + + steps: + - uses: actions/setup-python@v5 + with: + python-version: "3.x" + + - uses: actions/download-artifact@v4 + with: + working-directory: pyvcell-fvsolver + pattern: cibw-* + merge-multiple: true + path: dist + + - uses: pypa/gh-action-pypi-publish@release/v1 From bde32e34a9e401073c57f311f501aac78f53edd0 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sun, 2 Jun 2024 14:05:01 -0400 Subject: [PATCH 13/29] reconcile whitespace and dead code in CMakeLists.txt before merge --- CMakeLists.txt | 79 +++--------------- pyvcell-fvsolver/CMakeLists.txt | 140 ++++++++++++++++---------------- 2 files changed, 83 insertions(+), 136 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf8f6530..2be996eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,15 +56,10 @@ if(POLICY CMP0057) cmake_policy(SET CMP0057 NEW) endif() -#include (LocalJNI.cmake) - -set(RULE_MESSAGES OFF) -set(CMAKE_COLOR_MAKEFILE OFF) -set(_ECLIPSE_VERSION "4.4") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") include(GetGitRevisionDescription) -git_describe(GIT_DESCRIBE) +git_describe(GIT_DESCRIBE ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) @@ -77,45 +72,18 @@ else() SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") endif() -#include (CMakeTestCCompiler) -#include (CheckCSourceCompiles) -#include (CheckCXXSourceCompiles) -#include (CheckStructHasMember) -#include (CheckLibraryExists) -#include (CheckFunctionExists) -#include (CheckCCompilerFlag) -#include (CheckCSourceRuns) -#include (CheckSymbolExists) -#include (CheckTypeSize) include (FindZLIB) -#message("gen "${CMAKE_GENERATOR}) -#message("extra "${CMAKE_EXTRA_GENERATOR}) -#message("system "${CMAKE_SYSTEM_NAME}) -#message("windows "${WINDOWS}) option(OPTION_TARGET_MESSAGING "Messaging (requires libcurl)" off) -option(OPTION_TARGET_DOCS "Generate Doxygen documentation" on) +option(OPTION_TARGET_DOCS "Generate Doxygen documentation" off) option(OPTION_TARGET_FV_SOLVER on) option(OPTION_TARGET_MESSAGING "Messaging (requires libcurl)" off) if (${OPTION_TARGET_DOCS}) -# if (DOXYGEN_FOUND AND ${CMAKE_VERSION} GREATER_EQUAL 3.9) -# find_package(Doxygen -# REQUIRED dot -# OPTIONAL_COMPONENTS mscgen dia) -# set(DOXYGEN_GENERATE_HTML YES) -# set(DOXYGEN_GENERATE_MAN NO) -# doxygen_add_docs( -# doxygen -# ${PROJECT_SOURCE_DIR} -# COMMENT "Generate man pages" -# ) -# else() - add_custom_target(graphviz ALL + add_custom_target(graphviz ALL "${CMAKE_COMMAND}" "--graphviz=dependencies.dot" . WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") -# endif() endif() if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") @@ -144,11 +112,6 @@ if (NOT APPLE AND NOT LINUX AND NOT MINGW) message(FATAL_ERROR "Unsupported Operating System or C/C++ Compiler.") endif() -#f (LINUX) -#set(BUILD_SHARED_LIBRARIES OFF) -#set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") -#endif() - #--------------------------- # IDE SUPPORT #--------------------------- @@ -174,19 +137,7 @@ set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}") add_definitions(-DUNIX) -#if (MINGW) -# add_definitions(-DWIN32) -#endif(MINGW) - -#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") -#set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") - - if (OPTION_TARGET_MESSAGING) -# if (APPLE OR MINGW) -# message(FATAL_ERROR "TARGET_SOLVERS_WITH_MESSAGING is not supported on MAC OS X and MINGW") -# endif(APPLE OR MINGW) - #don't need graphics for server side solvers set(OPTION_USE_OPENGL OFF CACHE BOOL "") @@ -196,21 +147,15 @@ if (OPTION_TARGET_MESSAGING) add_definitions(-DUSE_MESSAGING) endif() -###################################### -# -# Add subdirectories -# -####################################### - - set(HDF5_USE_STATIC_LIBRARIES ON) - if(WINDOWS OR WIN32 OR WIN64) - set(HDF5_USE_STATIC_LIBRARIES OFF) - add_definitions(-DZIP_STATIC) - endif () - #CMakeList.txt that comes with hdf5 switches library name if compiled with debug - find_package(HDF5 COMPONENTS HL CXX C) - set(HDF_VERSION ${HDF5_VERSION}) - ###### ${HDF5_HL_LIBRARIES} ${HDF5_CXX_LIBRARIES} +set(HDF5_USE_STATIC_LIBRARIES ON) +if(WINDOWS OR WIN32 OR WIN64) + set(HDF5_USE_STATIC_LIBRARIES OFF) + add_definitions(-DZIP_STATIC) +endif () +#CMakeList.txt that comes with hdf5 switches library name if compiled with debug +find_package(HDF5 COMPONENTS HL CXX C) +set(HDF_VERSION ${HDF5_VERSION}) +###### ${HDF5_HL_LIBRARIES} ${HDF5_CXX_LIBRARIES} add_subdirectory(VCellMessaging) diff --git a/pyvcell-fvsolver/CMakeLists.txt b/pyvcell-fvsolver/CMakeLists.txt index 05530d00..83c05561 100644 --- a/pyvcell-fvsolver/CMakeLists.txt +++ b/pyvcell-fvsolver/CMakeLists.txt @@ -18,48 +18,48 @@ endif() # ############################################## if (APPLE) - execute_process(COMMAND uname -m OUTPUT_VARIABLE PROCESSOR_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE) - message("Processor Architecture: ${PROCESSOR_ARCHITECTURE}") - if (PROCESSOR_ARCHITECTURE STREQUAL "arm64") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__arm64__") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__arm64__") - set(CMAKE_OSX_ARCHITECTURES "arm64") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__x86_64__") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__x86_64__") - set(CMAKE_OSX_ARCHITECTURES "x86_64") - endif() - # set(CMAKE_Fortran_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=10.7" CACHE PATH "") - # set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE PATH "") - ############################################# - # - # Choose 32bit or 64bit target arch on Linux - # - ############################################## + execute_process(COMMAND uname -m OUTPUT_VARIABLE PROCESSOR_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE) + message("Processor Architecture: ${PROCESSOR_ARCHITECTURE}") + if (PROCESSOR_ARCHITECTURE STREQUAL "arm64") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__arm64__") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__arm64__") + set(CMAKE_OSX_ARCHITECTURES "arm64") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__x86_64__") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__x86_64__") + set(CMAKE_OSX_ARCHITECTURES "x86_64") + endif() +# set(CMAKE_Fortran_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=10.7" CACHE PATH "") +# set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE PATH "") +############################################# +# +# Choose 32bit or 64bit target arch on Linux +# +############################################## elseif (LINUX) - option(LINUX_32bit_BINARIES "Build 32bit Linux BINARIES" OFF) - option(LINUX_64bit_BINARIES "Build 64bit Linux BINARIES" ON) - - if (LINUX_32bit_BINARIES AND LINUX_64bit_BINARIES) - message(FATAL_ERROR "It is required to select either 32bit or 64bit Linux Binaries, not both") - endif() - - if (LINUX_32bit_BINARIES) - set (ARCH_64bit FALSE) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") - set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -m32") - endif() - - if (LINUX_64bit_BINARIES) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64") - set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -m64") - endif() + option(LINUX_32bit_BINARIES "Build 32bit Linux BINARIES" OFF) + option(LINUX_64bit_BINARIES "Build 64bit Linux BINARIES" ON) + + if (LINUX_32bit_BINARIES AND LINUX_64bit_BINARIES) + message(FATAL_ERROR "It is required to select either 32bit or 64bit Linux Binaries, not both") + endif() + + if (LINUX_32bit_BINARIES) + set (ARCH_64bit FALSE) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") + set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -m32") + endif() + + if (LINUX_64bit_BINARIES) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64") + set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -m64") + endif() endif() if(POLICY CMP0057) - cmake_policy(SET CMP0057 NEW) + cmake_policy(SET CMP0057 NEW) endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") @@ -82,23 +82,23 @@ endif() set(LINUX FALSE) if (${CMAKE_SYSTEM_NAME} MATCHES Linux) - set(LINUX TRUE) + set(LINUX TRUE) endif() set(WINDOWS FALSE) if (${CMAKE_SYSTEM_NAME} MATCHES Windows) - set(WINDOWS TRUE) - set(WIN32 TRUE) - set(MINGW TRUE) + set(WINDOWS TRUE) + set(WIN32 TRUE) + set(MINGW TRUE) endif() set (ARCH_64bit FALSE) if (CMAKE_SIZEOF_VOID_P EQUAL 8) - set (ARCH_64bit TRUE) + set (ARCH_64bit TRUE) endif() if (NOT APPLE AND NOT LINUX AND NOT MINGW) - message(FATAL_ERROR "Unsupported Operating System or C/C++ Compiler.") + message(FATAL_ERROR "Unsupported Operating System or C/C++ Compiler.") endif() add_definitions(-DFORTRAN_UNDERSCORE) @@ -106,47 +106,49 @@ add_definitions(-DFORTRAN_UNDERSCORE) set(OPTION_EXE_DIRECTORY "bin" CACHE PATH "installation directory") set(OPTION_LIB_DIRECTORY "lib" CACHE PATH "library directory") set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}") + + add_definitions(-DUNIX) set(HDF5_USE_STATIC_LIBRARIES ON) if(WINDOWS OR WIN32 OR WIN64) - set(HDF5_USE_STATIC_LIBRARIES OFF) - add_definitions(-DZIP_STATIC) + set(HDF5_USE_STATIC_LIBRARIES OFF) + add_definitions(-DZIP_STATIC) endif () #CMakeList.txt that comes with hdf5 switches library name if compiled with debug find_package(HDF5 COMPONENTS HL CXX C) set(HDF_VERSION ${HDF5_VERSION}) ###### ${HDF5_HL_LIBRARIES} ${HDF5_CXX_LIBRARIES} -add_subdirectory(../VCellMessaging bin/VCellMessaging) + add_subdirectory(../VCellMessaging bin/VCellMessaging) -add_subdirectory(../VCellZipUtils bin/VCellZipUtils) + add_subdirectory(../VCellZipUtils bin/VCellZipUtils) -add_subdirectory(../libzip-1.2.0 bin/libzip-1.2.0) + add_subdirectory(../libzip-1.2.0 bin/libzip-1.2.0) -add_subdirectory(../ExpressionParser bin/ExpressionParser) + add_subdirectory(../ExpressionParser bin/ExpressionParser) -add_subdirectory(../sundials bin/sundials) + add_subdirectory(../sundials bin/sundials) -if (NOT APPLE) - add_subdirectory(../blas bin/blas) -endif() + if (NOT APPLE) + add_subdirectory(../blas bin/blas) + endif() + + option(OPTION_VCELL "Compile Smoldyn for VCell" ON) + option(OPTION_NSV "Compile Smoldyn with NextSubvolume functionality" OFF) + option(OPTION_USE_OPENGL "Build with OpenGL support" OFF) + option(OPTION_USE_ZLIB "Build with Zlib support" ON) + option(OPTION_USE_LIBTIFF "Build with LibTiff support" OFF) + option(OPTION_USE_ICONV "Build with Libiconv support" OFF) + SET(HAVE_ZLIB TRUE) + set(OPTION_TARGET_LIBSMOLDYN ON) + set(OPTION_VCELL ON) + add_subdirectory(../bridgeVCellSmoldyn bin/bridgeVCellSmoldyn) + add_subdirectory(../smoldyn-2.38 bin/smoldyn-2.38) -option(OPTION_VCELL "Compile Smoldyn for VCell" ON) -option(OPTION_NSV "Compile Smoldyn with NextSubvolume functionality" OFF) -option(OPTION_USE_OPENGL "Build with OpenGL support" OFF) -option(OPTION_USE_ZLIB "Build with Zlib support" ON) -option(OPTION_USE_LIBTIFF "Build with LibTiff support" OFF) -option(OPTION_USE_ICONV "Build with Libiconv support" OFF) -SET(HAVE_ZLIB TRUE) -set(OPTION_TARGET_LIBSMOLDYN ON) -set(OPTION_VCELL ON) -add_subdirectory(../bridgeVCellSmoldyn bin/bridgeVCellSmoldyn) -add_subdirectory(../smoldyn-2.38 bin/smoldyn-2.38) - -add_subdirectory(../VCell bin/VCell) -add_subdirectory(../PCGPack bin/PCGPack) -add_subdirectory(../qhull bin/qhull) + add_subdirectory(../VCell bin/VCell) + add_subdirectory(../PCGPack bin/PCGPack) + add_subdirectory(../qhull bin/qhull) From 73a7fc0b57b382a0e51ccf2a78e7e7956c0c6ee4 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sun, 2 Jun 2024 14:57:26 -0400 Subject: [PATCH 14/29] one /CMakeLists.txt with with OPTION_TARGET_PYTHON_BINDING [true] --- .github/workflows/cd.yml | 4 + .github/workflows/conda.yml | 2 +- .github/workflows/pip.yml | 2 +- .github/workflows/wheels.yml | 8 - CMakeLists.txt | 246 ++++++++------- Dockerfile | 1 + .../pyproject.toml => pyproject.toml | 0 pyvcell-fvsolver/CMakeLists.txt | 168 ----------- pyvcell-fvsolver/README.md | 1 - .../modules/GetGitRevisionDescription.cmake | 284 ------------------ .../GetGitRevisionDescription.cmake.in | 45 --- {pyvcell-fvsolver/src => src}/SolverMain.cpp | 0 {pyvcell-fvsolver/src => src}/SolverMain.h | 0 {pyvcell-fvsolver/src => src}/main.cpp | 0 .../src => src}/pyvcell_fvsolver/__init__.py | 0 {pyvcell-fvsolver/test => test}/test.py | 0 16 files changed, 137 insertions(+), 624 deletions(-) rename pyvcell-fvsolver/pyproject.toml => pyproject.toml (100%) delete mode 100644 pyvcell-fvsolver/CMakeLists.txt delete mode 100644 pyvcell-fvsolver/README.md delete mode 100644 pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake delete mode 100644 pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake.in rename {pyvcell-fvsolver/src => src}/SolverMain.cpp (100%) rename {pyvcell-fvsolver/src => src}/SolverMain.h (100%) rename {pyvcell-fvsolver/src => src}/main.cpp (100%) rename {pyvcell-fvsolver/src => src}/pyvcell_fvsolver/__init__.py (100%) rename {pyvcell-fvsolver/test => test}/test.py (100%) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index c6bf330e..45846e9c 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -104,6 +104,7 @@ jobs: -G Ninja \ -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang \ -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++ \ + -DOPTION_TARGET_PYTHON_BINDING=OFF \ -DOPTION_MINGW=ON \ -DOPTION_TARGET_MESSAGING=OFF \ -DOPTION_TARGET_SMOLDYN_SOLVER=OFF \ @@ -128,6 +129,7 @@ jobs: -G Ninja \ -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang \ -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++ \ + -DOPTION_TARGET_PYTHON_BINDING=OFF \ -DOPTION_MINGW=ON \ -DOPTION_TARGET_MESSAGING=OFF \ -DOPTION_TARGET_SMOLDYN_SOLVER=OFF \ @@ -205,6 +207,7 @@ jobs: -G Ninja \ -DCMAKE_C_COMPILER="clang.exe" \ -DCMAKE_CXX_COMPILER="clang++.exe" \ + -DOPTION_TARGET_PYTHON_BINDING=OFF \ -DOPTION_TARGET_MESSAGING=OFF \ -DOPTION_TARGET_SMOLDYN_SOLVER=OFF \ -DOPTION_TARGET_FV_SOLVER=ON \ @@ -253,6 +256,7 @@ jobs: cmake \ -G Ninja \ + -DOPTION_TARGET_PYTHON_BINDING=OFF \ -DOPTION_TARGET_MESSAGING=OFF \ -DOPTION_TARGET_SMOLDYN_SOLVER=OFF \ -DOPTION_TARGET_FV_SOLVER=ON \ diff --git a/.github/workflows/conda.yml b/.github/workflows/conda.yml index fc267d8e..cd3643f9 100644 --- a/.github/workflows/conda.yml +++ b/.github/workflows/conda.yml @@ -38,7 +38,7 @@ jobs: run: conda build conda.recipe - name: Install - run: conda install -c ${CONDA_PREFIX}/conda-bld/ pyvcell_fvsolver + run: conda install -c ${CONDA_PREFIX}/conda-bld/ . - name: Test run: pytest tests diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml index a1f2173a..933c4cc1 100644 --- a/.github/workflows/pip.yml +++ b/.github/workflows/pip.yml @@ -25,7 +25,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Build and install - run: pip install --verbose ./pyvcell-fvsolver + run: pip install --verbose . - name: Test run: pytest diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 3fcfe235..7f1dea9a 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -27,11 +27,9 @@ jobs: submodules: true - name: Build SDist - working-directory: pyvcell-fvsolver run: pipx run build --sdist - name: Check metadata - working-directory: pyvcell-fvsolver run: pipx run twine check dist/* - name: artifact upload @@ -39,7 +37,6 @@ jobs: with: name: cibw-sdist path: dist/*.tar.gz - working-directory: pyvcell-fvsolver build_wheels: @@ -57,21 +54,17 @@ jobs: - name: build wheel uses: pypa/cibuildwheel@v2.17 - with: - working-directory: pyvcell-fvsolver env: CIBW_ARCHS_MACOS: universal2 CIBW_ARCHS_WINDOWS: auto ARM64 - name: Verify clean directory - working-directory: pyvcell-fvsolver run: git diff --exit-code shell: bash - uses: actions/upload-artifact@v4 with: name: cibw-wheels-${{ matrix.os }} - working-directory: pyvcell-fvsolver path: wheelhouse/*.whl @@ -91,7 +84,6 @@ jobs: - uses: actions/download-artifact@v4 with: - working-directory: pyvcell-fvsolver pattern: cibw-* merge-multiple: true path: dist diff --git a/CMakeLists.txt b/CMakeLists.txt index 2be996eb..2eab5166 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,47 @@ -############################################# -# -# Build 64bit binaries on Mac and target Macos 10.7 or later -# -############################################## +cmake_minimum_required(VERSION 3.27) +option(OPTION_TARGET_PYTHON_BINDING "build Python bindings" ON) +option(OPTION_TARGET_MESSAGING "Messaging (requires libcurl)" off) +option(OPTION_TARGET_DOCS "Generate Doxygen documentation" off) +option(OPTION_TARGET_FV_SOLVER on) +option(OPTION_VCELL "Compile Smoldyn for VCell" ON) +option(OPTION_NSV "Compile Smoldyn with NextSubvolume functionality" OFF) +option(OPTION_USE_OPENGL "Build with OpenGL support" OFF) +option(OPTION_USE_ZLIB "Build with Zlib support" ON) +option(OPTION_USE_LIBTIFF "Build with LibTiff support" OFF) +option(OPTION_USE_ICONV "Build with Libiconv support" OFF) + + +if (OPTION_TARGET_PYTHON_BINDING) + project( + ${SKBUILD_PROJECT_NAME} + VERSION ${SKBUILD_PROJECT_VERSION} + LANGUAGES CXX C Fortran) + set(OPTION_TARGET_MESSAGING OFF) + set(OPTION_TARGET_FV_SOLVER ON) + set(OPTION_TARGET_DOCS OFF) + set(OPTION_VCELL ON) + set(OPTION_NSV OFF) + set(OPTION_USE_OPENGL OFF) + set(OPTION_USE_ZLIB ON) + set(OPTION_USE_LIBTIFF OFF) + set(OPTION_USE_ICONV OFF) +else() + project( + fvsolver + LANGUAGES CXX C Fortran) + set(OPTION_TARGET_LIBSMOLDYN ON) + set(OPTION_VCELL ON) +endif () + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(OPTION_USE_OPENGL OFF CACHE BOOL "") + +if(POLICY CMP0057) + cmake_policy(SET CMP0057 NEW) +endif() + if (APPLE) execute_process(COMMAND uname -m OUTPUT_VARIABLE PROCESSOR_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE) message("Processor Architecture: ${PROCESSOR_ARCHITECTURE}") @@ -15,13 +54,6 @@ if (APPLE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__x86_64__") set(CMAKE_OSX_ARCHITECTURES "x86_64") endif() -# set(CMAKE_Fortran_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=10.7" CACHE PATH "") -# set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE PATH "") -############################################# -# -# Choose 32bit or 64bit target arch on Linux -# -############################################## elseif (LINUX) option(LINUX_32bit_BINARIES "Build 32bit Linux BINARIES" OFF) option(LINUX_64bit_BINARIES "Build 64bit Linux BINARIES" ON) @@ -44,47 +76,29 @@ elseif (LINUX) endif() endif() -cmake_minimum_required(VERSION 3.17...3.27) -project(fvsolver) -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -enable_language(CXX) -enable_language(C) -enable_language(Fortran) - -if(POLICY CMP0057) - cmake_policy(SET CMP0057 NEW) -endif() - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") include(GetGitRevisionDescription) git_describe(GIT_DESCRIBE ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - -#include (VCellCMakeShowVariables.txt) - -if(DEFINED CMAKE_BUILD_TYPE) - SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") -else() - SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") -endif() - include (FindZLIB) -option(OPTION_TARGET_MESSAGING "Messaging (requires libcurl)" off) -option(OPTION_TARGET_DOCS "Generate Doxygen documentation" off) -option(OPTION_TARGET_FV_SOLVER on) -option(OPTION_TARGET_MESSAGING "Messaging (requires libcurl)" off) +if (NOT OPTION_TARGET_PYTHON_BINDING) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - -if (${OPTION_TARGET_DOCS}) - add_custom_target(graphviz ALL - "${CMAKE_COMMAND}" "--graphviz=dependencies.dot" . - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") -endif() + if(DEFINED CMAKE_BUILD_TYPE) + SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") + else() + SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") + endif() + + if (${OPTION_TARGET_DOCS}) + add_custom_target(graphviz ALL + "${CMAKE_COMMAND}" "--graphviz=dependencies.dot" . + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") + endif() +endif(NOT OPTION_TARGET_PYTHON_BINDING) if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") @@ -112,35 +126,24 @@ if (NOT APPLE AND NOT LINUX AND NOT MINGW) message(FATAL_ERROR "Unsupported Operating System or C/C++ Compiler.") endif() -#--------------------------- -# IDE SUPPORT -#--------------------------- -if (MINGW) - set(NETBEANS_WINDOWS TRUE) - set(CMAKE_RC_FLAGS "-DGCC_WINDRES") -endif(MINGW) - add_definitions(-DFORTRAN_UNDERSCORE) ############################################# # installation directories ############################################# -if (NOT OPTION_TARGET_MESSAGING) - set(OPTION_EXE_DIRECTORY "bin" CACHE PATH "installation directory") -else (NOT OPTION_TARGET_MESSAGING) - set(OPTION_EXE_DIRECTORY "../bin" CACHE PATH "installation directory") -endif (NOT OPTION_TARGET_MESSAGING) - -set(OPTION_LIB_DIRECTORY "lib" CACHE PATH "library directory") -set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}") - +if (NOT OPTION_TARGET_PYTHON_BINDING) + if (NOT OPTION_TARGET_MESSAGING) + set(OPTION_EXE_DIRECTORY "bin" CACHE PATH "installation directory") + else (NOT OPTION_TARGET_MESSAGING) + set(OPTION_EXE_DIRECTORY "../bin" CACHE PATH "installation directory") + endif (NOT OPTION_TARGET_MESSAGING) + set(OPTION_LIB_DIRECTORY "lib" CACHE PATH "library directory") + set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}") +endif (NOT OPTION_TARGET_PYTHON_BINDING) add_definitions(-DUNIX) if (OPTION_TARGET_MESSAGING) - #don't need graphics for server side solvers - set(OPTION_USE_OPENGL OFF CACHE BOOL "") - find_package(CURL REQUIRED) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) @@ -157,62 +160,73 @@ find_package(HDF5 COMPONENTS HL CXX C) set(HDF_VERSION ${HDF5_VERSION}) ###### ${HDF5_HL_LIBRARIES} ${HDF5_CXX_LIBRARIES} - add_subdirectory(VCellMessaging) - - add_subdirectory(VCellZipUtils) +add_subdirectory(VCellMessaging) - add_subdirectory(libzip-1.2.0) +add_subdirectory(VCellZipUtils) - add_subdirectory(ExpressionParser) +add_subdirectory(libzip-1.2.0) - add_subdirectory(sundials) +add_subdirectory(ExpressionParser) - if (NOT APPLE) - add_subdirectory(blas) - endif() +add_subdirectory(sundials) - option(OPTION_VCELL "Compile Smoldyn for VCell" ON) - option(OPTION_NSV "Compile Smoldyn with NextSubvolume functionality" OFF) - option(OPTION_USE_OPENGL "Build with OpenGL support" OFF) - option(OPTION_USE_ZLIB "Build with Zlib support" ON) - option(OPTION_USE_LIBTIFF "Build with LibTiff support" OFF) - option(OPTION_USE_ICONV "Build with Libiconv support" OFF) - SET(HAVE_ZLIB TRUE) - set(OPTION_TARGET_LIBSMOLDYN ON) - set(OPTION_VCELL ON) - add_subdirectory(bridgeVCellSmoldyn) - add_subdirectory(smoldyn-2.38) - - add_subdirectory(VCell) - add_subdirectory(PCGPack) - add_subdirectory(qhull) - -include(FetchContent) -FetchContent_Declare( - googletest - URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip -) -if (WINDOWS) - # For Windows: Prevent overriding the parent project's compiler/linker settings - set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +if (NOT APPLE) + add_subdirectory(blas) endif() -FetchContent_MakeAvailable(googletest) -enable_testing() - -get_cmake_property(_variableNames VARIABLES) -list (SORT _variableNames) -foreach (_variableName ${_variableNames}) - message(STATUS "${_variableName}=${${_variableName}}") -endforeach() - -include(CMakePrintHelpers) -cmake_print_variables(OPTION_TARGET_MESSAGING - OPTION_TARGET_DOCS - OPTION_TARGET_FV_SOLVER - OPTION_TARGET_LIBSMOLDYN OPTION_TARGET_VCELL OPTION_TARGET_NSV ) -cmake_print_variables(CMAKE_CXX_FLAGS CMAKE_C_FLAGS CMAKE_Fortran_FLAGS) -cmake_print_variables(CMAKE_SYSTEM_NAME WINDOWS WIN32 MINGW APPLE ARCH_64bit ARCH_32bit) -cmake_print_variables(CMAKE_CPP_COMPILER CMAKE_C_COMPILER CMAKE_CXX_COMPILER CMAKE_Fortran_COMPILER) -cmake_print_variables(HAVE_ZLIB) +SET(HAVE_ZLIB TRUE) +add_subdirectory(bridgeVCellSmoldyn) +add_subdirectory(smoldyn-2.38) + +add_subdirectory(VCell) +add_subdirectory(PCGPack) +add_subdirectory(qhull) + +if (OPTION_TARGET_PYTHON_BINDING) + # Find the module development requirements (requires FindPython from 3.17 or + # scikit-build-core's built-in backport) + find_package(Python REQUIRED COMPONENTS Interpreter Development.Module) + find_package(pybind11 CONFIG REQUIRED) + + # Add a library using FindPython's tooling (pybind11 also provides a helper like this) + python_add_library(_core MODULE src/main.cpp src/SolverMain.cpp src/SolverMain.h WITH_SOABI) + target_link_libraries(_core PRIVATE vcell pybind11::headers) + + # This is passing in the version as a define just as an example + target_compile_definitions(_core PRIVATE VERSION_INFO=${PROJECT_VERSION}) + + # The install directory is the output (wheel) directory + install(TARGETS _core DESTINATION pyvcell_fvsolver) + +else(OPTION_TARGET_PYTHON_BINDING) + + include(FetchContent) + FetchContent_Declare( + googletest + URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip + ) + if (WINDOWS) + # For Windows: Prevent overriding the parent project's compiler/linker settings + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + endif() + FetchContent_MakeAvailable(googletest) + enable_testing() + + get_cmake_property(_variableNames VARIABLES) + list (SORT _variableNames) + foreach (_variableName ${_variableNames}) + message(STATUS "${_variableName}=${${_variableName}}") + endforeach() + + include(CMakePrintHelpers) + cmake_print_variables(OPTION_TARGET_MESSAGING + OPTION_TARGET_DOCS + OPTION_TARGET_FV_SOLVER + OPTION_TARGET_LIBSMOLDYN OPTION_TARGET_VCELL OPTION_TARGET_NSV ) + cmake_print_variables(CMAKE_CXX_FLAGS CMAKE_C_FLAGS CMAKE_Fortran_FLAGS) + cmake_print_variables(CMAKE_SYSTEM_NAME WINDOWS WIN32 MINGW APPLE ARCH_64bit ARCH_32bit) + cmake_print_variables(CMAKE_CPP_COMPILER CMAKE_C_COMPILER CMAKE_CXX_COMPILER CMAKE_Fortran_COMPILER) + cmake_print_variables(HAVE_ZLIB) + +endif (OPTION_TARGET_PYTHON_BINDING) \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index f4a40fe1..04521ae8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ WORKDIR /vcellroot/build RUN cmake \ -G Ninja \ + -DOPTION_TARGET_PYTHON_BINDING=OFF \ -DOPTION_TARGET_MESSAGING=ON \ -DOPTION_TARGET_SMOLDYN_SOLVER=OFF \ -DOPTION_TARGET_FV_SOLVER=ON \ diff --git a/pyvcell-fvsolver/pyproject.toml b/pyproject.toml similarity index 100% rename from pyvcell-fvsolver/pyproject.toml rename to pyproject.toml diff --git a/pyvcell-fvsolver/CMakeLists.txt b/pyvcell-fvsolver/CMakeLists.txt deleted file mode 100644 index 83c05561..00000000 --- a/pyvcell-fvsolver/CMakeLists.txt +++ /dev/null @@ -1,168 +0,0 @@ -cmake_minimum_required(VERSION 3.29) - -project( - ${SKBUILD_PROJECT_NAME} - VERSION ${SKBUILD_PROJECT_VERSION} - LANGUAGES CXX C Fortran) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -if(POLICY CMP0057) - cmake_policy(SET CMP0057 NEW) -endif() - -############################################# -# -# Build 64bit binaries on Mac and target Macos 10.7 or later -# -############################################## -if (APPLE) - execute_process(COMMAND uname -m OUTPUT_VARIABLE PROCESSOR_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE) - message("Processor Architecture: ${PROCESSOR_ARCHITECTURE}") - if (PROCESSOR_ARCHITECTURE STREQUAL "arm64") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__arm64__") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__arm64__") - set(CMAKE_OSX_ARCHITECTURES "arm64") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__x86_64__") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__x86_64__") - set(CMAKE_OSX_ARCHITECTURES "x86_64") - endif() -# set(CMAKE_Fortran_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=10.7" CACHE PATH "") -# set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE PATH "") -############################################# -# -# Choose 32bit or 64bit target arch on Linux -# -############################################## -elseif (LINUX) - option(LINUX_32bit_BINARIES "Build 32bit Linux BINARIES" OFF) - option(LINUX_64bit_BINARIES "Build 64bit Linux BINARIES" ON) - - if (LINUX_32bit_BINARIES AND LINUX_64bit_BINARIES) - message(FATAL_ERROR "It is required to select either 32bit or 64bit Linux Binaries, not both") - endif() - - if (LINUX_32bit_BINARIES) - set (ARCH_64bit FALSE) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") - set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -m32") - endif() - - if (LINUX_64bit_BINARIES) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64") - set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -m64") - endif() -endif() - -if(POLICY CMP0057) - cmake_policy(SET CMP0057 NEW) -endif() - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") - -include(GetGitRevisionDescription) -git_describe(GIT_DESCRIBE ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR) - -include (FindZLIB) - -option(OPTION_TARGET_MESSAGING "Messaging (requires libcurl)" off) -option(OPTION_TARGET_DOCS "Generate Doxygen documentation" off) -option(OPTION_TARGET_FV_SOLVER on) -option(OPTION_TARGET_MESSAGING "Messaging (requires libcurl)" off) - - -if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE STRING "Choose minimum deploy target for Macos machines") -endif() - -set(LINUX FALSE) -if (${CMAKE_SYSTEM_NAME} MATCHES Linux) - set(LINUX TRUE) -endif() - -set(WINDOWS FALSE) -if (${CMAKE_SYSTEM_NAME} MATCHES Windows) - set(WINDOWS TRUE) - set(WIN32 TRUE) - set(MINGW TRUE) -endif() - -set (ARCH_64bit FALSE) -if (CMAKE_SIZEOF_VOID_P EQUAL 8) - set (ARCH_64bit TRUE) -endif() - -if (NOT APPLE AND NOT LINUX AND NOT MINGW) - message(FATAL_ERROR "Unsupported Operating System or C/C++ Compiler.") -endif() - -add_definitions(-DFORTRAN_UNDERSCORE) - -set(OPTION_EXE_DIRECTORY "bin" CACHE PATH "installation directory") -set(OPTION_LIB_DIRECTORY "lib" CACHE PATH "library directory") -set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}") - - -add_definitions(-DUNIX) - -set(HDF5_USE_STATIC_LIBRARIES ON) -if(WINDOWS OR WIN32 OR WIN64) - set(HDF5_USE_STATIC_LIBRARIES OFF) - add_definitions(-DZIP_STATIC) -endif () -#CMakeList.txt that comes with hdf5 switches library name if compiled with debug -find_package(HDF5 COMPONENTS HL CXX C) -set(HDF_VERSION ${HDF5_VERSION}) -###### ${HDF5_HL_LIBRARIES} ${HDF5_CXX_LIBRARIES} - - add_subdirectory(../VCellMessaging bin/VCellMessaging) - - add_subdirectory(../VCellZipUtils bin/VCellZipUtils) - - add_subdirectory(../libzip-1.2.0 bin/libzip-1.2.0) - - add_subdirectory(../ExpressionParser bin/ExpressionParser) - - add_subdirectory(../sundials bin/sundials) - - if (NOT APPLE) - add_subdirectory(../blas bin/blas) - endif() - - option(OPTION_VCELL "Compile Smoldyn for VCell" ON) - option(OPTION_NSV "Compile Smoldyn with NextSubvolume functionality" OFF) - option(OPTION_USE_OPENGL "Build with OpenGL support" OFF) - option(OPTION_USE_ZLIB "Build with Zlib support" ON) - option(OPTION_USE_LIBTIFF "Build with LibTiff support" OFF) - option(OPTION_USE_ICONV "Build with Libiconv support" OFF) - SET(HAVE_ZLIB TRUE) - set(OPTION_TARGET_LIBSMOLDYN ON) - set(OPTION_VCELL ON) - add_subdirectory(../bridgeVCellSmoldyn bin/bridgeVCellSmoldyn) - add_subdirectory(../smoldyn-2.38 bin/smoldyn-2.38) - - add_subdirectory(../VCell bin/VCell) - add_subdirectory(../PCGPack bin/PCGPack) - add_subdirectory(../qhull bin/qhull) - - - -# Find the module development requirements (requires FindPython from 3.17 or -# scikit-build-core's built-in backport) -find_package(Python REQUIRED COMPONENTS Interpreter Development.Module) -find_package(pybind11 CONFIG REQUIRED) - -# Add a library using FindPython's tooling (pybind11 also provides a helper like this) -python_add_library(_core MODULE src/main.cpp src/SolverMain.cpp src/SolverMain.h WITH_SOABI) -target_link_libraries(_core PRIVATE vcell pybind11::headers) - -# This is passing in the version as a define just as an example -target_compile_definitions(_core PRIVATE VERSION_INFO=${PROJECT_VERSION}) - -# The install directory is the output (wheel) directory -install(TARGETS _core DESTINATION pyvcell_fvsolver) \ No newline at end of file diff --git a/pyvcell-fvsolver/README.md b/pyvcell-fvsolver/README.md deleted file mode 100644 index b17fbaa4..00000000 --- a/pyvcell-fvsolver/README.md +++ /dev/null @@ -1 +0,0 @@ -## pyvcell_fvsolver diff --git a/pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake b/pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake deleted file mode 100644 index e48b2067..00000000 --- a/pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake +++ /dev/null @@ -1,284 +0,0 @@ -# - Returns a version string from Git -# -# These functions force a re-configure on each git commit so that you can -# trust the values of the variables in your build system. -# -# get_git_head_revision( [ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR]) -# -# Returns the refspec and sha hash of the current head revision -# -# git_describe( [ ...]) -# -# Returns the results of git describe on the source tree, and adjusting -# the output so that it tests false if an error occurs. -# -# git_describe_working_tree( [ ...]) -# -# Returns the results of git describe on the working tree (--dirty option), -# and adjusting the output so that it tests false if an error occurs. -# -# git_get_exact_tag( [ ...]) -# -# Returns the results of git describe --exact-match on the source tree, -# and adjusting the output so that it tests false if there was no exact -# matching tag. -# -# git_local_changes() -# -# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes. -# Uses the return code of "git diff-index --quiet HEAD --". -# Does not regard untracked files. -# -# Requires CMake 2.6 or newer (uses the 'function' command) -# -# Original Author: -# 2009-2020 Ryan Pavlik -# http://academic.cleardefinition.com -# -# Copyright 2009-2013, Iowa State University. -# Copyright 2013-2020, Ryan Pavlik -# Copyright 2013-2020, Contributors -# SPDX-License-Identifier: BSL-1.0 -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -if(__get_git_revision_description) - return() -endif() -set(__get_git_revision_description YES) - -# We must run the following at "include" time, not at function call time, -# to find the path to this module rather than the path to a calling list file -get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) - -# Function _git_find_closest_git_dir finds the next closest .git directory -# that is part of any directory in the path defined by _start_dir. -# The result is returned in the parent scope variable whose name is passed -# as variable _git_dir_var. If no .git directory can be found, the -# function returns an empty string via _git_dir_var. -# -# Example: Given a path C:/bla/foo/bar and assuming C:/bla/.git exists and -# neither foo nor bar contain a file/directory .git. This wil return -# C:/bla/.git -# -function(_git_find_closest_git_dir _start_dir _git_dir_var) - set(cur_dir "${_start_dir}") - set(git_dir "${_start_dir}/.git") - while(NOT EXISTS "${git_dir}") - # .git dir not found, search parent directories - set(git_previous_parent "${cur_dir}") - get_filename_component(cur_dir "${cur_dir}" DIRECTORY) - if(cur_dir STREQUAL git_previous_parent) - # We have reached the root directory, we are not in git - set(${_git_dir_var} - "" - PARENT_SCOPE) - return() - endif() - set(git_dir "${cur_dir}/.git") - endwhile() - set(${_git_dir_var} - "${git_dir}" - PARENT_SCOPE) -endfunction() - -function(get_git_head_revision _refspecvar _hashvar) - _git_find_closest_git_dir("${CMAKE_CURRENT_SOURCE_DIR}" GIT_DIR) - - if("${ARGN}" STREQUAL "ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR") - set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR TRUE) - else() - set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR FALSE) - endif() - if(NOT "${GIT_DIR}" STREQUAL "") - file(RELATIVE_PATH _relative_to_source_dir "${CMAKE_SOURCE_DIR}" - "${GIT_DIR}") - if("${_relative_to_source_dir}" MATCHES "[.][.]" AND NOT ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR) - # We've gone above the CMake root dir. - set(GIT_DIR "") - endif() - endif() - if("${GIT_DIR}" STREQUAL "") - set(${_refspecvar} - "GITDIR-NOTFOUND" - PARENT_SCOPE) - set(${_hashvar} - "GITDIR-NOTFOUND" - PARENT_SCOPE) - return() - endif() - - # Check if the current source dir is a git submodule or a worktree. - # In both cases .git is a file instead of a directory. - # - if(NOT IS_DIRECTORY ${GIT_DIR}) - # The following git command will return a non empty string that - # points to the super project working tree if the current - # source dir is inside a git submodule. - # Otherwise the command will return an empty string. - # - execute_process( - COMMAND "${GIT_EXECUTABLE}" rev-parse - --show-superproject-working-tree - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - OUTPUT_VARIABLE out - ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT "${out}" STREQUAL "") - # If out is empty, GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a submodule - file(READ ${GIT_DIR} submodule) - string(REGEX REPLACE "gitdir: (.*)$" "\\1" GIT_DIR_RELATIVE - ${submodule}) - string(STRIP ${GIT_DIR_RELATIVE} GIT_DIR_RELATIVE) - get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) - get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} - ABSOLUTE) - set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD") - else() - # GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a worktree - file(READ ${GIT_DIR} worktree_ref) - # The .git directory contains a path to the worktree information directory - # inside the parent git repo of the worktree. - # - string(REGEX REPLACE "gitdir: (.*)$" "\\1" git_worktree_dir - ${worktree_ref}) - string(STRIP ${git_worktree_dir} git_worktree_dir) - _git_find_closest_git_dir("${git_worktree_dir}" GIT_DIR) - set(HEAD_SOURCE_FILE "${git_worktree_dir}/HEAD") - endif() - else() - set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD") - endif() - set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") - if(NOT EXISTS "${GIT_DATA}") - file(MAKE_DIRECTORY "${GIT_DATA}") - endif() - - if(NOT EXISTS "${HEAD_SOURCE_FILE}") - return() - endif() - set(HEAD_FILE "${GIT_DATA}/HEAD") - configure_file("${HEAD_SOURCE_FILE}" "${HEAD_FILE}" COPYONLY) - - configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" - "${GIT_DATA}/grabRef.cmake" @ONLY) - include("${GIT_DATA}/grabRef.cmake") - - set(${_refspecvar} - "${HEAD_REF}" - PARENT_SCOPE) - set(${_hashvar} - "${HEAD_HASH}" - PARENT_SCOPE) -endfunction() - -function(git_describe _var) - if(NOT GIT_FOUND) - find_package(Git QUIET) - endif() - get_git_head_revision(refspec hash) - if(NOT GIT_FOUND) - set(${_var} - "GIT-NOTFOUND" - PARENT_SCOPE) - return() - endif() - if(NOT hash) - set(${_var} - "HEAD-HASH-NOTFOUND" - PARENT_SCOPE) - return() - endif() - - # TODO sanitize - #if((${ARGN}" MATCHES "&&") OR - # (ARGN MATCHES "||") OR - # (ARGN MATCHES "\\;")) - # message("Please report the following error to the project!") - # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") - #endif() - - #message(STATUS "Arguments to execute_process: ${ARGN}") - - execute_process( - COMMAND "${GIT_EXECUTABLE}" describe --tags --always ${hash} ${ARGN} - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - RESULT_VARIABLE res - OUTPUT_VARIABLE out - ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT res EQUAL 0) - set(out "${out}-${res}-NOTFOUND") - endif() - - set(${_var} - "${out}" - PARENT_SCOPE) -endfunction() - -function(git_describe_working_tree _var) - if(NOT GIT_FOUND) - find_package(Git QUIET) - endif() - if(NOT GIT_FOUND) - set(${_var} - "GIT-NOTFOUND" - PARENT_SCOPE) - return() - endif() - - execute_process( - COMMAND "${GIT_EXECUTABLE}" describe --dirty ${ARGN} - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - RESULT_VARIABLE res - OUTPUT_VARIABLE out - ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT res EQUAL 0) - set(out "${out}-${res}-NOTFOUND") - endif() - - set(${_var} - "${out}" - PARENT_SCOPE) -endfunction() - -function(git_get_exact_tag _var) - git_describe(out --exact-match ${ARGN}) - set(${_var} - "${out}" - PARENT_SCOPE) -endfunction() - -function(git_local_changes _var) - if(NOT GIT_FOUND) - find_package(Git QUIET) - endif() - get_git_head_revision(refspec hash) - if(NOT GIT_FOUND) - set(${_var} - "GIT-NOTFOUND" - PARENT_SCOPE) - return() - endif() - if(NOT hash) - set(${_var} - "HEAD-HASH-NOTFOUND" - PARENT_SCOPE) - return() - endif() - - execute_process( - COMMAND "${GIT_EXECUTABLE}" diff-index --quiet HEAD -- - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - RESULT_VARIABLE res - OUTPUT_VARIABLE out - ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if(res EQUAL 0) - set(${_var} - "CLEAN" - PARENT_SCOPE) - else() - set(${_var} - "DIRTY" - PARENT_SCOPE) - endif() -endfunction() diff --git a/pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake.in b/pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake.in deleted file mode 100644 index 27982af5..00000000 --- a/pyvcell-fvsolver/cmake/modules/GetGitRevisionDescription.cmake.in +++ /dev/null @@ -1,45 +0,0 @@ -# -# Internal file for GetGitRevisionDescription.cmake -# -# Requires CMake 2.6 or newer (uses the 'function' command) -# -# Original Author: -# 2009-2010 Ryan Pavlik -# http://academic.cleardefinition.com -# Iowa State University HCI Graduate Program/VRAC -# -# Copyright 2009-2012, Iowa State University -# Copyright 2011-2015, Contributors -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) -# SPDX-License-Identifier: BSL-1.0 - -set(HEAD_HASH) - -file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) - -string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) -if(HEAD_CONTENTS MATCHES "ref") - # named branch - string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") - if(EXISTS "@GIT_DIR@/${HEAD_REF}") - configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) - else() - if(EXISTS "@GIT_DIR@/packed-refs") - configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) - file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) - if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") - set(HEAD_HASH "${CMAKE_MATCH_1}") - endif() - endif() - endif() -else() - # detached HEAD - configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) -endif() - -if(NOT HEAD_HASH) - file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) - string(STRIP "${HEAD_HASH}" HEAD_HASH) -endif() diff --git a/pyvcell-fvsolver/src/SolverMain.cpp b/src/SolverMain.cpp similarity index 100% rename from pyvcell-fvsolver/src/SolverMain.cpp rename to src/SolverMain.cpp diff --git a/pyvcell-fvsolver/src/SolverMain.h b/src/SolverMain.h similarity index 100% rename from pyvcell-fvsolver/src/SolverMain.h rename to src/SolverMain.h diff --git a/pyvcell-fvsolver/src/main.cpp b/src/main.cpp similarity index 100% rename from pyvcell-fvsolver/src/main.cpp rename to src/main.cpp diff --git a/pyvcell-fvsolver/src/pyvcell_fvsolver/__init__.py b/src/pyvcell_fvsolver/__init__.py similarity index 100% rename from pyvcell-fvsolver/src/pyvcell_fvsolver/__init__.py rename to src/pyvcell_fvsolver/__init__.py diff --git a/pyvcell-fvsolver/test/test.py b/test/test.py similarity index 100% rename from pyvcell-fvsolver/test/test.py rename to test/test.py From 640e6babfc28895b9b27a78f4606fae5c22c8888 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sun, 2 Jun 2024 15:12:41 -0400 Subject: [PATCH 15/29] don't test on Docker, install platform deps for wheels --- .github/workflows/wheels.yml | 69 ++++++++++++++++++++++++++++++++++++ Dockerfile | 5 +-- 2 files changed, 72 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 7f1dea9a..897b2508 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -52,6 +52,75 @@ jobs: with: submodules: true + - name: Install Intel MacOS dependencies + if: matrix.platform == 'macos-13' + shell: bash + run: | + brew install boost + brew install hdf5 + brew install ninja + + brew install llvm + echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> /Users/runner/.bash_profile + source /Users/runner/.bash_profile + + gcc --version + gfortran --version + cmake --version + brew info boost + brew info hdf5 + + - name: Install ARM MacOS dependencies + if: matrix.platform == 'macos-14' + shell: bash + run: | + brew install boost + brew install hdf5 + brew install ninja + + brew install llvm + echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> /Users/runner/.bash_profile + ln -s /opt/homebrew/bin/gfortran-14 /usr/local/bin/gfortran + + gcc --version + gfortran --version + cmake --version + brew info boost + brew info hdf5 + + - name: Install Windows Dependencies + if: matrix.platform == 'windows-latest' + uses: msys2/setup-msys2@v2 + with: + msystem: CLANG64 + update: true + install: > + zip + git + mingw-w64-clang-x86_64-curl + mingw-w64-clang-x86_64-toolchain + mingw-w64-clang-x86_64-flang + mingw-w64-clang-x86_64-cmake + mingw-w64-clang-x86_64-boost + mingw-w64-clang-x86_64-hdf5 + mingw-w64-clang-x86_64-libzip + mingw-w64-clang-x86_64-zlib + mingw-w64-clang-x86_64-libaec + + - name: Install Linux Dependencies + if: matrix.platform == 'ubuntu-latest' + run: | + sudo apt-get update + sudo apt-get install -y libboost-all-dev + sudo apt-get install -y libhdf5-dev + sudo apt-get install -y ninja-build + + gcc --version + gfortran --version + cmake --version + dpkg -s libboost-all-dev + dpkg -s libhdf5-dev + - name: build wheel uses: pypa/cibuildwheel@v2.17 env: diff --git a/Dockerfile b/Dockerfile index 04521ae8..ba3116af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,5 +17,6 @@ RUN cmake \ -DOPTION_TARGET_FV_SOLVER=ON \ -DOPTION_TARGET_DOCS=OFF \ .. && \ - ninja && \ - ctest + ninja + +#RUN ctest From a4b29729edc5856cba039c6701b3b002417e1cb6 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sun, 2 Jun 2024 15:15:29 -0400 Subject: [PATCH 16/29] install platform dependencies for pip action --- .github/workflows/pip.yml | 69 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml index 933c4cc1..0cde23e3 100644 --- a/.github/workflows/pip.yml +++ b/.github/workflows/pip.yml @@ -20,6 +20,75 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Install Intel MacOS dependencies + if: matrix.platform == 'macos-13' + shell: bash + run: | + brew install boost + brew install hdf5 + brew install ninja + + brew install llvm + echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> /Users/runner/.bash_profile + source /Users/runner/.bash_profile + + gcc --version + gfortran --version + cmake --version + brew info boost + brew info hdf5 + + - name: Install ARM MacOS dependencies + if: matrix.platform == 'macos-14' + shell: bash + run: | + brew install boost + brew install hdf5 + brew install ninja + + brew install llvm + echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> /Users/runner/.bash_profile + ln -s /opt/homebrew/bin/gfortran-14 /usr/local/bin/gfortran + + gcc --version + gfortran --version + cmake --version + brew info boost + brew info hdf5 + + - name: Install Windows Dependencies + if: matrix.platform == 'windows-latest' + uses: msys2/setup-msys2@v2 + with: + msystem: CLANG64 + update: true + install: > + zip + git + mingw-w64-clang-x86_64-curl + mingw-w64-clang-x86_64-toolchain + mingw-w64-clang-x86_64-flang + mingw-w64-clang-x86_64-cmake + mingw-w64-clang-x86_64-boost + mingw-w64-clang-x86_64-hdf5 + mingw-w64-clang-x86_64-libzip + mingw-w64-clang-x86_64-zlib + mingw-w64-clang-x86_64-libaec + + - name: Install Linux Dependencies + if: matrix.platform == 'ubuntu-latest' + run: | + sudo apt-get update + sudo apt-get install -y libboost-all-dev + sudo apt-get install -y libhdf5-dev + sudo apt-get install -y ninja-build + + gcc --version + gfortran --version + cmake --version + dpkg -s libboost-all-dev + dpkg -s libhdf5-dev + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} From 85ffaee428466ce7c17b87668f5da3446d91e46e Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sun, 2 Jun 2024 15:55:12 -0400 Subject: [PATCH 17/29] fix path to pybind11 --- CMakeLists.txt | 2 +- src/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2eab5166..63e0dcd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.27) +cmake_minimum_required(VERSION 3.22) option(OPTION_TARGET_PYTHON_BINDING "build Python bindings" ON) option(OPTION_TARGET_MESSAGING "Messaging (requires libcurl)" off) option(OPTION_TARGET_DOCS "Generate Doxygen documentation" off) diff --git a/src/main.cpp b/src/main.cpp index 9aa735d3..77073fbc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,4 @@ -#include <../../extern/pybind11/include/pybind11/pybind11.h> +#include #include "SolverMain.h" From c92a29f1e97ddd0d0a63f8e8c7040425c0aea714 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sun, 2 Jun 2024 16:05:17 -0400 Subject: [PATCH 18/29] debug CI/CD matrix --- .github/workflows/pip.yml | 5 +++-- .github/workflows/wheels.yml | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml index 0cde23e3..df42ddff 100644 --- a/.github/workflows/pip.yml +++ b/.github/workflows/pip.yml @@ -14,8 +14,9 @@ jobs: strategy: fail-fast: false matrix: - platform: [windows-latest, macos-13, ubuntu-latest] - python-version: ["3.7", "3.12", "pypy-3.9"] + platform: [windows-latest, macos-13, macos-14, ubuntu-latest] +# python-version: ["3.7", "3.12", "pypy-3.9"] + python-version: ["3.12"] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 897b2508..dc1df309 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -53,7 +53,7 @@ jobs: submodules: true - name: Install Intel MacOS dependencies - if: matrix.platform == 'macos-13' + if: matrix.os == 'macos-13' shell: bash run: | brew install boost @@ -71,7 +71,7 @@ jobs: brew info hdf5 - name: Install ARM MacOS dependencies - if: matrix.platform == 'macos-14' + if: matrix.os == 'macos-14' shell: bash run: | brew install boost @@ -89,7 +89,7 @@ jobs: brew info hdf5 - name: Install Windows Dependencies - if: matrix.platform == 'windows-latest' + if: matrix.os == 'windows-latest' uses: msys2/setup-msys2@v2 with: msystem: CLANG64 @@ -108,7 +108,7 @@ jobs: mingw-w64-clang-x86_64-libaec - name: Install Linux Dependencies - if: matrix.platform == 'ubuntu-latest' + if: matrix.os == 'ubuntu-latest' run: | sudo apt-get update sudo apt-get install -y libboost-all-dev From de5e537e4b34e93fbfaefea7ef9b955c515fd06d Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sun, 2 Jun 2024 16:28:58 -0400 Subject: [PATCH 19/29] install pytest for pip action --- .github/workflows/pip.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml index df42ddff..2610bab6 100644 --- a/.github/workflows/pip.yml +++ b/.github/workflows/pip.yml @@ -98,4 +98,6 @@ jobs: run: pip install --verbose . - name: Test - run: pytest + run: | + pip install pytest + pytest From 6f54c3b7be14ca8c290831c697f38287d136ee97 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sun, 2 Jun 2024 16:44:29 -0400 Subject: [PATCH 20/29] fix pytest --- test/test.py | 15 --------------- tests/test_basic.py | 7 +++++++ 2 files changed, 7 insertions(+), 15 deletions(-) delete mode 100644 test/test.py create mode 100644 tests/test_basic.py diff --git a/test/test.py b/test/test.py deleted file mode 100644 index b5c7c977..00000000 --- a/test/test.py +++ /dev/null @@ -1,15 +0,0 @@ -from __future__ import annotations - -import pyvcell_fvsolver as fv - - -def test_version(): - assert fv.__version__ == "0.0.1" - - -def test_add(): - assert fv.add(1, 2) == 3 - - -def test_sub(): - assert fv.subtract(1, 2) == -1 diff --git a/tests/test_basic.py b/tests/test_basic.py new file mode 100644 index 00000000..1077a16e --- /dev/null +++ b/tests/test_basic.py @@ -0,0 +1,7 @@ +import pyvcell_fvsolver as fv + +def test_version(): + assert fv.__version__ == "0.0.1" + +def test_version(): + assert fv.version() is not None From f593bb4b4ea395b4ace5d71a48b673189f03b0be Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sun, 2 Jun 2024 18:27:05 -0400 Subject: [PATCH 21/29] enforce mingw LLVM toolchain for pip build on windows --- .github/workflows/pip.yml | 9 ++++++- CMakeLists.txt | 51 +++++++++++++++++++++++---------------- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml index 2610bab6..2157fa10 100644 --- a/.github/workflows/pip.yml +++ b/.github/workflows/pip.yml @@ -92,10 +92,17 @@ jobs: - uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} + python-version: "${{ matrix.python-version }}" - name: Build and install run: pip install --verbose . + if: matrix.platform == 'windows-latest' + env: + PATH: "/c/Program Files/LLVM/bin:${{ env.PATH }}" + + - name: Build and install + run: pip install --verbose . + if: matrix.platform != 'windows-latest' - name: Test run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 63e0dcd3..c1a5117e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,12 +36,35 @@ endif () set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + set(OPTION_USE_OPENGL OFF CACHE BOOL "") if(POLICY CMP0057) cmake_policy(SET CMP0057 NEW) endif() +set(LINUX FALSE) +if (${CMAKE_SYSTEM_NAME} MATCHES Linux) + set(LINUX TRUE) +endif() + +set(WINDOWS FALSE) +if (${CMAKE_SYSTEM_NAME} MATCHES Windows) + set(WINDOWS TRUE) + set(WIN32 TRUE) + set(MINGW TRUE) +endif() + +set (ARCH_64bit FALSE) +if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set (ARCH_64bit TRUE) +endif() + +if (NOT APPLE AND NOT LINUX AND NOT MINGW) + message(FATAL_ERROR "Unsupported Operating System or C/C++ Compiler.") +endif() + if (APPLE) execute_process(COMMAND uname -m OUTPUT_VARIABLE PROCESSOR_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE) message("Processor Architecture: ${PROCESSOR_ARCHITECTURE}") @@ -74,6 +97,13 @@ elseif (LINUX) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64") set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -m64") endif() +elseif (MINGW) + if(NOT DEFINED CMAKE_C_COMPILER) + set(CMAKE_C_COMPILER "clang.exe") + endif() + if(NOT DEFINED CMAKE_CXX_COMPILER) + set(CMAKE_CXX_COMPILER "clang++.exe") + endif() endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") @@ -105,27 +135,6 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE STRING "Choose minimum deploy target for Macos machines") endif() -set(LINUX FALSE) -if (${CMAKE_SYSTEM_NAME} MATCHES Linux) - set(LINUX TRUE) -endif() - -set(WINDOWS FALSE) -if (${CMAKE_SYSTEM_NAME} MATCHES Windows) - set(WINDOWS TRUE) - set(WIN32 TRUE) - set(MINGW TRUE) -endif() - -set (ARCH_64bit FALSE) -if (CMAKE_SIZEOF_VOID_P EQUAL 8) - set (ARCH_64bit TRUE) -endif() - -if (NOT APPLE AND NOT LINUX AND NOT MINGW) - message(FATAL_ERROR "Unsupported Operating System or C/C++ Compiler.") -endif() - add_definitions(-DFORTRAN_UNDERSCORE) ############################################# From 8a6605578c7c4d69de3d040873cd692c146d1d8a Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sun, 2 Jun 2024 20:37:10 -0400 Subject: [PATCH 22/29] update platform LLVM paths for pip and wheel actions --- .github/workflows/pip.yml | 31 ++++++++++++++++++++++++++++--- .github/workflows/wheels.yml | 15 +++++++++++++-- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml index 2157fa10..0d1b3d54 100644 --- a/.github/workflows/pip.yml +++ b/.github/workflows/pip.yml @@ -38,6 +38,10 @@ jobs: cmake --version brew info boost brew info hdf5 + + echo "CC=/usr/local/opt/llvm/bin/clang" >> $GITHUB_ENV + echo "CXX=/usr/local/opt/llvm/bin/clang++" >> $GITHUB_ENV + - name: Install ARM MacOS dependencies if: matrix.platform == 'macos-14' @@ -56,6 +60,10 @@ jobs: cmake --version brew info boost brew info hdf5 + + echo "CC=/opt/homebrew/opt/llvm/bin/clang" >> $GITHUB_ENV + echo "CXX=/opt/homebrew/opt/llvm/bin/clang++" >> $GITHUB_ENV + - name: Install Windows Dependencies if: matrix.platform == 'windows-latest' @@ -75,6 +83,11 @@ jobs: mingw-w64-clang-x86_64-libzip mingw-w64-clang-x86_64-zlib mingw-w64-clang-x86_64-libaec + - if: matrix.os == 'windows-latest' + run: | + echo "CC=/c/Program Files/LLVM/bin/clang.exe" >> $GITHUB_ENV + echo "CXX=/c/Program Files/LLVM/bin/clang++.exe" >> $GITHUB_ENV + - name: Install Linux Dependencies if: matrix.platform == 'ubuntu-latest' @@ -94,15 +107,27 @@ jobs: with: python-version: "${{ matrix.python-version }}" - - name: Build and install + - name: Build and install macos-13 + run: pip install --verbose . + if: matrix.platform == 'macos-13' + env: + PATH: "/usr/local/opt/llvm/bin:${{ env.PATH }}" + + - name: Build and install macos-14 + run: pip install --verbose . + if: matrix.platform == 'macos-14' + env: + PATH: "/opt/homebrew/opt/llvm/bin:${{ env.PATH }}" + + - name: Build and install windows-latest run: pip install --verbose . if: matrix.platform == 'windows-latest' env: PATH: "/c/Program Files/LLVM/bin:${{ env.PATH }}" - - name: Build and install + - name: Build and install ubuntu-latest run: pip install --verbose . - if: matrix.platform != 'windows-latest' + if: matrix.platform == 'ubuntu-latest' - name: Test run: | diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index dc1df309..b7fc26bf 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -69,6 +69,10 @@ jobs: cmake --version brew info boost brew info hdf5 + + echo "CC=/usr/local/opt/llvm/bin/clang" >> $GITHUB_ENV + echo "CXX=/usr/local/opt/llvm/bin/clang++" >> $GITHUB_ENV + - name: Install ARM MacOS dependencies if: matrix.os == 'macos-14' @@ -87,6 +91,9 @@ jobs: cmake --version brew info boost brew info hdf5 + + echo "CC=/opt/homebrew/opt/llvm/bin/clang" >> $GITHUB_ENV + echo "CXX=/opt/homebrew/opt/llvm/bin/clang++" >> $GITHUB_ENV - name: Install Windows Dependencies if: matrix.os == 'windows-latest' @@ -106,6 +113,11 @@ jobs: mingw-w64-clang-x86_64-libzip mingw-w64-clang-x86_64-zlib mingw-w64-clang-x86_64-libaec + - if: matrix.os == 'windows-latest' + run: | + echo "CC=/c/Program Files/LLVM/bin/clang.exe" >> $GITHUB_ENV + echo "CXX=/c/Program Files/LLVM/bin/clang++.exe" >> $GITHUB_ENV + - name: Install Linux Dependencies if: matrix.os == 'ubuntu-latest' @@ -124,8 +136,7 @@ jobs: - name: build wheel uses: pypa/cibuildwheel@v2.17 env: - CIBW_ARCHS_MACOS: universal2 - CIBW_ARCHS_WINDOWS: auto ARM64 + CIBW_ARCHS: native - name: Verify clean directory run: git diff --exit-code From a7dd35d86a333464daea5a7e18700c2d95c9ff66 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sun, 2 Jun 2024 22:58:45 -0400 Subject: [PATCH 23/29] WIP: pip and wheels config --- .github/workflows/pip.yml | 35 +++++++++++++++-------------------- .github/workflows/wheels.yml | 11 +---------- CMakeLists.txt | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml index 0d1b3d54..186a9985 100644 --- a/.github/workflows/pip.yml +++ b/.github/workflows/pip.yml @@ -38,9 +38,6 @@ jobs: cmake --version brew info boost brew info hdf5 - - echo "CC=/usr/local/opt/llvm/bin/clang" >> $GITHUB_ENV - echo "CXX=/usr/local/opt/llvm/bin/clang++" >> $GITHUB_ENV - name: Install ARM MacOS dependencies @@ -60,9 +57,6 @@ jobs: cmake --version brew info boost brew info hdf5 - - echo "CC=/opt/homebrew/opt/llvm/bin/clang" >> $GITHUB_ENV - echo "CXX=/opt/homebrew/opt/llvm/bin/clang++" >> $GITHUB_ENV - name: Install Windows Dependencies @@ -83,10 +77,6 @@ jobs: mingw-w64-clang-x86_64-libzip mingw-w64-clang-x86_64-zlib mingw-w64-clang-x86_64-libaec - - if: matrix.os == 'windows-latest' - run: | - echo "CC=/c/Program Files/LLVM/bin/clang.exe" >> $GITHUB_ENV - echo "CXX=/c/Program Files/LLVM/bin/clang++.exe" >> $GITHUB_ENV - name: Install Linux Dependencies @@ -103,30 +93,35 @@ jobs: dpkg -s libboost-all-dev dpkg -s libhdf5-dev + - uses: actions/setup-python@v5 with: python-version: "${{ matrix.python-version }}" - name: Build and install macos-13 - run: pip install --verbose . + run: | + PATH="/usr/local/opt/llvm/bin:$PATH" + pip install --verbose . if: matrix.platform == 'macos-13' - env: - PATH: "/usr/local/opt/llvm/bin:${{ env.PATH }}" - name: Build and install macos-14 - run: pip install --verbose . + run: | + PATH="/opt/homebrew/opt/llvm/bin:$PATH" + pip install --verbose . if: matrix.platform == 'macos-14' - env: - PATH: "/opt/homebrew/opt/llvm/bin:${{ env.PATH }}" - name: Build and install windows-latest - run: pip install --verbose . + shell: msys2 {0} + run: | + platform=windows + PATH="/c/Program Files/LLVM/bin:$PATH" + pip install --verbose . if: matrix.platform == 'windows-latest' - env: - PATH: "/c/Program Files/LLVM/bin:${{ env.PATH }}" - name: Build and install ubuntu-latest - run: pip install --verbose . + run: | + platform=linux + pip install --verbose . if: matrix.platform == 'ubuntu-latest' - name: Test diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index b7fc26bf..985437db 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -69,9 +69,6 @@ jobs: cmake --version brew info boost brew info hdf5 - - echo "CC=/usr/local/opt/llvm/bin/clang" >> $GITHUB_ENV - echo "CXX=/usr/local/opt/llvm/bin/clang++" >> $GITHUB_ENV - name: Install ARM MacOS dependencies @@ -91,9 +88,6 @@ jobs: cmake --version brew info boost brew info hdf5 - - echo "CC=/opt/homebrew/opt/llvm/bin/clang" >> $GITHUB_ENV - echo "CXX=/opt/homebrew/opt/llvm/bin/clang++" >> $GITHUB_ENV - name: Install Windows Dependencies if: matrix.os == 'windows-latest' @@ -113,10 +107,6 @@ jobs: mingw-w64-clang-x86_64-libzip mingw-w64-clang-x86_64-zlib mingw-w64-clang-x86_64-libaec - - if: matrix.os == 'windows-latest' - run: | - echo "CC=/c/Program Files/LLVM/bin/clang.exe" >> $GITHUB_ENV - echo "CXX=/c/Program Files/LLVM/bin/clang++.exe" >> $GITHUB_ENV - name: Install Linux Dependencies @@ -133,6 +123,7 @@ jobs: dpkg -s libboost-all-dev dpkg -s libhdf5-dev + - name: build wheel uses: pypa/cibuildwheel@v2.17 env: diff --git a/CMakeLists.txt b/CMakeLists.txt index c1a5117e..00d02ecb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,13 @@ if (APPLE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__x86_64__") set(CMAKE_OSX_ARCHITECTURES "x86_64") endif() + if(NOT DEFINED CMAKE_C_COMPILER) + set(CMAKE_C_COMPILER "clang") + endif() + if(NOT DEFINED CMAKE_CXX_COMPILER) + set(CMAKE_CXX_COMPILER "clang++") + endif() + elseif (LINUX) option(LINUX_32bit_BINARIES "Build 32bit Linux BINARIES" OFF) option(LINUX_64bit_BINARIES "Build 64bit Linux BINARIES" ON) @@ -97,6 +104,13 @@ elseif (LINUX) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64") set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -m64") endif() + if(NOT DEFINED CMAKE_C_COMPILER) + set(CMAKE_C_COMPILER "clang") + endif() + if(NOT DEFINED CMAKE_CXX_COMPILER) + set(CMAKE_CXX_COMPILER "clang++") + endif() + elseif (MINGW) if(NOT DEFINED CMAKE_C_COMPILER) set(CMAKE_C_COMPILER "clang.exe") @@ -104,6 +118,7 @@ elseif (MINGW) if(NOT DEFINED CMAKE_CXX_COMPILER) set(CMAKE_CXX_COMPILER "clang++.exe") endif() + endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") From bb2acd578cb59db0152e928e9e60d86ba8db5a00 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Sun, 2 Jun 2024 23:39:55 -0400 Subject: [PATCH 24/29] debug with tmate --- .github/workflows/pip.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml index 186a9985..f3d72d49 100644 --- a/.github/workflows/pip.yml +++ b/.github/workflows/pip.yml @@ -128,3 +128,7 @@ jobs: run: | pip install pytest pytest + + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: ${{ failure() }} From 8a9bd46649c22f471270fa5e63e6978784492bd7 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Mon, 3 Jun 2024 08:04:52 -0400 Subject: [PATCH 25/29] try dynamic binding for hdf5 for python/linux --- .github/workflows/pip.yml | 5 ++--- CMakeLists.txt | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml index f3d72d49..49c2450d 100644 --- a/.github/workflows/pip.yml +++ b/.github/workflows/pip.yml @@ -77,6 +77,7 @@ jobs: mingw-w64-clang-x86_64-libzip mingw-w64-clang-x86_64-zlib mingw-w64-clang-x86_64-libaec + mingw-w64-clang-x86_64-python-pip-tools - name: Install Linux Dependencies @@ -113,9 +114,7 @@ jobs: - name: Build and install windows-latest shell: msys2 {0} run: | - platform=windows - PATH="/c/Program Files/LLVM/bin:$PATH" - pip install --verbose . + pip install --verbose -Ccmake.define.CMAKE_C_COMPILER="clang.exe" -Ccmake.define.CMAKE_CXX_COMPILER="clang++.exe" . if: matrix.platform == 'windows-latest' - name: Build and install ubuntu-latest diff --git a/CMakeLists.txt b/CMakeLists.txt index 00d02ecb..2e8b5b68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,6 +179,10 @@ if(WINDOWS OR WIN32 OR WIN64) set(HDF5_USE_STATIC_LIBRARIES OFF) add_definitions(-DZIP_STATIC) endif () +if (LINUX AND OPTION_TARGET_PYTHON_BINDING) + set(HDF5_USE_STATIC_LIBRARIES OFF) +endif() + #CMakeList.txt that comes with hdf5 switches library name if compiled with debug find_package(HDF5 COMPONENTS HL CXX C) set(HDF_VERSION ${HDF5_VERSION}) From 0191ae12cd07c20ee6cc68ae860bec3611b1e4f3 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Mon, 3 Jun 2024 09:26:03 -0400 Subject: [PATCH 26/29] fix windows type conflicts in SolverMain --- src/SolverMain.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/SolverMain.cpp b/src/SolverMain.cpp index 5e5b1527..1b8308e3 100644 --- a/src/SolverMain.cpp +++ b/src/SolverMain.cpp @@ -1,6 +1,11 @@ // // Created by Jim Schaff on 6/1/24. // +#if (defined(WIN32) || defined(WIN64) ) +#define _HAS_STD_BYTE 0 +#include +#endif + #include "SolverMain.h" #include From 08fc3de5e12e99aa9811ea34e6d5873f668c7467 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Mon, 3 Jun 2024 09:35:05 -0400 Subject: [PATCH 27/29] fix windows pip test with correct shell --- .github/workflows/pip.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml index 49c2450d..e2064801 100644 --- a/.github/workflows/pip.yml +++ b/.github/workflows/pip.yml @@ -123,10 +123,18 @@ jobs: pip install --verbose . if: matrix.platform == 'ubuntu-latest' - - name: Test + - name: Test not windows run: | pip install pytest pytest + if: matrix.platform != 'windows-latest' + + - name: Test on windows + shell: msys2 {0} + run: | + pip install pytest + pytest + if: matrix.platform == 'windows-latest' - name: Setup tmate session uses: mxschmitt/action-tmate@v3 From ffe7fd0187244d87283ab3530e8a9d0388723ba2 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Mon, 3 Jun 2024 09:55:44 -0400 Subject: [PATCH 28/29] don't trigger conda/wheel actions automatically and add tmate debug --- .github/workflows/conda.yml | 14 ++++++++++---- .github/workflows/enscripten.yaml | 6 +++--- .github/workflows/pip.yml | 2 ++ .github/workflows/wheels.yml | 26 +++++++++++++++++++------- 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/.github/workflows/conda.yml b/.github/workflows/conda.yml index cd3643f9..ee9343dd 100644 --- a/.github/workflows/conda.yml +++ b/.github/workflows/conda.yml @@ -2,10 +2,10 @@ name: Conda on: workflow_dispatch: - push: - branches: - - master - pull_request: +# push: +# branches: +# - master +# pull_request: jobs: build: @@ -42,3 +42,9 @@ jobs: - name: Test run: pytest tests + + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: ${{ failure() }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/enscripten.yaml b/.github/workflows/enscripten.yaml index 7a5de098..5e20ff7f 100644 --- a/.github/workflows/enscripten.yaml +++ b/.github/workflows/enscripten.yaml @@ -2,9 +2,9 @@ name: WASM on: workflow_dispatch: - pull_request: - branches: - - master +# pull_request: +# branches: +# - master concurrency: group: "${{ github.workflow }}-${{ github.ref }}" diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml index e2064801..ebca15d7 100644 --- a/.github/workflows/pip.yml +++ b/.github/workflows/pip.yml @@ -139,3 +139,5 @@ jobs: - name: Setup tmate session uses: mxschmitt/action-tmate@v3 if: ${{ failure() }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 985437db..327dcb70 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -2,13 +2,13 @@ name: Wheels on: workflow_dispatch: - pull_request: - push: - branches: - - master - release: - types: - - published +# pull_request: +# push: +# branches: +# - master +# release: +# types: +# - published env: FORCE_COLOR: 3 @@ -138,6 +138,12 @@ jobs: name: cibw-wheels-${{ matrix.os }} path: wheelhouse/*.whl + - name: Setup tmate session on build failure + uses: mxschmitt/action-tmate@v3 + if: ${{ failure() }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + upload_all: name: Upload if release @@ -160,3 +166,9 @@ jobs: path: dist - uses: pypa/gh-action-pypi-publish@release/v1 + + - name: Setup tmate session on upload failure + uses: mxschmitt/action-tmate@v3 + if: ${{ failure() }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} From 2a3160ad2cc262d558f14a6614ce53003f46f742 Mon Sep 17 00:00:00 2001 From: jcschaff Date: Mon, 3 Jun 2024 10:15:37 -0400 Subject: [PATCH 29/29] updated README.md --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 49dfec8d..337cf1b1 100644 --- a/README.md +++ b/README.md @@ -14,4 +14,17 @@ Virtual Cell solvers [virtualcell/vcell-solvers](https://github.com/virtualcell/ ## The Virtual Cell Project The Virtual Cell is a modeling and simulation framework for computational biology. For details see http://vcell.org and http://github.com/virtualcell. -## Python Bindings (more to come) +## Docker container +the vcell-fvsolver is available as a docker container at ghcr.io/virtualcell/vcell-fvsolver. + +## Standalone executables +FiniteVolume executable can be build on Windows, MacOS, and Linux (see .github/workflows/cd.yml for details). The executables are available in the release section of this repository. + +## Python API - pyvcell_fvsolver +The Python API for the VCell Finite Volume solver is a low level wrapper which +accepts VCell solver input files (.fvinput, .vcg) +and generates the output files (.log, .zip, .mesh, .meshmetrics, .hdf5). The +.functions file is not used by the solver, but is helpful for interpreting the +results in the context of the original model. + +This package is intented to be used by the Virtual Cell Python API, pyvcell (coming soon).