Skip to content

Commit

Permalink
Merge branch 'henryiii/chore/scikit-build-core' of https://github.com…
Browse files Browse the repository at this point in the history
…/henryiii/flare into henryiii-henryiii/chore/scikit-build-core
  • Loading branch information
jonpvandermause committed Sep 16, 2024
2 parents 4f4a285 + c64bc96 commit 87c8dd0
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 276 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: C++ tests

on: [push, pull_request]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
strategy:
matrix:
omp: [OFF, ON]
lapack: [OFF, ON]
name: "(OpenMP, Lapack) ="

# The type of runner that the job will run on
runs-on: ubuntu-latest

env:
BUILD_DIR: build_${{ matrix.omp }}_${{ matrix.lapack }}
CC: gcc-9
CXX: g++-9

steps:
- uses: actions/checkout@v2

- name: Build and run C++ tests
run: |
sudo apt install liblapacke liblapacke-dev
mkdir ${BUILD_DIR}
cd ${BUILD_DIR}
if [ "${{ matrix.omp }}" = "ON" ]; then
unset NO_OMP
else
export NO_OMP=1
fi
if [ "${{ matrix.lapack }}" = "ON" ]; then
unset NO_LAPACK
else
export NO_LAPACK=1
fi
echo "OpenMP ${{ matrix.omp }}"
echo "Lapack ${{ matrix.lapack }}"
cmake .. -DNO_PYTHON=ON
cmake --build . -j4
cd ctests
./tests
14 changes: 1 addition & 13 deletions .github/workflows/flare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@

name: flare

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on: [push, pull_request]


# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
Expand Down Expand Up @@ -60,8 +56,6 @@ jobs:
cmake ..
cmake --build . -j4
cp _C_flare* ../flare/bffs/sgp
cd ctests
./tests
- name: Install LAMMPS
run: |
Expand Down Expand Up @@ -92,8 +86,7 @@ jobs:
- name: Pip install
run: |
pip install -U codecov pytest pytest-cov pytest_mock Sphinx sphinx-rtd-theme breathe nbsphinx
pip install -r requirements.txt
pip install -v -C cmake.define.CMAKE_PREFIX_PATH=$CONDA_PREFIX .[docs,tests]
- name: Patch ASE
run: |
Expand Down Expand Up @@ -124,11 +117,6 @@ jobs:
python tutorial.py
rm Al* aluminum.txt aspirin.txt md17_aspirin.npz tutorial.ipynb tutorial.py
- name: Install Sphinx and Breathe
run: |
sudo apt-get update
sudo apt-get install python3-sphinx python3-sphinx-rtd-theme python3-breathe python3-nbsphinx
- name: Run Doxygen
uses: mattnotmitt/[email protected]
with:
Expand Down
103 changes: 41 additions & 62 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14.5)
cmake_minimum_required(VERSION 3.18...3.26)

set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
Expand All @@ -15,8 +15,6 @@ set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_OSX_ARCHITECTURES "x86_64")

set(FLARE_PYTHON_VERSION "" CACHE STRING "Python version to use for compiling modules")

if(NOT CMAKE_BUILD_TYPE)
message(STATUS "[flare] CMAKE_BUILD_TYPE not specified, setting it to "
"Release. Use `-DCMAKE_BUILD_TYPE=...` to overwrite.")
Expand All @@ -32,13 +30,15 @@ include(FetchContent)
# googletest
################################################################################

FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.11.0
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/External/googletest
UPDATE_COMMAND ""
)
FetchContent_MakeAvailable(googletest)
if(NOT DEFINED SKBUILD)
FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.11.0
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/External/googletest
UPDATE_COMMAND ""
)
FetchContent_MakeAvailable(googletest)
endif()

# Json
################################################################################
Expand All @@ -53,19 +53,6 @@ FetchContent_Populate(json)
add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR})
include_directories(${json_SOURCE_DIR})

# Kokkos
################################################################################

#FetchContent_Declare(kokkos
# GIT_REPOSITORY https://github.com/kokkos/kokkos
# SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/External/kokkos
# UPDATE_COMMAND ""
#)
#FetchContent_GetProperties(kokkos)
#FetchContent_Populate(kokkos)
#add_subdirectory(${kokkos_SOURCE_DIR} ${kokkos_BINARY_DIR})
#include_directories(${Kokkos_SOURCE_DIR})


# Eigen3
################################################################################
Expand All @@ -84,15 +71,6 @@ add_library(Eigen3 INTERFACE)
target_include_directories(Eigen3 SYSTEM INTERFACE ${SOURCE_DIR})
include_directories(${SOURCE_DIR})

# pybind11
###############################################################################
set(PYBIND11_FINDPYTHON ON)
FetchContent_Declare(
pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11
GIT_TAG v2.13.0
)
FetchContent_MakeAvailable(pybind11)
###############################################################################

# Specify source files.
Expand Down Expand Up @@ -140,37 +118,24 @@ add_dependencies(flare eigen_project)
# Link to json.
target_link_libraries(flare PUBLIC nlohmann_json::nlohmann_json)

