Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/build_test_serial.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ jobs:
compiler-install: 'gcc-10 g++-10 gfortran-10'
hdf5-install: 'libhdf5-dev'
hdf5-restart-support: TRUE
python-version: '3.10'
numpy-version: '1.26'
- os: 'ubuntu-22.04'
compiler-type: 'GNU'
compiler-version: '11'
Expand All @@ -196,6 +198,8 @@ jobs:
compiler-install: 'gcc-11 g++-11 gfortran-11'
hdf5-install: 'libhdf5-dev'
hdf5-restart-support: TRUE
python-version: '3.11'
numpy-version: '1.26'
- os: 'ubuntu-24.04'
compiler-type: 'GNU'
compiler-version: '12'
Expand All @@ -205,6 +209,8 @@ jobs:
compiler-install: 'gcc-12 g++-12 gfortran-12'
hdf5-install: ''
hdf5-restart-support: FALSE
python-version: '3.12'
numpy-version: '2.0'
- os: 'ubuntu-24.04'
compiler-type: 'GNU'
compiler-version: '13'
Expand All @@ -214,6 +220,8 @@ jobs:
compiler-install: 'gcc-13 g++-13 gfortran-13'
hdf5-install: ''
hdf5-restart-support: FALSE
python-version: '3.12'
numpy-version: '2.1'
- os: 'ubuntu-24.04'
compiler-type: 'GNU'
compiler-version: '14'
Expand All @@ -223,6 +231,8 @@ jobs:
compiler-install: 'gcc-14 g++-14 gfortran-14'
hdf5-install: ''
hdf5-restart-support: FALSE
python-version: '3.13'
numpy-version: '2.2'
- os: 'ubuntu-24.04'
compiler-type: 'CLANG'
compiler-version: '17'
Expand All @@ -232,6 +242,8 @@ jobs:
compiler-install: 'clang-17 gfortran'
hdf5-install: ''
hdf5-restart-support: FALSE
python-version: '3.11'
numpy-version: '1.26'
- os: 'ubuntu-24.04'
compiler-type: 'CLANG'
compiler-version: '18'
Expand All @@ -241,6 +253,8 @@ jobs:
compiler-install: 'clang-18 gfortran'
hdf5-install: ''
hdf5-restart-support: FALSE
python-version: '3.12'
numpy-version: '2.0'
- os: 'ubuntu-24.04'
compiler-type: 'LLVM'
compiler-version: '20'
Expand Down Expand Up @@ -286,6 +300,8 @@ jobs:
compiler-install: 'gcc-14 g++-14 gfortran-14'
hdf5-install: ''
hdf5-restart-support: FALSE
python-version: '3.13'
numpy-version: '2.2'
- os: 'ubuntu-24.04-arm'
compiler-type: 'CLANG'
compiler-version: '18'
Expand All @@ -295,6 +311,8 @@ jobs:
compiler-install: 'clang-18 gfortran'
hdf5-install: ''
hdf5-restart-support: FALSE
python-version: '3.12'
numpy-version: '2.0'
- os: 'macos-14'
compiler-type: 'GNU'
compiler-version: '15'
Expand All @@ -304,6 +322,8 @@ jobs:
compiler-install: 'gcc@15'
hdf5-install: 'hdf5'
hdf5-restart-support: TRUE
python-version: '3.12'
numpy-version: '2.0'
- os: 'macos-14'
compiler-type: 'CLANG'
compiler-version: '20'
Expand All @@ -314,6 +334,8 @@ jobs:
compiler-install: 'llvm@20 gcc@15'
hdf5-install: 'hdf5'
hdf5-restart-support: TRUE
python-version: '3.12'
numpy-version: '2.1'
- os: 'macos-15'
compiler-type: 'GNU'
compiler-version: '15'
Expand All @@ -323,6 +345,8 @@ jobs:
compiler-install: 'gcc@15'
hdf5-install: 'hdf5'
hdf5-restart-support: TRUE
python-version: '3.13'
numpy-version: '2.2'
- os: 'macos-15'
compiler-type: 'CLANG'
compiler-version: '20'
Expand All @@ -333,6 +357,8 @@ jobs:
compiler-install: 'llvm@20 gcc@15'
hdf5-install: 'hdf5'
hdf5-restart-support: TRUE
python-version: '3.13'
numpy-version: '2.2'
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} - Serial - CMake - ${{ matrix.compiler-type }} - ${{ matrix.compiler-version }}
steps:
Expand Down Expand Up @@ -495,6 +521,33 @@ jobs:
cd build
cmake --build . --parallel 2 --verbose
cmake --install .
- name: 'Set up Python for pyquick'
if: matrix.python-version
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: 'Install numpy for pyquick build'
if: matrix.python-version
run: |
python3 -m pip install "numpy==${{ matrix.numpy-version }}.*" meson ninja
- name: 'Build and install pyquick Python extension'
if: matrix.python-version
run: |
if [ ${{ matrix.compiler-type }} == 'INTELLLVM' ]; then
source /opt/intel/oneapi/setvars.sh
fi
cd build
cmake .. -DPYTHON=TRUE
cmake --build . --parallel 2 --target pyquick
cmake --install .
- name: 'Run pyquick test'
if: matrix.python-version
run: |
export PYTHONPATH=$PWD/install/lib${PYTHONPATH:+:$PYTHONPATH}
if [ "$RUNNER_OS" == "macOS" ]; then
export DYLD_LIBRARY_PATH=$PWD/install/lib${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}
fi
python3 test/pyquick_ene_H2O_rhf_sto3g.py
- name: 'Run Tests for Serial Version'
run: |
if [ ${{ matrix.compiler-type }} == 'INTELLLVM' ]; then
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ if(HDF5)
endif()

