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

Commit

Permalink
More updates to get an automated build working and exporting a Python…
Browse files Browse the repository at this point in the history
… wheel file for a particular build
  • Loading branch information
daminton committed Aug 11, 2023
1 parent 9af17e5 commit 88e40e5
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 11 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
!swiftest/*.h
!swiftest/tests/*.py
!src/*/*.f90
!src/globals/globals_module.f90.in
!buildscripts/*.sh
!buildscripts/*.yml
32 changes: 30 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ ENV SHELL="/bin/bash"
WORKDIR /swiftest

# Compile the dependencies
COPY ./buildscripts ./buildscripts/
COPY ./buildscripts/fetch_dependencies.sh ./buildscripts/
COPY ./buildscripts/get_platform.sh ./buildscripts/
COPY ./buildscripts/make_build_environment.sh ./buildscripts/
COPY ./buildscripts/build_dependencies.sh ./buildscripts/
COPY ./buildscripts/swiftest-build-env.yml ./buildscripts/
RUN ${SCRIPT_DIR}/fetch_dependencies.sh
RUN if [ "$BUILDIMAGE" = "intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04" ]; then \
apt-get update && \
Expand All @@ -33,7 +37,22 @@ RUN if [ "$BUILDIMAGE" = "intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04" ]; the
echo "conda activate swiftest-build-env" >> ~/.bashrc && \
/bin/bash -lic "${SCRIPT_DIR}/build_dependencies.sh GNU"; \
fi

FROM ${BUILDIMAGE} as build-swiftest
ENV SCRIPT_DIR="buildscripts"
SHELL ["/bin/bash", "--login", "-c"]
ENV SHELL="/bin/bash"
WORKDIR /swiftest
ENV BUILD_DIR=/swiftest/build

# Copy build artifacts over to the swiftest package builder stage
COPY --from=build-deps ${BUILD_DIR}/lib/ /usr/local/lib/
COPY --from=build-deps ${BUILD_DIR}/include/ /usr/local/include/
COPY --from=build-deps ${BUILD_DIR}/bin/ /usr/local/bin/
COPY --from=build-deps ${BUILD_DIR}/share/ /usr/local/share/

# Compile the Swiftest project
COPY ./buildscripts/build_swiftest.sh ./buildscripts/
COPY ./cmake/ ./cmake/
COPY ./src/ ./src/
COPY ./swiftest/ ./swiftest/
Expand All @@ -43,4 +62,13 @@ COPY ./environment.yml ./
COPY ./pyproject.toml ./
COPY ./requirements.txt ./
COPY ./version.txt ./
RUN /bin/bash -lic "${SCRIPT_DIR}/build_swiftest.sh"
ENV PIP_ROOT_USER_ACTION=ignore
RUN if [ "$BUILDIMAGE" = "intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04" ]; then \
/bin/bash -lic "${SCRIPT_DIR}/build_swiftest.sh Intel"; \
else \
/bin/bash -lic "${SCRIPT_DIR}/build_swiftest.sh GNU"; \
fi

#Export the generated wheel file to the host machine
FROM scratch as export-wheel
COPY --from=build-swiftest /swiftest/dist/ /dist/
11 changes: 7 additions & 4 deletions buildscripts/build_swiftest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ esac
export F77=${FC}
echo "Using $COMPILER compilers:\nFC: $FC\nCC: $CC\nCXX: $CXX\n"

export CPATH=$DEPDIR
export LD_LIBRARY_PATH="${CPATH}/lib:${LD_LIBRARY_PATH}"
export LIBS="-lhdf5_hl -lhdf5 -lz"
export CPATH=$DEPDIR/include
export NETCDF_FORTRAN_HOME=$DEPDIR
export LD_LIBRARY_PATH="${DEPDIR}/lib:${LD_LIBRARY_PATH}"
export LIBS=$(${DEPDIR}/bin/nf-config --all)
export LDFLAGS="-L${DEPDIR}/lib"
export CFLAGS="-fPIC"
export CMAKE_ARGS="-DBUILD_SHARED_LIBS=OFF"
Expand All @@ -64,4 +65,6 @@ else
export FFLAGS="${CFLAGS}"
fi
cd $ROOT_DIR
pip install .
python -m pip install build
python -m build --wheel

10 changes: 5 additions & 5 deletions cmake/Modules/FindNETCDF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

# - Finds the NetCDF libraries

find_path(NETCDF_INCLUDE_DIR NAMES netcdf.mod HINTS ENV NETCDF_FORTRAN_HOME ENV CPATH)
find_library(NETCDF_FORTRAN_LIBRARY NAMES netcdff HINTS ENV NETCDF_FORTRAN_HOME ENV LD_LIBRARY_PATH)
find_library(NETCDF_LIBRARY NAMES netcdf HINTS ENV NETCDF_FORTRAN_HOME ENV LD_LIBRARY_PATH)
find_path(NETCDF_INCLUDE_DIR NAMES netcdf.mod HINTS ENV NETCDF_FORTRAN_HOME)
find_library(NETCDF_FORTRAN_LIBRARY NAMES netcdff HINTS ENV NETCDF_FORTRAN_HOME)
find_library(NETCDF_LIBRARY NAMES netcdf HINTS ENV NETCDF_FORTRAN_HOME)

set(NETCDF_FOUND TRUE)
# Note for posterity: When building static libraries, NETCDF_FORTRAN_LIBRARY must come *before* NETCDF_LIBRARY. Otherwise you get a bunch of "undefined reference to" errors
set(NETCDF_LIBRARIES ${NETCDF_FORTRAN_LIBRARY} ${NETCDF_LIBRARY} CACHE STRING "NetCDF libraries")

mark_as_advanced(NETCDF_LIBRARY NETCDF_FORTRAN_LIBRARY NETCDF_INCLUDE_DIR)
mark_as_advanced(NETCDF_LIBRARY NETCDF_FORTRAN_LIBRARY NETCDF_INCLUDE_DIR)
set(NETCDF_LIBRARIES ${NETCDF_FORTRAN_LIBRARY} ${NETCDF_LIBRARY} CACHE STRING "NetCDF libraries")

0 comments on commit 88e40e5

Please sign in to comment.