# Add conda include directories
if (DEFINED ENV{CONDA_PREFIX})
message(STATUS "Adding conda include directories.")
include_directories($ENV{CONDA_PREFIX}/include)
endif()

# Link to OpenMP.
if (DEFINED ENV{OMP_LOC})
target_link_libraries(flare PUBLIC $ENV{OMP_LOC})
message(STATUS "Linking to user-specified OpenMP library.")
elseif(DEFINED ENV{NO_OMP})
message(STATUS "Building without OpenMP.")
else()
if(NOT DEFINED ENV{NO_OMP})
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
target_link_libraries(flare PUBLIC OpenMP::OpenMP_CXX)
endif()
endif()

# Check for user-specified MKL package.
if (DEFINED ENV{MKL_INCLUDE} AND DEFINED ENV{MKL_LIBS})
message(STATUS "Linking Eigen to user-specified MKL libraries.")
include_directories($ENV{MKL_INCLUDE})
target_link_libraries(flare PUBLIC $ENV{MKL_LIBS})
target_compile_definitions(flare PUBLIC EIGEN_USE_MKL_ALL=1)
# Give the option to do a "bare-bones" build without Lapack/Lapacke.
elseif(DEFINED ENV{NO_LAPACK})
message(STATUS "Building without Lapack.")
else()
# Add conda include directories TODO: MKL issue if not
if(DEFINED ENV{CONDA_PREFIX})
message(STATUS "Adding conda include directories.")
include_directories($ENV{CONDA_PREFIX}/include)
endif()


if(NOT DEFINED ENV{NO_LAPACK})
find_package(LAPACK REQUIRED)
target_link_libraries(flare PUBLIC ${LAPACK_LIBRARIES})
target_link_libraries(flare PUBLIC LAPACK::LAPACK)

if (LAPACK_LIBRARIES MATCHES mkl)
message(STATUS "Linking Eigen to MKL.")
Expand All @@ -179,16 +144,30 @@ else()
find_package(LAPACKE)
if(LAPACKE_FOUND)
target_link_libraries(flare PUBLIC ${LAPACKE_LIBRARIES})
message(STATUS "Linking Eigen to LAPACKE.")
target_compile_definitions(flare PUBLIC EIGEN_USE_LAPACKE=1)
endif()
message(STATUS "Linking Eigen to LAPACKE.")
target_compile_definitions(flare PUBLIC EIGEN_USE_LAPACKE=1)
endif()
endif()

# Create pybind module.
pybind11_add_module(flare_module ${PYBIND_SOURCES})
target_link_libraries(flare_module PUBLIC flare)
set_target_properties(flare_module PROPERTIES OUTPUT_NAME "_C_flare")
option(NO_PYTHON "Do not build Python module." OFF)
if(NOT NO_PYTHON)
set(PYBIND11_NEWPYTHON ON)
FetchContent_Declare(pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11
)
FetchContent_MakeAvailable(pybind11)
#find_package(pybind11 CONFIG REQUIRED)

# Greatly reduces the code bloat
# target_compile_options(pybind11 INTERFACE "-fvisibility=hidden")
pybind11_add_module(flare_module ${PYBIND_SOURCES})
target_link_libraries(flare_module PUBLIC flare)
set_target_properties(flare_module PROPERTIES OUTPUT_NAME "_C_flare")
install(TARGETS flare_module LIBRARY DESTINATION flare/bffs/sgp)
endif()

# Add test directory.
add_subdirectory(ctests)
if(NOT DEFINED SKBUILD)
add_subdirectory(ctests)
endif()
5 changes: 0 additions & 5 deletions MANIFEST.in

This file was deleted.

59 changes: 59 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[build-system]
requires = ["scikit-build-core", "pybind11"]
build-backend = "scikit_build_core.build"

[project]
name = "mir-flare"
version = "1.4.0"
description = "Fast Learning of Atomistic Rare Events"
readme = "README.md"
requires-python = ">=3.7"
authors = [
{ name = "Materials Intelligence Research", email = "[email protected]" },
]
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Scientific/Engineering :: Physics",
]
dependencies = [
"ase",
"nptyping",
"numba",
"numpy >=1.18, <1.23",
"pyyaml",
"scipy",
"wandb",
]

[project.scripts]
flare-otf = "flare.scripts.otf_train:main"

[project.urls]
Homepage = "https://github.com/mir-group/flare"

[project.optional-dependencies]
tests = [
"pytest-mock",
"pytest>=4.6",
"IPython",
]
dev = [
"jupyter",
"memory_profiler",
]
docs = [
"babel",
"docutils==0.17.1",
"nbconvert",
"nbsphinx",
"pygments==2.11.2",
"codecov",
"Sphinx",
"sphinx-rtd-theme",
"breathe"
]

[tool.scikit-build]
wheel.packages = ["flare"]
Loading

0 comments on commit 87c8dd0

Please sign in to comment.