option(ENABLEF "Enables the support for f functions in the ERI code." FALSE)
option(PYTHON "Build the pyquick Python extension via f2py (requires numpy)." FALSE)

# Compiler flags
# These should really go into cmake/CompilerFlags.cmake but with the
Expand Down
2 changes: 2 additions & 0 deletions quick-cmake/quick.rc
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ export QUICK_BASIS="$QUICK_INSTALL/basis"
export PATH="$QUICK_INSTALL/bin":$PATH
export LIBRARY_PATH="$QUICK_INSTALL/lib":$LIBRARY_PATH
export LD_LIBRARY_PATH="$QUICK_INSTALL/lib":$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH="$QUICK_INSTALL/lib":$DYLD_LIBRARY_PATH
export PYTHONPATH="$QUICK_INSTALL/lib":$PYTHONPATH
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,7 @@ if(CUDA AND MPI)
install(TARGETS quick.${QUICK_GPU_TARGET_NAME}.MPI DESTINATION ${BINDIR} EXPORT QUICK)
install(TARGETS test-api.${QUICK_GPU_TARGET_NAME}.MPI DESTINATION ${BINDIR} EXPORT QUICK)
endif()

if(PYTHON)
add_subdirectory(pyquick)
endif()
105 changes: 105 additions & 0 deletions src/pyquick/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Build the pyquick Python extension via f2py.
# Enabled with -DPYTHON=TRUE at the cmake configure step.

# ---------------------------------------------------------------------------
# 1. Locate the Python interpreter.
#
# Honour an explicit -DPython3_EXECUTABLE=... hint if provided.
# Otherwise resolve "python3" from PATH so that conda/virtualenv
# environments are found before any system Python.
# ---------------------------------------------------------------------------
if(NOT Python3_EXECUTABLE)
find_program(Python3_EXECUTABLE
NAMES python3 python
DOC "Python interpreter used to run f2py"
NO_CMAKE_SYSTEM_PATH # skip CMake's built-in system search first
)
if(NOT Python3_EXECUTABLE)
find_program(Python3_EXECUTABLE NAMES python3 python
DOC "Python interpreter used to run f2py")
endif()
endif()

