Skip to content

Commit 86c377b

Browse files
committed
python
1 parent 22e8d69 commit 86c377b

File tree

4 files changed

+37
-11
lines changed

4 files changed

+37
-11
lines changed

CMakeLists.txt

+8-4
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,14 @@ message(STATUS "Building using CMake ${CMAKE_VERSION} Generator ${CMAKE_GENERATO
9898
### compiler-only
9999

100100
### library-only
101+
option_with_default(LIBINT2_ENABLE_PYTHON
102+
"Build Python bindings (requires Python and Pybind11 and Eigen3)" OFF)
103+
option_with_default(LIBINT2_PREFIX_PYTHON_INSTALL
104+
"For LIBINT2_ENABLE_PYTHON=ON, whether to install the Python module in the Linux manner to CMAKE_INSTALL_PREFIX or to not install it. See target libint2-python-wheel for alternate installation in the Python manner to Python_EXECUTABLE's site-packages." OFF)
105+
101106
option_with_print(LIBINT2_ENABLE_MPFR
102107
"Use GNU MPFR library for high-precision testing (EXPERTS ONLY). Consumed at library build-time." OFF)
103-
option_with_print(LIBINT2_LOCAL_Eigen3_INSTALL
104-
"Install an exported target with hard-coded Eigen3 dependency paths. This is potentially useful and important when consuming the compiled C++11 interface library so that the Libint library build and Libint consumer build use the same Eigen3 installation & ABI. This is at most a convenience when consuming the header-only C++11 interface library. See `LIBINT2_LOCAL_Eigen3_FIND`. Consumed at library build-time." OFF)
108+
## next one defined by `include(CTest)`
105109

106110
# <<< Which Integrals Classes, Which Derivative Levels >>>
107111

@@ -275,7 +279,7 @@ endif()
275279

276280
check_include_file_cxx(stdint.h HAVE_STDINT_H) # limits.h?
277281

278-
if(cxx_std_11 IN_LIST CMAKE_CXX_COMPILE_FEATURES)
282+
if (cxx_std_11 IN_LIST CMAKE_CXX_COMPILE_FEATURES)
279283
set(LIBINT_HAS_CXX11 1)
280284
endif()
281285

@@ -296,7 +300,7 @@ booleanize01(LIBINT_PROFILE)
296300

297301
# See notes at https://github.com/evaleev/libint/blob/master/INSTALL.md#prerequisites
298302

299-
if(LIBINT2_ENABLE_MPFR)
303+
if (LIBINT2_ENABLE_MPFR)
300304
# mpfr detected at appropriate time for library (CMakeLists.txt.export), but prechecking here
301305
find_package(Multiprecision MODULE REQUIRED COMPONENTS gmpxx mpfr)
302306
set(LIBINT_HAS_MPFR 1)

INSTALL.md

+5
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,16 @@ Note that options, docs, and CMake components are focused on the C++ interface,
238238
239239
* `LIBINT2_ENABLE_MPFR` — L — Use MPFR library to test Libint integrals in high precision (requires MPFR; experts only). [Default=OFF]
240240
* `LIBINT2_LOCAL_Eigen3_INSTALL` — L — Install an exported target with hard-coded Eigen3 dependency paths. This is potentially useful and important when consuming the compiled C++11 interface library so that the Libint library build and Libint consumer build use the same Eigen3 installation & ABI. This is at most a convenience when consuming the header-only C++11 interface library. See `LIBINT2_LOCAL_Eigen3_FIND`. [Default=OFF]
241+
* `LIBINT2_ENABLE_PYTHON` — L — Build Python bindings (requires Python and Eigen3; Boost and pybind11 recommended; [see prereq line](#prerequisites)). Can instead be enabled and built through separate CMake configuration after library build. [Default=OFF]
241242
242243
243244
### Build Library How (G L) (TARBALL)
244245
245246
246247
### Detecting Dependencies (G L C) (TARBALL)
247248
249+
* `Python_EXECUTABLE` — L — Path to Python interpreter.
250+
* `CMAKE_PREFIX_PATH` — G L — Set to list of root directories to look for external dependencies. [Standard CMake variable](https://cmake.org/cmake/help/latest/variable/CMAKE_PREFIX_PATH.html)
248251
* `BOOST_ROOT` — G L C — Prefix to installation location (`BOOST_ROOT/include/boost/` exists)
249252
* `Boost_DIR` - G L C - Path to installation location of Boost's config file (`Boost_DIR/BoostConfig.cmake` exists)
250253
* `CMAKE_DISABLE_FIND_PACKAGE_Boost` — L — When Boost required for C++11 Libint API, disable its detection, thereby forcing use of bundled Boost. Note that this (and other Boost-hinting variables) can affect what is installed [see here](#packagers). [Standard CMake variable](https://cmake.org/cmake/help/latest/variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName.html). [Default=OFF]
@@ -288,6 +291,7 @@ Note that options, docs, and CMake components are focused on the C++ interface,
288291
289292
### Install Paths (L) (TARBALL)
290293
294+
* `LIBINT2_PREFIX_PYTHON_INSTALL` — L — For `LIBINT2_ENABLE_PYTHON=ON`, whether to install the Python module in the Linux manner to `CMAKE_INSTALL_PREFIX` or to not install it. Note: not a path; the installation sub-path below `CMAKE_INSTALL_PREFIX` is determined by querying `Python_EXECUTABLE`. For alternate installation in the Python manner to `Python_EXECUTABLE`'s site-packages, see target libint2-python-wheel. [Default=OFF]
291295
292296
293297
### Miscellaneous (G L)
@@ -382,6 +386,7 @@ Note that options, docs, and CMake components are focused on the C++ interface,
382386
383387
* `ENV(CPPFLAGS)=-I/path/to/boost/includes` --> `-D BOOST_ROOT=/path/to/boost/prefix`
384388
389+
* `-D LIBINT2_PYTHON=ON` --> `-D LIBINT2_ENABLE_PYTHON=ON`
385390
* `-D LIBINT_USE_BUNDLED_BOOST=ON` --> `-D CMAKE_DISABLE_FIND_PACKAGE_Boost=ON` (standard CMake variable)
386391
* `--with-boost` & `--with-boost-libdir` --> see `BOOST_ROOT` & `Boost_DIR`
387392
* `-D LIBINT_LOCAL_Eigen3_INSTALL` --> `-D LIBINT2_LOCAL_Eigen3_INSTALL`

src/lib/libint/CMakeLists.txt

+9-7
Original file line numberDiff line numberDiff line change
@@ -50,26 +50,28 @@ add_custom_target(libint-library-export DEPENDS "${EXPORT_STAGE_DIR}.tgz")
5050
-DLIBINT2_ALIGN_SIZE=${LIBINT_ALIGN_SIZE}
5151
-DLIBINT2_REALTYPE=${LIBINT2_REALTYPE}
5252
-DLIBINT2_ENABLE_MPFR=${LIBINT2_ENABLE_MPFR}
53+
-DLIBINT2_ENABLE_PYTHON=${LIBINT2_ENABLE_PYTHON}
54+
-DLIBINT2_PREFIX_PYTHON_INSTALL=${LIBINT2_PREFIX_PYTHON_INSTALL}
5355
)
54-
if(Multiprecision_ROOT)
56+
if (Multiprecision_ROOT)
5557
list(APPEND library_CMAKE_ARGS "-DMultiprecision_ROOT=${Multiprecision_ROOT}")
5658
endif()
57-
if(Boost_DIR)
59+
if (Boost_DIR)
5860
list(APPEND library_CMAKE_ARGS "-DBoost_DIR=${Boost_DIR}")
5961
endif()
60-
if(BOOST_ROOT)
62+
if (BOOST_ROOT)
6163
list(APPEND library_CMAKE_ARGS "-DBOOST_ROOT=${BOOST_ROOT}")
6264
endif()
63-
if(CMAKE_DISABLE_FIND_PACKAGE_Boost)
65+
if (CMAKE_DISABLE_FIND_PACKAGE_Boost)
6466
list(APPEND library_CMAKE_ARGS "-DCMAKE_DISABLE_FIND_PACKAGE_Boost=${CMAKE_DISABLE_FIND_PACKAGE_Boost}")
6567
endif()
66-
if(Eigen3_DIR)
68+
if (Eigen3_DIR)
6769
list(APPEND library_CMAKE_ARGS "-DEigen3_DIR=${Eigen3_DIR}")
6870
endif()
69-
if(Eigen3_ROOT)
71+
if (Eigen3_ROOT)
7072
list(APPEND library_CMAKE_ARGS "-DEigen3_ROOT=${Eigen3_ROOT}")
7173
endif()
72-
if(LIBINT2_LOCAL_Eigen3_INSTALL)
74+
if (LIBINT2_LOCAL_Eigen3_INSTALL)
7375
list(APPEND library_CMAKE_ARGS "-DLIBINT2_LOCAL_Eigen3_INSTALL=${LIBINT2_LOCAL_Eigen3_INSTALL}")
7476
endif()
7577

src/lib/libint/CMakeLists.txt.export

+15
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ include(CheckFunctionExists)
3636

3737
option_with_print(LIBINT2_ENABLE_MPFR
3838
"Use GNU MPFR library for high-precision testing (requires MPFR. EXPERTS ONLY)" OFF)
39+
option_with_print(LIBINT2_ENABLE_PYTHON
40+
"Build Python bindings (requires Python and Pybind11 and Eigen3)" OFF)
41+
option_with_print(LIBINT2_PREFIX_PYTHON_INSTALL
42+
"For LIBINT2_ENABLE_PYTHON=ON, whether to install the Python module in the Linux manner to CMAKE_INSTALL_PREFIX or to not install it. See target libint2-python-wheel for alternate installation in the Python manner to Python_EXECUTABLE's site-packages." OFF)
3943
option_with_print(LIBINT2_LOCAL_Eigen3_INSTALL
4044
"Install an exported target with hard-coded Eigen3 dependency paths. This is potentially useful and important when consuming the compiled C++11 interface library so that the Libint library build and Libint consumer build use the same Eigen3 installation & ABI. This is at most a convenience when consuming the header-only C++11 interface library. In consumer build, set `LIBINT2_LOCAL_Eigen3_FIND=ON` before `find_package(Libint2) to load the exported Eigen3." OFF)
4145
option_with_print(CMAKE_DISABLE_FIND_PACKAGE_Boost
@@ -119,6 +123,17 @@ if (NOT LIBINT_HAS_EIGEN) # TODO tmp wrong logic
119123
message(FATAL_ERROR "C++ API cannot be built without Eigen3; configure (via CMake) and install Eigen3 and add the install prefix to CMAKE_PREFIX_PATH, or add -DLIBINT2_REQUIRE_CXX_API=OFF to the CMake command line if the C++ API is not required")
120124
endif()
121125

126+
# Python is optionally used for testing.
127+
# * But for Fortran, it's additionally required for preprocessing.
128+
# * And for Python bindings, it's required along with its headers.
129+
if (LIBINT2_ENABLE_PYTHON)
130+
find_package(Python COMPONENTS Interpreter Development REQUIRED)
131+
elseif (LIBINT2_ENABLE_FORTRAN)
132+
find_package(Python COMPONENTS Interpreter REQUIRED)
133+
else()
134+
find_package(Python COMPONENTS Interpreter)
135+
endif()
136+
122137

123138
################################# Main Project #################################
124139
include(CMakePackageConfigHelpers)

0 commit comments

Comments
 (0)