Skip to content

Commit 45195d0

Browse files
committed
Change installation of fenics-basix using pip with compiled C++ version directly from repo
1 parent 3969fd8 commit 45195d0

3 files changed

Lines changed: 22 additions & 31 deletions

File tree

CMakeLists.txt

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ if(UNIX AND NOT APPLE)
2727
ninja-build
2828
git
2929
libopenmpi-dev
30+
libblas-dev
31+
liblapack-dev
3032
screen
3133
nano
3234
RESULT_VARIABLE APT_RESULT
@@ -96,28 +98,26 @@ endif()
9698
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
9799
find_package(pybind11 CONFIG REQUIRED)
98100

99-
# --- Basix: use the basix that is installed in this Python env (fenics-basix wheel) ---
100-
execute_process(
101-
COMMAND "${Python_EXECUTABLE}" -c
102-
"import basix, os; print(os.path.join(os.path.dirname(basix.__file__), 'lib'))"
103-
OUTPUT_VARIABLE BASIX_PY_LIBDIR
104-
OUTPUT_STRIP_TRAILING_WHITESPACE
105-
RESULT_VARIABLE _basix_rc
106-
)
107-
if(NOT _basix_rc EQUAL 0)
108-
message(FATAL_ERROR
109-
"Basix not importable in this Python env. Install: python -m pip install fenics-basix")
110-
endif()
101+
# ------------------------------------------------------------
102+
# FEniCS Basix (C++) automatic compilation via FetchContent
103+
# ------------------------------------------------------------
104+
find_package(BLAS REQUIRED)
105+
find_package(LAPACK REQUIRED)
111106

112-
find_library(BASIX_LIB
113-
NAMES basix
114-
PATHS "${BASIX_PY_LIBDIR}"
115-
NO_DEFAULT_PATH
116-
REQUIRED
107+
include(FetchContent)
108+
FetchContent_Declare(
109+
basix
110+
GIT_REPOSITORY https://github.com/FEniCS/basix.git
111+
GIT_TAG v0.10.0 # Matches the >=0.10.0 requirement in your pyproject.toml
112+
SOURCE_SUBDIR cpp # Tells CMake to look for CMakeLists.txt inside the cpp/ folder
117113
)
118114

119-
message(STATUS "Basix wheel libdir: ${BASIX_PY_LIBDIR}")
120-
message(STATUS "Basix wheel lib: ${BASIX_LIB}")
115+
FetchContent_GetProperties(basix)
116+
if(NOT basix_POPULATED)
117+
message(STATUS "Fetching and building FEniCS Basix C++ library from GitHub...")
118+
FetchContent_Populate(basix)
119+
add_subdirectory(${basix_SOURCE_DIR}/cpp ${basix_BINARY_DIR})
120+
endif()
121121

122122
# ------------------------------------------------------------
123123
# Eigen3 automatic installation (cached and robust)
@@ -168,7 +168,7 @@ foreach(mod ${MODULES})
168168
${Python_INCLUDE_DIRS}
169169
)
170170

171-
target_link_libraries(${mod} PRIVATE "${BASIX_LIB}")
171+
target_link_libraries(${mod} PRIVATE basix)
172172

173173
# Apply high-performance compile flags
174174
target_compile_options(${mod} PRIVATE
@@ -207,4 +207,4 @@ message(STATUS " Pybind11 includes: ${pybind11_INCLUDE_DIRS}")
207207
message(STATUS " Eigen include dir: ${EIGEN_INCLUDE_DIR}")
208208
message(STATUS " Eigen unsupported: ${EIGEN_UNSUPPORTED_DIR}")
209209
message(STATUS " LTO enabled: ${CMAKE_INTERPROCEDURAL_OPTIMIZATION}")
210-
message(STATUS "------------------------------------------------------------")
210+
message(STATUS "------------------------------------------------------------")

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[build-system]
22
requires = ["scikit-build-core>=0.10",
3-
"fenics-basix>=0.10.0",
43
"pybind11",
54
"numpy",
65
"setuptools",
@@ -26,7 +25,6 @@ dependencies = [
2625
"scikit-image",
2726
"pint",
2827
"pymetis",
29-
"fenics-basix>=0.10.0",
3028
"pynufft",
3129
]
3230
keywords = ["MRI", "finite-element", "simulation", "pybind11", "C++"]

python/feelmri/__init__.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,4 @@
33
try:
44
__version__ = version("feelmri")
55
except PackageNotFoundError:
6-
__version__ = "0.0.0"
7-
8-
# Ensure basix (and its bundled libbasix) is loaded before feelmri extensions
9-
try:
10-
import basix # noqa: F401
11-
except Exception:
12-
# If basix isn't installed, leave the error to the caller when they import features needing it
13-
pass
6+
__version__ = "0.0.0"

0 commit comments

Comments
 (0)