Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Continued restructuring and started adding skbuild to the python side…
Browse files Browse the repository at this point in the history
… to help automate the building of the extension module
  • Loading branch information
MintoDA1 authored and MintoDA1 committed Aug 8, 2023
1 parent 1da0ce1 commit d955405
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ dump*
**/.DS_Store
!python/swiftest/tests/test_suite.py
!version.txt
**/_skbuild



#Documentation
Expand Down
28 changes: 17 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,19 @@ RUN cd netcdf-fortran-4.6.1 && \
make install

FROM intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04 as build_driver
SHELL ["/bin/bash", "--login", "-c"]
SHELL ["/bin/bash", "-c"]
COPY --from=build_deps /usr/local/. /usr/local/
ENV PATH /root/miniconda3/bin:$PATH

RUN wget https://repo.anaconda.com/miniconda/Miniconda3-py311_23.5.2-0-Linux-x86_64.sh && \
/bin/bash Miniconda3-py311_23.5.2-0-Linux-x86_64.sh -b && \
/root/miniconda3/bin/conda init bash && \
source /root/.bashrc && conda update --all -y && \
conda install conda-libmamba-solver -y && \
conda config --set solver libmamba && \
conda install -c conda-forge scikit-build -y&& \
conda install -c anaconda cython -y

ENV INSTALL_DIR="/usr/local"
ENV CC="${ONEAPI_ROOT}/compiler/latest/linux/bin/icx"
ENV FC="${ONEAPI_ROOT}/compiler/latest/linux/bin/ifx"
Expand All @@ -103,26 +114,21 @@ ENV NETCDF_FORTRAN_HOME=${NETCDF_HOME}
ENV NETCDF_LIBRARY=${NETCDF_HOME}
ENV FOR_COARRAY_NUM_IMAGES=1
ENV OMP_NUM_THREADS=1

ENV FC="${ONEAPI_ROOT}/mpi/latest/bin/mpiifort"
ENV CC="${ONEAPI_ROOT}/mpi/latest/bin/mpicc -cc=icx"
ENV CXX="${ONEAPI_ROOT}/mpi/latest/bin/mpicc -cc=icpx"
ENV FFLAGS="-fPIC -standard-semantics"
ENV LDFLAGS="-L/usr/local/lib"
ENV LIBS="-lhdf5_hl -lhdf5 -lz"
ENV PATH /root/miniconda3/bin:$PATH

COPY ./cmake/ /swiftest/cmake/
COPY ./src/ /swiftest/src/
COPY ./CMakeLists.txt /swiftest/
COPY ./python/ /swiftest/python/
COPY ./version.txt /swiftest/
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-py311_23.5.2-0-Linux-x86_64.sh && \
/usr/bin/bash Miniconda3-py311_23.5.2-0-Linux-x86_64.sh -b && \
/root/miniconda3/bin/conda init bash && \
source /root/.bashrc && conda update --all -y && \
conda install conda-libmamba-solver -y && \
conda config --set solver libmamba && \
conda install -c conda-forge numpy -y&& \
conda install -c anaconda cython -y && \
cd swiftest && \

RUN cd swiftest && \
cmake -S . -B build -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
-DMACHINE_CODE_VALUE=${MACHINE_CODE_VALUE} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
Expand Down
4 changes: 4 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ SET(SETUP_PY_IN "${PY}/setup.py.in")
SET(SETUP_PY_OUT "${PY}/setup.py")

CONFIGURE_FILE(${SETUP_PY_IN} ${SETUP_PY_OUT})

