-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmake build #157
Merged
Merged
cmake build #157
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
5ee897c
add cmake build
kleinhenz 77cda35
update targets to match config module
kleinhenz 369c2d2
wip allow setuptools to drive cmake build
kleinhenz 49e0e39
provide edrixs executables as part of python package installation
kleinhenz bc13801
print CMAKE_COMMAND
kleinhenz 018f802
properly set module filename to include abi info
kleinhenz 5fb9d72
add pyproject.toml to specify required build environment
kleinhenz b15ba58
remove unnecessary cmake code
kleinhenz 4faec47
set CMAKE_BUILD_TYPE to RelWithDebInfo if not specified
kleinhenz f5b8c0d
allow passing args to cmake configure via CMAKE_CONFIGURE_ARGS env var
kleinhenz 1cbab54
update install instruction in README
kleinhenz 809ce87
remove unused makefiles
kleinhenz 232d939
delete pdfs from examples directory
kleinhenz de2046b
update dockerfile
kleinhenz ad7f35f
make flake8 happy
kleinhenz b4f0c8a
update install-deps.sh script for new build system
kleinhenz 27b8252
allow python 3.7
kleinhenz f23207d
update installation.rst
kleinhenz 6af7daf
Merge branch 'master' into develop
mpmdean ab91da5
update ubuntu version
mpmdean 57b3e35
CI: add steps to upload GHA artifacts
mrakitin 36ea6a8
MNT: move wheels generation step to the beginning
mrakitin 5d1699b
Comment-out wheels building step for now
mrakitin b1e0b56
make wheel with pip
mpmdean 6be197e
remove pin of setuptools version
mpmdean 4f74e93
CI: add diagnostic checks and update CI env with repo name
mrakitin c99eb1e
CI: put wheels into a separate dir
mrakitin 982ac1e
CI: back to `python setup.py bdist_wheel`
mrakitin 464e1e7
PKG: fix warnings from CI logs
mrakitin 3c6463f
CI: add pkg name to the wheels artifact
mrakitin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
.git/ | ||
docker/ | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,14 @@ name: CI-Test | |
on: [push, pull_request] | ||
|
||
jobs: | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
- uses: pre-commit/[email protected] | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v4 | ||
- uses: pre-commit/[email protected] | ||
|
||
test: | ||
name: Tests | ||
runs-on: ${{ matrix.host-os }} | ||
|
@@ -19,23 +21,37 @@ jobs: | |
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] | ||
fail-fast: false | ||
steps: | ||
- name: Set env.REPOSITORY_NAME # just the repo, as opposed to org/repo | ||
run: | | ||
export REPOSITORY_NAME=${GITHUB_REPOSITORY#*/} | ||
echo "REPOSITORY_NAME=${REPOSITORY_NAME}" >> $GITHUB_ENV | ||
|
||
- name: Checkout the code | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
set -vxeuo pipefail | ||
bash ./scripts/install-deps.sh | ||
ls -Al . | ||
ls -Al ./dist/ | ||
tree . | ||
|
||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ env.REPOSITORY_NAME }}-wheels | ||
path: dist/*.whl | ||
|
||
- name: Test with pytest | ||
run: | | ||
set -vxeuo pipefail | ||
bash ./scripts/run-tests.sh | ||
|
||
docs: | ||
name: Documentation | ||
runs-on: ubuntu-latest | ||
|
@@ -46,11 +62,16 @@ jobs: | |
fail-fast: false | ||
|
||
steps: | ||
- name: Set env.REPOSITORY_NAME # just the repo, as opposed to org/repo | ||
run: | | ||
export REPOSITORY_NAME=${GITHUB_REPOSITORY#*/} | ||
echo "REPOSITORY_NAME=${REPOSITORY_NAME}" >> $GITHUB_ENV | ||
|
||
- name: Checkout the code | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
|
@@ -63,3 +84,8 @@ jobs: | |
run: | | ||
set -vxeuo pipefail | ||
bash ./scripts/build-docs.sh | ||
|
||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ env.REPOSITORY_NAME }}-docs | ||
path: docs/build/html/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,7 @@ target/ | |
#pycharm | ||
.idea/* | ||
|
||
.vscode/* | ||
|
||
#Ipython Notebook | ||
.ipynb_checkpoints |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
cmake_minimum_required(VERSION 3.17.3 FATAL_ERROR) # 3.17 > for Python3_SOABI | ||
|
||
project (EDRIXS C Fortran) | ||
|
||
if (NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build type configuration" FORCE) | ||
message(STATUS "Setting default build type: ${CMAKE_BUILD_TYPE}") | ||
endif() | ||
|
||
message(STATUS "CMAKE_COMMAND: ${CMAKE_COMMAND}") | ||
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") | ||
|
||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
|
||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) | ||
|
||
find_package(MPI REQUIRED) | ||
|
||
find_package(LAPACK REQUIRED) | ||
|
||
option(EDRIXS_PYINTERFACE "Build python interface" OFF) | ||
|
||
# see https://gitlab.kitware.com/cmake/cmake/-/issues/21779 | ||
if (CMAKE_VERSION VERSION_LESS 3.20) | ||
if(LAPACK_FOUND) | ||
set(_lapack_libs "${LAPACK_LIBRARIES}") | ||
if(_lapack_libs AND TARGET BLAS::BLAS) | ||
# remove the ${BLAS_LIBRARIES} from the interface and replace it | ||
# with the BLAS::BLAS target | ||
list(REMOVE_ITEM _lapack_libs "${BLAS_LIBRARIES}") | ||
list(APPEND _lapack_libs BLAS::BLAS) | ||
endif() | ||
if(_lapack_libs) | ||
set_target_properties(LAPACK::LAPACK PROPERTIES | ||
INTERFACE_LINK_LIBRARIES "${_lapack_libs}" | ||
) | ||
endif() | ||
unset(_lapack_libs) | ||
endif() | ||
endif() | ||
|
||
# use a custom find module because arpack-ng config module doesn't provide full paths to libs | ||
# see https://github.com/opencollab/arpack-ng/pull/311 | ||
find_package(arpack MODULE REQUIRED COMPONENTS serial parallel) | ||
|
||
|
||
if (EDRIXS_PY_INTERFACE) | ||
message(STATUS "Building python interface") | ||
find_package(Python3 3.7 REQUIRED COMPONENTS Interpreter Development NumPy) | ||
|
||
# Grab the variables from a local Python installation | ||
# F2PY headers | ||
execute_process( | ||
COMMAND "${Python3_EXECUTABLE}" | ||
-c "import numpy.f2py; print(numpy.f2py.get_include())" | ||
OUTPUT_VARIABLE F2PY_INCLUDE_DIR | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
message(STATUS "Python3_INCLUDE_DIRS: ${Python3_INCLUDE_DIRS}") | ||
message(STATUS "F2PY_INCLUDE_DIR: ${F2PY_INCLUDE_DIR}") | ||
message(STATUS "Python3_NumPy_INCLUDE_DIRS: ${Python3_NumPy_INCLUDE_DIRS}") | ||
endif() | ||
|
||
add_subdirectory(src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
include(FindPackageHandleStandardArgs) | ||
|
||
message(STATUS "Finding arpack") | ||
|
||
# if components not specified default to serial library | ||
set(_supported_components serial parallel) | ||
if(NOT arpack_FIND_COMPONENTS) | ||
set(arpack_FIND_COMPONENTS serial) | ||
endif() | ||
|
||
# check request components | ||
foreach(_component ${arpack_FIND_COMPONENTS}) | ||
if (NOT ${_component} IN_LIST _supported_components) | ||
message(FATAL_ERROR "${_component} is not a valid component (serial,parallel)") | ||
endif() | ||
endforeach() | ||
|
||
message(STATUS "${arpack_FIND_COMPONENTS}") | ||
|
||
if(DEFINED ENV{ARPACK_ROOT}) | ||
set(ARPACK_ROOT "$ENV{ARPACK_ROOT}") | ||
endif() | ||
|
||
set(arpack_serial_FOUND FALSE) | ||
set(arpack_parallel_FOUND FALSE) | ||
set(arpack_LIBRARIES "") | ||
|
||
if ("serial" IN_LIST arpack_FIND_COMPONENTS) | ||
find_library(ARPACK_LIBRARY NAMES arpack HINTS ${ARPACK_ROOT}) | ||
if(ARPACK_LIBRARY) | ||
set(arpack_serial_FOUND TRUE) | ||
message(STATUS "ARPACK_LIBRARY: ${ARPACK_LIBRARY}") | ||
add_library(ARPACK::ARPACK INTERFACE IMPORTED) | ||
set_target_properties(ARPACK::ARPACK PROPERTIES INTERFACE_LINK_LIBRARIES "${ARPACK_LIBRARY}") | ||
list(APPEND arpack_LIBRARIES ${ARPACK_LIBRARY}) | ||
endif() | ||
endif() | ||
|
||
if ("parallel" IN_LIST arpack_FIND_COMPONENTS) | ||
find_library(PARPACK_LIBRARY NAMES parpack HINTS ${ARPACK_ROOT}) | ||
if(PARPACK_LIBRARY) | ||
set(arpack_parallel_FOUND TRUE) | ||
message(STATUS "PARPACK_LIBRARY: ${PARPACK_LIBRARY}") | ||
add_library(PARPACK::PARPACK INTERFACE IMPORTED) | ||
set_target_properties(PARPACK::PARPACK PROPERTIES INTERFACE_LINK_LIBRARIES "${PARPACK_LIBRARY}") | ||
list(APPEND arpack_LIBRARIES ${PARPACK_LIBRARY}) | ||
endif() | ||
endif() | ||
|
||
find_package_handle_standard_args(arpack REQUIRED_VARS "arpack_LIBRARIES" HANDLE_COMPONENTS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,69 @@ | ||
FROM edrixs/edrixs_base | ||
WORKDIR /project | ||
|
||
COPY . ./src/edrixs | ||
|
||
# build fortran part of edrixs | ||
RUN export LD_LIBRARY_PATH="/usr/local/lib:\$LD_LIBRARY_PATH" \ | ||
&& make -C src/edrixs/src F90=mpif90 LIBS="-L/usr/local/lib -lopenblas -lparpack -larpack" \ | ||
&& make install -C src/edrixs/src \ | ||
# build python part of edrixs | ||
&& cd src/edrixs \ | ||
&& python setup.py build_ext --library-dirs=/usr/local/lib \ | ||
&& pip install . \ | ||
&& cd ../../ \ | ||
# set env | ||
&& echo "export PATH=/project/src/edrixs/bin:\$PATH" >> ~/.bashrc \ | ||
&& echo "export PATH=/project/src/edrixs/bin:\$PATH" >> /home/rixs/.bashrc \ | ||
# copy examples to /home/rixs | ||
&& cp -r src/edrixs/examples /home/rixs/edrixs_examples \ | ||
&& chown -R rixs:rixs /home/rixs/edrixs_examples | ||
FROM ubuntu:22.04 as base | ||
|
||
# general environment for docker | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# base packages | ||
RUN apt-get update && apt-get install -y --no-install-recommends sudo curl vim libgfortran-11-dev libopenmpi-dev libopenblas-dev python3 libpython3-dev python3-pip python3-venv && rm -rf /var/lib/apt/lists/* | ||
|
||
# create docker user | ||
RUN useradd -m -s /bin/bash -u 1999 docker && echo "docker:docker" | chpasswd && adduser docker sudo | ||
|
||
# enable passwordless sudo | ||
RUN echo "docker ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/docker | ||
|
||
# allow docker user to install into /opt | ||
RUN sudo chown docker:docker /opt | ||
|
||
USER docker | ||
WORKDIR /home/docker | ||
|
||
# create venv | ||
ENV VIRTUAL_ENV=/opt/edrixs | ||
RUN python3 -m venv $VIRTUAL_ENV | ||
ENV PATH="$VIRTUAL_ENV/bin:$PATH" | ||
|
||
FROM base as dep_builder | ||
|
||
ENV LD_LIBRARY_PATH="/opt/edrixs/lib" \ | ||
CMAKE_PREFIX_PATH="/opt/edrixs" | ||
|
||
# install build tools | ||
RUN sudo apt-get update && sudo apt-get install -y --no-install-recommends \ | ||
autoconf \ | ||
build-essential \ | ||
gfortran \ | ||
ca-certificates \ | ||
coreutils \ | ||
curl \ | ||
git \ | ||
cmake | ||
|
||
RUN curl -L https://github.com/opencollab/arpack-ng/archive/refs/tags/3.8.0.tar.gz | tar xvz && \ | ||
cd arpack-ng-3.8.0 && \ | ||
mkdir build && \ | ||
cd build && \ | ||
cmake -DMPI=ON -DCMAKE_INSTALL_PREFIX=/opt/edrixs .. && \ | ||
make -j4 && \ | ||
make test && \ | ||
make install | ||
|
||
FROM dep_builder as app_builder | ||
|
||
RUN pip install --upgrade pip setuptools | ||
RUN pip install numpy scipy sympy matplotlib sphinx mpi4py ipython jupyter jupyterlab | ||
|
||
COPY --chown=docker . edrixs | ||
|
||
RUN export VERBOSE=1 FFLAGS="-Wall -Wunused -Wextra -Wno-maybe-uninitialized -Ofast -faggressive-loop-optimizations -fno-tree-pre" && \ | ||
pip install -v ./edrixs | ||
|
||
from base as app | ||
|
||
# see https://github.com/open-mpi/ompi/issues/4948 | ||
ENV LD_LIBRARY_PATH="/opt/edrixs/lib" \ | ||
CMAKE_PREFIX_PATH="/opt/edrixs" \ | ||
OMPI_MCA_btl_vader_single_copy_mechanism="none" | ||
|
||
COPY --from=app_builder /opt /opt | ||
COPY --from=app_builder --chown=docker /home/docker/edrixs/examples examples |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it will only find Python 3.7 in this case... I guess we can keep it for now and see what happens when we remove py37 support.