if(NOT Python3_EXECUTABLE)
message(FATAL_ERROR
"Python interpreter not found. Set -DPython3_EXECUTABLE=/path/to/python3 "
"or activate the correct conda/virtualenv environment before running cmake.")
endif()

message(STATUS "pyquick: using Python interpreter: ${Python3_EXECUTABLE}")

# ---------------------------------------------------------------------------
# 2. Verify numpy and f2py are available via the located interpreter
# ---------------------------------------------------------------------------
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "import numpy"
RESULT_VARIABLE _numpy_result
OUTPUT_QUIET ERROR_QUIET)
if(NOT _numpy_result EQUAL 0)
message(FATAL_ERROR
"numpy not importable by ${Python3_EXECUTABLE}. "
"Install numpy or reconfigure without -DPYTHON=TRUE.")
endif()

execute_process(
COMMAND ${Python3_EXECUTABLE} -m numpy.f2py -h
RESULT_VARIABLE _f2py_result
OUTPUT_QUIET
ERROR_QUIET)
if(NOT _f2py_result EQUAL 0)
message(FATAL_ERROR
"f2py not found (numpy.f2py unavailable for ${Python3_EXECUTABLE}). "
"Install numpy to build the Python extension, or reconfigure without -DPYTHON=TRUE.")
endif()

# ---------------------------------------------------------------------------
# 3. Compute the platform-specific extension suffix
# e.g. .cpython-313-x86_64-linux-gnu.so
# ---------------------------------------------------------------------------
execute_process(
COMMAND ${Python3_EXECUTABLE} -c
"import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'), end='')"
OUTPUT_VARIABLE PYTHON_EXT_SUFFIX)

set(_PYQUICK_SO "${CMAKE_CURRENT_BINARY_DIR}/_pyquick${PYTHON_EXT_SUFFIX}")

# ---------------------------------------------------------------------------
# 4. Build the .so via f2py as a custom command
#
# Include path: build-tree .mod files for the serial libquick target.
# The directory is ${CMAKE_BINARY_DIR}/amber-modules/quick/serial, which
# is set by config_module_dirs(libquick quick/serial ...) in src/CMakeLists.txt
# and is fully populated after libquick has been compiled (DEPENDS libquick).
#
# Link path: resolved at build time via $<TARGET_FILE_DIR:libquick>, so
# -L always points to the actual location of libquick.so regardless of
# CMAKE_INSTALL_PREFIX.
# ---------------------------------------------------------------------------
add_custom_command(
OUTPUT "${_PYQUICK_SO}"
COMMAND ${Python3_EXECUTABLE} -m numpy.f2py
-c "${CMAKE_SOURCE_DIR}/src/pyquick/pyquick.f90"
"-I${CMAKE_BINARY_DIR}/amber-modules/quick/serial"
"-L$<TARGET_FILE_DIR:libquick>"
-lquick
-m _pyquick
DEPENDS libquick "${CMAKE_SOURCE_DIR}/src/pyquick/pyquick.f90"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMENT "Building _pyquick Python extension via f2py"
VERBATIM)

# ---------------------------------------------------------------------------
# 5. Named target included in the default ALL build
# ---------------------------------------------------------------------------
add_custom_target(pyquick ALL DEPENDS "${_PYQUICK_SO}")

# ---------------------------------------------------------------------------
# 6. Install rules
# Both the compiled extension and the Python package glue go into
# <prefix>/lib/pyquick/ so that after "source quick.rc" (which prepends
# <prefix>/lib to PYTHONPATH) the package is importable as "import pyquick".
# ---------------------------------------------------------------------------
install(FILES "${_PYQUICK_SO}"
DESTINATION lib/pyquick)
install(FILES "${CMAKE_SOURCE_DIR}/src/pyquick/__init__.py"
DESTINATION lib/pyquick)
Loading
Loading