# ADD_LIBRARY(pybindings MODULE hello/_hello.cxx)
# python_extension_module(_hello)
# install(TARGETS _hello LIBRARY DESTINATION hello)
8 changes: 6 additions & 2 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
If not, see: https://www.gnu.org/licenses.
"""

from setuptools import setup, find_packages, Extension
#from skbuild import setup
from setuptools import setup
from setuptools import find_packages, Extension
from Cython.Build import cythonize
import os

Expand All @@ -19,7 +21,7 @@
include_dirs = "/Users/daminton/git/swiftest/apple_install/usr/local/include;/Users/daminton/git/swiftest/apple_install/usr/local/include"
include_dirs = include_dirs.split()
include_dirs.append(root_dir)
link_flags = " -static-libgfortran -static-libgcc -static-libstdc++"
link_flags = " -static-libgfortran -static-libgcc -static-libstdc++ -L/Users/daminton/git/swiftest/lib -lswiftest /Users/daminton/git/swiftest/apple_install/usr/local/lib/libnetcdff.a /Users/daminton/git/swiftest/apple_install/usr/local/lib/libnetcdf.a -L/Users/daminton/git/swiftest/apple_install/usr/local/lib -lhdf5_hl -lhdf5 -lm -lz -lbz2 -lxml2 -lcurl"
link_flags = link_flags.split()

pybindings_extension = [Extension('swiftest.bindings',
Expand All @@ -34,5 +36,7 @@
author='David A. Minton',
author_email='daminton@purdue.edu',
url='https://github.itap.purdue.edu/MintonGroup/swiftest',
python_requires=">3.8",
license="GPLv3",
ext_modules = cythonize(pybindings_extension),
packages=find_packages())
8 changes: 6 additions & 2 deletions python/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
If not, see: https://www.gnu.org/licenses.
"""

from setuptools import setup, find_packages, Extension
#from skbuild import setup
from setuptools import setup
from setuptools import find_packages, Extension
from Cython.Build import cythonize
import os

Expand All @@ -19,7 +21,7 @@ root_dir = 'pybindings'
include_dirs = "${SWIFTEST_INCLUDE_DIR}"
include_dirs = include_dirs.split()
include_dirs.append(root_dir)
link_flags = "${CMAKE_Fortran_LINK_FLAGS}"
link_flags = "${SWIFTEST_LINK_FLAGS}"
link_flags = link_flags.split()

pybindings_extension = [Extension('swiftest.bindings',
Expand All @@ -34,5 +36,7 @@ setup(name='swiftest',
author='David A. Minton',
author_email='daminton@purdue.edu',
url='https://github.itap.purdue.edu/MintonGroup/swiftest',
python_requires=">3.8",
license="GPLv3",
ext_modules = cythonize(pybindings_extension),
packages=find_packages())
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ IF(USE_COARRAY)
SET_PROPERTY(TARGET ${SWIFTEST_LIBRARY} ${SWIFTEST_DRIVER} APPEND_STRING PROPERTY LINK_FLAGS "${Coarray_Fortran_FLAGS} ")
ENDIF(USE_COARRAY)

STRING(REPLACE ";" " " SWIFTEST_LINK_FLAGS "${CMAKE_Fortran_LINK_FLAGS} ${CMAKE_LINK_LIBRARY_FLAG}${SWIFTEST_LIBRARY} ${NETCDF_FORTRAN_LIBRARIES} ${NETCDF_LIBRARIES} $ENV{LIBS}")
STRING(REPLACE ";" " " SWIFTEST_LINK_FLAGS "${CMAKE_Fortran_LINK_FLAGS} -L${LIB} ${CMAKE_LINK_LIBRARY_FLAG}${SWIFTEST_LIBRARY} ${NETCDF_FORTRAN_LIBRARIES} ${NETCDF_LIBRARIES} $ENV{LIBS}")
SET(SWIFTEST_LINK_FLAGS "${SWIFTEST_LINK_FLAGS}" CACHE STRING "Link flags to pass to setup.py")

GET_TARGET_PROPERTY(SWIFTEST_INCLUDE_DIR ${SWIFTEST_DRIVER} INCLUDE_DIRECTORIES)
Expand Down

0 comments on commit d955405

Please sign in to comment.