Skip to content

Commit

Permalink
separate scikit-build-core build using 'pip install ./pyvcell_fvsolver'
Browse files Browse the repository at this point in the history
  • Loading branch information
jcschaff committed Jun 2, 2024
1 parent ce3ed83 commit 5d191f6
Show file tree
Hide file tree
Showing 17 changed files with 708 additions and 39 deletions.
24 changes: 9 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -244,9 +241,6 @@ endif()
add_subdirectory(PCGPack)
add_subdirectory(qhull)

add_subdirectory(extern/pybind11)
add_subdirectory(pyvcell-fvsolver)

include(FetchContent)
FetchContent_Declare(
googletest
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
41 changes: 41 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -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",
)
169 changes: 158 additions & 11 deletions pyvcell-fvsolver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions pyvcell-fvsolver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## pyvcell_fvsolver
Loading

0 comments on commit 5d191f6

Please sign in to comment.